auth

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddClaimHandler

func AddClaimHandler(next http.Handler, logger *zerolog.Logger) http.Handler

AddClaimHandler is a middleware that adds the telemetry claim to the context.

func ErrorHandler

func ErrorHandler(logger *zerolog.Logger) func(w http.ResponseWriter, r *http.Request, err error)

ErrorHandler is a custom error handler for the jwt middleware. It logs the error and then calls the default error handler.

func NewJWTMiddleware

func NewJWTMiddleware(issuer, jwksURI, contractAddress string, logger *zerolog.Logger) (*jwtmiddleware.JWTMiddleware, error)

NewJWTMiddleware creates a new JWT middleware with the given issuer and contract address. This middleware will validate the token and add the claim to the context.

func RequiresPrivilegeCheck

func RequiresPrivilegeCheck(ctx context.Context, _ any, next graphql.Resolver, privs []model.Privilege) (any, error)

RequiresPrivilegeCheck checks if the claim set in the context has the required privileges.

func RequiresTokenCheck

func RequiresTokenCheck(ctx context.Context, _ any, next graphql.Resolver) (any, error)

RequiresTokenCheck checks if the tokenID in the context matches the tokenID in the claim.

Types

type TelemetryClaim

type TelemetryClaim struct {
	privilegetoken.CustomClaims
	// contains filtered or unexported fields
}

TelemetryClaim is a custom claim for the telemetry API.

func (*TelemetryClaim) SetPrivileges

func (t *TelemetryClaim) SetPrivileges()

SetPrivileges sets the privileges from the embedded CustomClaims.

func (*TelemetryClaim) Validate

func (t *TelemetryClaim) Validate(context.Context) error

Validate function is required to implement the validator.CustomClaims interface.

type TelemetryClaimContextKey

type TelemetryClaimContextKey struct{}

TelemetryClaimContextKey is a custom key for the context to store the custom claims.

Jump to

Keyboard shortcuts

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