Documentation
¶
Index ¶
- type Config
- func (c *Config) CallbackHandler(w http.ResponseWriter, r *http.Request)
- func (c *Config) GetOrgID(ctx context.Context) string
- func (c *Config) GetPersonID(ctx context.Context) string
- func (c *Config) GetUserEmail(ctx context.Context) string
- func (c *Config) GetUserName(ctx context.Context) string
- func (c *Config) GetUserSession(ctx context.Context) *UserSession
- func (c *Config) GetUsername(ctx context.Context) string
- func (c *Config) GetWorkspaceID(ctx context.Context) string
- func (c *Config) HasRole(r *http.Request, role string) bool
- func (c *Config) IsAuthenticated(ctx context.Context) bool
- func (c *Config) LoginHandler(w http.ResponseWriter, r *http.Request)
- func (c *Config) LogoutCallbackHandler(w http.ResponseWriter, r *http.Request)
- func (c *Config) LogoutHandler(w http.ResponseWriter, r *http.Request)
- func (c *Config) Middleware(selfAuthenticatedPaths ...string) func(http.Handler) http.Handler
- func (c *Config) RegisterHandlers(mux *http.ServeMux)
- func (c *Config) RegistrationHandler(w http.ResponseWriter, r *http.Request)
- type UserSession
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
SessionManager *scs.SessionManager
OAuthConfig *oauth2.Config
Verifier *oidc.IDTokenVerifier
Provider *oidc.Provider
Database *sql.DB // Raw DB for transactions (auto-provisioning)
IdentityQ identity.Querier // Identity module queries
OrgQ organization.Querier // Organization module queries
}
Config holds all auth-related configuration
func Setup ¶
func Setup(database *sql.DB, identityQ identity.Querier, orgQ organization.Querier) (*Config, error)
Setup initializes the auth configuration
func (*Config) CallbackHandler ¶
func (c *Config) CallbackHandler(w http.ResponseWriter, r *http.Request)
CallbackHandler processes the OIDC callback
func (*Config) GetPersonID ¶
GetPersonID returns the person UUID of the authenticated user. Returns empty string if the user is not authenticated.
func (*Config) GetUserEmail ¶
GetUserEmail returns the email of the authenticated user.
func (*Config) GetUserName ¶
GetUserName returns the display name of the authenticated user.
func (*Config) GetUserSession ¶
func (c *Config) GetUserSession(ctx context.Context) *UserSession
GetUserSession retrieves the authenticated user's session data. Returns nil if the user is not authenticated.
func (*Config) GetUsername ¶
GetUsername returns the username of the authenticated user.
func (*Config) GetWorkspaceID ¶
GetWorkspaceID returns the active workspace UUID.
func (*Config) IsAuthenticated ¶
IsAuthenticated returns true if the user has an active session.
func (*Config) LoginHandler ¶
func (c *Config) LoginHandler(w http.ResponseWriter, r *http.Request)
LoginHandler initiates the OIDC authentication flow
func (*Config) LogoutCallbackHandler ¶
func (c *Config) LogoutCallbackHandler(w http.ResponseWriter, r *http.Request)
LogoutCallbackHandler handles the redirect after Keycloak logout
func (*Config) LogoutHandler ¶
func (c *Config) LogoutHandler(w http.ResponseWriter, r *http.Request)
LogoutHandler handles user logout
func (*Config) Middleware ¶
Middleware returns an auth middleware function. selfAuthenticatedPaths are integration-declared endpoints that verify their own caller (provider webhooks checking an HMAC signature) — they must bypass session auth or the provider's delivery bounces off the /login redirect. The server passes the paths collected from RouteMount.CSRFExemptPaths: a path that authenticates by signature is exempt from both protections for the same reason.
func (*Config) RegisterHandlers ¶
RegisterHandlers adds all auth-related handlers to the router
func (*Config) RegistrationHandler ¶
func (c *Config) RegistrationHandler(w http.ResponseWriter, r *http.Request)
RegistrationHandler redirects to the OIDC registration page