auth

package
v0.0.0-...-3ca6529 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContextUsernameKey contextKey = "username"

	// Does not use contextKey type because the jwt middleware improperly updates context with string key type
	// See https://github.com/auth0/go-jwt-middleware/blob/master/jwtmiddleware.go#L232
	ContextAuthKey string = "user"
)

Variables

This section is empty.

Functions

func GetUsernameFromContext

func GetUsernameFromContext(ctx context.Context) string

func SetUsernameContext

func SetUsernameContext(ctx context.Context, username string) context.Context

Types

type AuthMiddleware

type AuthMiddleware struct{}

func NewAuthMiddleware

func NewAuthMiddleware() (*AuthMiddleware, error)

func (*AuthMiddleware) AuthenticateAccountJWT

func (a *AuthMiddleware) AuthenticateAccountJWT(next http.Handler) http.Handler

Middleware handler to validate JWT tokens and authenticate users

type AuthMiddlewareMock

type AuthMiddlewareMock struct{}

func (*AuthMiddlewareMock) AuthenticateAccountJWT

func (a *AuthMiddlewareMock) AuthenticateAccountJWT(next http.Handler) http.Handler

type AuthPayload

type AuthPayload struct {
	Username  string `json:"username"`
	FirstName string `json:"first_name"`
	LastName  string `json:"last_name"`
	Email     string `json:"email"`
	Issuer    string `json:"iss"`
	ClientID  string `json:"clientId"`
}

AuthPayload defines the structure of the JWT payload we expect from RHD JWT tokens

func GetAuthPayload

func GetAuthPayload(r *http.Request) (*AuthPayload, error)

func GetAuthPayloadFromContext

func GetAuthPayloadFromContext(ctx context.Context) (*AuthPayload, error)

Get authorization payload api object from context

type AuthorizationMiddleware

type AuthorizationMiddleware interface {
	AuthorizeApi(next http.Handler) http.Handler
}

func NewAuthzMiddleware

func NewAuthzMiddleware(ocmClient *ocm.Client, action, resourceType string) AuthorizationMiddleware

func NewAuthzMiddlewareMock

func NewAuthzMiddlewareMock() AuthorizationMiddleware

type JWTMiddleware

type JWTMiddleware interface {
	AuthenticateAccountJWT(next http.Handler) http.Handler
}

Jump to

Keyboard shortcuts

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