handlers

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAuthNotEnabled  = errors.New("OIDC authentication is not enabled")
	ErrStateMissing    = errors.New("state parameter missing")
	ErrInvalidState    = errors.New("invalid state parameter")
	ErrAuthCodeMissing = errors.New("authorization code not provided")
	ErrFailedExchange  = errors.New("failed to exchange code for token")
	ErrNoIDToken       = errors.New("no id_token field in oauth2 token")
	ErrFailedVerify    = errors.New("failed to verify ID token")
	ErrFailedClaims    = errors.New("failed to extract user claims")
	ErrNoAuthCode      = errors.New("no authorization code found")
	ErrMissingUserInfo = errors.New("missing user info")
)

Functions

This section is empty.

Types

type APIKeyCreateInput

type APIKeyCreateInput struct {
	Payload *CreateAPIKeyPayload `in:"body=json"`
}

type APIKeyHandler

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

func NewAPIKeyHandler

func NewAPIKeyHandler(db *gorm.DB) *APIKeyHandler

func (*APIKeyHandler) CreateAPIKey

func (h *APIKeyHandler) CreateAPIKey(w http.ResponseWriter, r *http.Request)

CreateAPIKey creates a new API key.

func (*APIKeyHandler) DeleteAPIKey

func (h *APIKeyHandler) DeleteAPIKey(w http.ResponseWriter, r *http.Request)

DeleteAPIKey deletes an API key.

func (*APIKeyHandler) ListAPIKeys

func (h *APIKeyHandler) ListAPIKeys(w http.ResponseWriter, r *http.Request)

ListAPIKeys lists all API keys for the authenticated user.

func (*APIKeyHandler) RevokeAPIKey

func (h *APIKeyHandler) RevokeAPIKey(w http.ResponseWriter, r *http.Request)

RevokeAPIKey revokes an API key.

type APIKeyIDInput

type APIKeyIDInput struct {
	ID string `in:"path=id"`
}

type Auth

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

Auth represents the authentication handler.

func NewAuth

func NewAuth(ctx context.Context, cfg *config.Config, db *gorm.DB) (*Auth, error)

NewAuth creates a new authentication handler with initialized OIDC components.

func (*Auth) Callback

func (a *Auth) Callback(w http.ResponseWriter, r *http.Request)

Callback handles the OIDC callback and exchanges code for token.

func (*Auth) Login

func (a *Auth) Login(w http.ResponseWriter, r *http.Request)

Login redirects to the OIDC provider for authentication.

func (*Auth) Logout

func (a *Auth) Logout(w http.ResponseWriter, r *http.Request)

Logout handles user logout.

func (*Auth) Me

func (a *Auth) Me(w http.ResponseWriter, r *http.Request)

type AuthResponse

type AuthResponse struct {
	Success bool        `json:"success"`
	Message string      `json:"message,omitempty"`
	Token   string      `json:"token,omitempty"`
	User    *users.User `json:"user,omitempty"`
}

AuthResponse represents the authentication response.

type CallbackInput

type CallbackInput struct {
	State string `in:"query=state"`
	Code  string `in:"query=code"`
}

CallbackInput represents the input for OAuth callback request.

type Claims

type Claims struct {
	Sub    string   `json:"sub"`
	Email  string   `json:"email"`
	Name   string   `json:"name"`
	Groups []string `json:"groups,omitempty"` // OIDC groups claim
	Exp    int64    `json:"exp"`              // Expiration time from ID token
}

func (*Claims) GetExpirationTime

func (c *Claims) GetExpirationTime() time.Time

func (*Claims) PostProcess

func (c *Claims) PostProcess()

type CreateAPIKeyPayload

type CreateAPIKeyPayload struct {
	Name      string     `json:"name"                 validate:"required,min=1,max=255"`
	Scopes    []string   `json:"scopes,omitempty"`
	ExpiresAt *time.Time `json:"expires_at,omitempty"`
}

type GeoIP

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

GeoIP handles GeoIP-related requests.

func NewGeoIP

func NewGeoIP(mm *maxmind.Client, cfg *config.Config) *GeoIP

NewGeoIP creates a new GeoIP handler.

func (*GeoIP) GetGeoIP

func (h *GeoIP) GetGeoIP(w http.ResponseWriter, r *http.Request)

GetGeoIP handles requests to get GeoIP information for a specific IP.

func (*GeoIP) GetMyIP

func (h *GeoIP) GetMyIP(w http.ResponseWriter, r *http.Request)

GetMyIP handles requests to get GeoIP information for the requester's IP.

type LoginInput

type LoginInput struct {
	Redirect string `in:"query=redirect"`
}

LoginInput represents the input for login request.

Jump to

Keyboard shortcuts

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