auth

package
v0.1.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2025 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSessionNotFound           = errors.New("session not found") // Referenced in HandleCallback error mapping logic? (Keep for now, though defined in core/session)
	ErrSessionExpired            = errors.New("session expired")   // Referenced in HandleCallback error mapping logic? (Keep for now, though defined in core/session)
	ErrUserNotFound              = errors.New("user not found")    // Referenced in HandleCallback error mapping logic? (Keep for now, though defined in core/users)
	ErrTeamNotFound              = errors.New("team not found")    // Referenced in HandleCallback error mapping logic? (Keep for now, though defined in core/users)
	ErrUnauthorizedUser          = errors.New("unauthorized user")
	ErrUserInactive              = errors.New("user inactive")
	ErrOIDCProviderNotConfigured = errors.New("OIDC provider not configured")
	ErrOIDCInvalidToken          = errors.New("invalid OIDC token")
	ErrOIDCEmailNotVerified      = errors.New("email not verified")
	ErrAdminNotFound             = errors.New("admin not found") // May not be needed if admin check moves to core
)

Define OIDC/Auth specific errors.

Functions

This section is empty.

Types

type OIDCProvider

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

OIDCProvider handles OIDC authentication interactions.

func NewOIDCProvider

func NewOIDCProvider(oidcCfg *config.OIDCConfig, log *slog.Logger) (*OIDCProvider, error)

NewOIDCProvider initializes an OIDCProvider based on the provided configuration. It requires explicit AuthURL and TokenURL, but uses ProviderURL for discovery to set up the ID token verifier.

func (*OIDCProvider) GetAuthURL

func (p *OIDCProvider) GetAuthURL(state string) string

GetAuthURL returns the URL for the OIDC authorization endpoint with the given state.

func (*OIDCProvider) HandleCallback

func (p *OIDCProvider) HandleCallback(ctx context.Context, db *sqlite.DB, log *slog.Logger, authCfg *config.AuthConfig, code, state string) (*models.User, *models.Session, error)

HandleCallback processes the OIDC callback, exchanges the code for tokens, verifies the ID token, looks up or potentially creates the user in the local database, and creates a local application session.

Jump to

Keyboard shortcuts

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