Documentation ¶
Index ¶
- Constants
- func ExtractToken(headerValue string) (string, error)
- func RequestLoggerMiddleware(logger logger.Logger) gin.HandlerFunc
- func SetupRouter(useOIDCAuth bool, l logger.Logger, authMiddleware *AuthMiddleware) (*gin.Engine, error)
- type AuthMiddleware
- type GinContext
- type GinRouter
- type RedisTokenCache
- type TokenCache
Constants ¶
View Source
const DefaultExpiration = 30 * time.Second
Variables ¶
This section is empty.
Functions ¶
func ExtractToken ¶
ExtractToken extracts the token from the Authorization header.
func RequestLoggerMiddleware ¶
func RequestLoggerMiddleware(logger logger.Logger) gin.HandlerFunc
func SetupRouter ¶
Types ¶
type AuthMiddleware ¶
type AuthMiddleware struct { Verifier *oidc.IDTokenVerifier Cache TokenCache Logger logger.Logger }
func LoadAuthMiddleware ¶
func LoadAuthMiddleware(clientID string, providerURL string, cache TokenCache, l logger.Logger) (*AuthMiddleware, error)
func NewAuthMiddleware ¶
func NewAuthMiddleware(clientID string, provider *oidc.Provider, cache TokenCache, logger logger.Logger) (*AuthMiddleware, error)
func (*AuthMiddleware) MiddlewareFunc ¶
func (a *AuthMiddleware) MiddlewareFunc() gin.HandlerFunc
MiddlewareFunc returns a gin.HandlerFunc (middleware) that checks for a valid token.
type GinContext ¶
type GinContext struct {
// contains filtered or unexported fields
}
GinContext is an adapter that implements the Context interface for Gin.
func (*GinContext) Bind ¶
func (gc *GinContext) Bind(obj any) error
Bind binds the request body to obj.
func (*GinContext) BindJSON ¶
func (gc *GinContext) BindJSON(obj any) error
BindJSON binds the JSON request body into obj.
func (*GinContext) Request ¶
func (gc *GinContext) Request() *http.Request
Request returns the underlying http.Request.
type GinRouter ¶
type GinRouter struct {
// contains filtered or unexported fields
}
GinRouter implements the Router interface for Gin framework.
type RedisTokenCache ¶
RedisTokenCache is a Redis implementation of TokenCache.
func (*RedisTokenCache) Get ¶
func (r *RedisTokenCache) Get(token string) (bool, error)
Get gets a token from the cache.
func (*RedisTokenCache) Set ¶
func (r *RedisTokenCache) Set(token string) error
Set sets a token in the cache.
Click to show internal directories.
Click to hide internal directories.