auth

package
v0.0.0-...-d5c1077 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DEBUG bool

Functions

func GetToken

func GetToken(ctx context.Context) (*oauth2.Token, interface {
	error
	shared.StatusCoder
})

Types

type Auth

type Auth struct {
	OauthConfig *oauth2.Config
	Salt        string

	Store      TokenStore
	KeyGen     KeyGenerator
	DefaultURL string
}

func (*Auth) Callback

func (h *Auth) Callback(w http.ResponseWriter, req *http.Request)

func (*Auth) Login

func (h *Auth) Login(w http.ResponseWriter, req *http.Request)

func (*Auth) RedirectURL

func (h *Auth) RedirectURL() string

func (*Auth) WithOauthToken

func (h *Auth) WithOauthToken(defaultKey string) func(http.Handler) http.Handler

type ConstantKeyGenerator

type ConstantKeyGenerator struct {
	Key string
}

func (*ConstantKeyGenerator) GenerateKey

func (g *ConstantKeyGenerator) GenerateKey(req *http.Request, token *oauth2.Token, salt string) (string, error)

type InmemoryStore

type InmemoryStore struct {
	TokenMap map[string]*oauth2.Token // apikey -> token
	// contains filtered or unexported fields
}

func NewInmemoryStore

func NewInmemoryStore() *InmemoryStore

func (*InmemoryStore) GetToken

func (s *InmemoryStore) GetToken(key string) (*oauth2.Token, bool)

func (*InmemoryStore) SetToken

func (s *InmemoryStore) SetToken(key string, token *oauth2.Token)

type KeyGenerator

type KeyGenerator interface {
	GenerateKey(req *http.Request, token *oauth2.Token, salt string) (string, error)
}

type TokenStore

type TokenStore interface {
	GetToken(key string) (*oauth2.Token, bool)
	SetToken(key string, token *oauth2.Token)
}

type UUIDKeyGenerator

type UUIDKeyGenerator struct {
}

func (*UUIDKeyGenerator) GenerateKey

func (g *UUIDKeyGenerator) GenerateKey(req *http.Request, token *oauth2.Token, salt string) (string, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL