Documentation ¶
Index ¶
- func OauthRouter(ctx context.Context) http.Handler
- type APIKeyCache
- type AuthCache
- func (a *AuthCache) CacheAPIKey(key string, role string)
- func (a *AuthCache) CacheJWTToken(token string, jwtToken *jwt.Token)
- func (a *AuthCache) LookupCachedAPIKey(key string) string
- func (a *AuthCache) LookupCachedToken(token string) (*jwt.Token, bool, error)
- func (a *AuthCache) TokenIsValid(token string) (*jwt.Token, bool, error)
- type InfoResponse
- type Middleware
- type OauthHandler
- type TokenCache
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type APIKeyCache ¶
type AuthCache ¶
type AuthCache struct { JWTTokenCache map[string]TokenCache APITokenCache map[string]APIKeyCache }
func NewAuthCache ¶
func NewAuthCache() *AuthCache
func (*AuthCache) CacheAPIKey ¶
CacheAPIKey adds the api key to the cache
func (*AuthCache) CacheJWTToken ¶
CacheJWTToken adds the token to the cache
func (*AuthCache) LookupCachedAPIKey ¶
LookupCachedAPIKey checks if the api key is in the cache returns the role if found, "unknown" if not found
func (*AuthCache) LookupCachedToken ¶
LookupCachedToken checks if the token is in the cache and returns it if it is
type InfoResponse ¶
func (*InfoResponse) Render ¶
func (i *InfoResponse) Render(w http.ResponseWriter, r *http.Request) error
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
func NewMiddleware ¶
func NewMiddleware(db *sql.DB) *Middleware
func (*Middleware) APIKeyLoader ¶
func (m *Middleware) APIKeyLoader(next http.Handler) http.Handler
APIKeyLoader middleware checks the provided api key against the database and sets the role if found
func (*Middleware) AdminOnly ¶
func (m *Middleware) AdminOnly(next http.Handler) http.Handler
AdminOnly middleware restricts access to just administrators.
func (*Middleware) OauthLoader ¶
func (m *Middleware) OauthLoader(next http.Handler) http.Handler
OauthLoader middleware ensures that a JWT token was passed and it's a valid token.
func (*Middleware) RoleVerifier ¶
func (m *Middleware) RoleVerifier(next http.Handler) http.Handler
RoleVerifier middleware ensures that the Role is set and valid in context.
type OauthHandler ¶
type OauthHandler struct {
// contains filtered or unexported fields
}
func (*OauthHandler) Authenticate ¶
func (h *OauthHandler) Authenticate(w http.ResponseWriter, r *http.Request)
func (*OauthHandler) Callback ¶
func (h *OauthHandler) Callback(w http.ResponseWriter, r *http.Request)
func (*OauthHandler) GetAuthURL ¶
func (h *OauthHandler) GetAuthURL(w http.ResponseWriter, r *http.Request)
func (*OauthHandler) Info ¶
func (h *OauthHandler) Info(w http.ResponseWriter, r *http.Request)
Click to show internal directories.
Click to hide internal directories.