auth

package
v0.0.0-...-36fb464 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth0Config

type Auth0Config struct {
	Domain       string
	ClientID     string
	ClientSecret string
	Audience     string
	Enabled      bool
}

Auth0Config holds Auth0 configuration

type Auth0Middleware

type Auth0Middleware struct {
	// contains filtered or unexported fields
}

Auth0Middleware provides Auth0 JWT validation

func NewAuth0Middleware

func NewAuth0Middleware(config *Auth0Config) (*Auth0Middleware, error)

NewAuth0Middleware creates a new Auth0 middleware

func (*Auth0Middleware) IsEnabled

func (a *Auth0Middleware) IsEnabled() bool

IsEnabled returns whether Auth0 is enabled

func (*Auth0Middleware) Middleware

func (a *Auth0Middleware) Middleware(next http.HandlerFunc) http.HandlerFunc

Middleware returns an HTTP middleware function for Auth0 authentication

func (*Auth0Middleware) ValidateToken

func (a *Auth0Middleware) ValidateToken(tokenString string) (*UserInfo, error)

ValidateToken validates a JWT token and returns user information

type CombinedAuthMiddleware

type CombinedAuthMiddleware struct {
	// contains filtered or unexported fields
}

CombinedAuthMiddleware provides both basic auth and Auth0 authentication

func NewCombinedAuthMiddleware

func NewCombinedAuthMiddleware(auth0Config *Auth0Config, basicAuthCallback func(string, string) bool) (*CombinedAuthMiddleware, error)

NewCombinedAuthMiddleware creates a middleware that supports both auth methods

func (*CombinedAuthMiddleware) Middleware

Middleware returns an HTTP middleware that tries Auth0 first, then falls back to basic auth

type CustomClaims

type CustomClaims struct {
	Scope string `json:"scope"`
	jwt.RegisteredClaims
}

CustomClaims represents the custom claims in the JWT token

func (CustomClaims) Validate

func (c CustomClaims) Validate(ctx context.Context) error

Validate validates the custom claims

type OAuthTokenResponse

type OAuthTokenResponse struct {
	AccessToken  string `json:"access_token"`
	TokenType    string `json:"token_type"`
	ExpiresIn    int    `json:"expires_in"`
	RefreshToken string `json:"refresh_token,omitempty"`
	Scope        string `json:"scope,omitempty"`
}

OAuthTokenResponse represents OAuth token response

type SCIMMiddleware

type SCIMMiddleware struct {
	// contains filtered or unexported fields
}

SCIMMiddleware handles SCIM-based authentication

func NewSCIMMiddleware

func NewSCIMMiddleware(db database.Database, config *database.SCIMConfig) *SCIMMiddleware

NewSCIMMiddleware creates a new SCIM middleware

func (*SCIMMiddleware) HandleCallback

func (s *SCIMMiddleware) HandleCallback(w http.ResponseWriter, r *http.Request)

HandleCallback handles OAuth callback

func (*SCIMMiddleware) HandleLogin

func (s *SCIMMiddleware) HandleLogin(w http.ResponseWriter, r *http.Request)

HandleLogin initiates SCIM OAuth flow

func (*SCIMMiddleware) IsEnabled

func (s *SCIMMiddleware) IsEnabled() bool

IsEnabled returns whether SCIM is enabled

type SCIMUserInfo

type SCIMUserInfo struct {
	ID          string `json:"sub"`                // Okta uses "sub" for user ID
	Username    string `json:"preferred_username"` // Okta uses "preferred_username"
	Email       string `json:"email"`
	DisplayName string `json:"name"`        // Okta uses "name" for display name
	FirstName   string `json:"given_name"`  // Okta uses "given_name"
	LastName    string `json:"family_name"` // Okta uses "family_name"
	Active      bool   `json:"active"`
}

SCIMUserInfo represents user information from SCIM provider

type UserInfo

type UserInfo struct {
	Subject   string    `json:"subject"`
	Email     string    `json:"email"`
	Username  string    `json:"username"`
	Scopes    []string  `json:"scopes"`
	IssuedAt  time.Time `json:"issued_at"`
	ExpiresAt time.Time `json:"expires_at"`
}

UserInfo represents authenticated user information

func GetUserInfoFromContext

func GetUserInfoFromContext(ctx context.Context) (*UserInfo, bool)

GetUserInfoFromContext extracts user info from request context

func (*UserInfo) HasScope

func (u *UserInfo) HasScope(scope string) bool

HasScope checks if the user has a specific scope

Jump to

Keyboard shortcuts

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