auth

package
v2.23.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func CheckRolesFromLoginClientMiddleware

func CheckRolesFromLoginClientMiddleware(loginClient string, roleCheckingHandlerFunc auth.RoleCheckingHandlerFunc) gin.HandlerFunc

CheckRolesFromLoginClientMiddleware takes the <raw token> and the <jwt issuer> from the current ginContext and uses the given handler <roleCheckingHandlerFunc> Any error returned from <roleCheckingHandlerFunc> will result in a rejected request It requires SetRawTokenIntoRequestContext and SetJwtIssuerIntoRequestContext to be called before its usage the target login client will be taken from <loginClient>

func CheckRolesMiddleware

func CheckRolesMiddleware(roleCheckingHandlerFunc auth.RoleCheckingHandlerFunc) gin.HandlerFunc

CheckRolesMiddleware takes all needed information from the current ginContext and uses the given handler <roleCheckingHandlerFunc> Any error returned from <roleCheckingHandlerFunc> will result in a rejected request It requires SetRawTokenIntoRequestContext, SetJwtIssuerIntoRequestContext and SetLoginClientIntoRequestContext to be called before its usage

func CustomSetRawTokenMiddleware added in v2.16.0

func CustomSetRawTokenMiddleware(extractor HeaderExtractor) gin.HandlerFunc

func DefaultHeaderExtraction added in v2.16.0

func DefaultHeaderExtraction(c *gin.Context) (string, error)

func JwtIssuerFromRequestContext

func JwtIssuerFromRequestContext(c *gin.Context) (string, bool)

func LoginClientFromRequestContext

func LoginClientFromRequestContext(ctx *gin.Context) (string, bool)

func PerformRoleChecking

func PerformRoleChecking(gCtx *gin.Context, loginClient string, roleCheckingHandlerFunc auth.RoleCheckingHandlerFunc)

PerformRoleChecking takes the <raw token> and the <jwt issuer> from the current ginContext and uses the given handler <roleCheckingHandlerFunc> It requires SetRawTokenIntoRequestContext and SetJwtIssuerIntoRequestContext to be called before its usage the target login client will be taken from <loginClient>

func RawTokenFromRequestContext

func RawTokenFromRequestContext(c *gin.Context) (string, bool)

func RequireRolesFromLoginClientMiddleware

func RequireRolesFromLoginClientMiddleware(loginClient string, roles ...string) gin.HandlerFunc

RequireRolesFromLoginClientMiddleware takes the <raw token> and the <jwt issuer> from the current ginContext and checks the existence of the required roles It requires SetRawTokenIntoRequestContext and SetJwtIssuerIntoRequestContext to be called before its usage the target login client will be taken from <loginClient>

func RequireRolesMiddleware

func RequireRolesMiddleware(roles ...string) gin.HandlerFunc

RequireRolesMiddleware takes all needed information from the current ginContext and checks the existence of the required roles within the current loginClient (taken from LoginClientFromRequestContext) It requires SetRawTokenIntoRequestContext, SetJwtIssuerIntoRequestContext and SetLoginClientIntoRequestContext to be called before its usage

func SetJwtIssuerIntoRequestContext

func SetJwtIssuerIntoRequestContext(ctx *gin.Context, jwtIssuer string)

func SetLoginClientIntoRequestContext

func SetLoginClientIntoRequestContext(ctx *gin.Context, loginClient string)

func SetRawTokenIntoRequestContext

func SetRawTokenIntoRequestContext(ctx *gin.Context, rawToken string)

func StaticJwtIssuerMiddleware

func StaticJwtIssuerMiddleware(jwtIssuer string) gin.HandlerFunc

func StaticLoginClientMiddleware

func StaticLoginClientMiddleware(loginClient string) gin.HandlerFunc

Types

type HeaderExtractor added in v2.16.0

type HeaderExtractor func(c *gin.Context) (string, error)

HeaderExtractor should extract and return the raw access token from the given request. Any returned error will be used to abort the current ongoing request

Jump to

Keyboard shortcuts

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