Documentation
¶
Index ¶
Constants ¶
const ( MetadataUserEmail = "x-aibrix-user-email" MetadataUserID = "x-aibrix-user-id" )
gRPC metadata keys used by the gateway to propagate the caller identity from the HTTP request context to gRPC handlers (which receive a fresh context across the gateway dial).
const IDTokenContextKey contextKey = "id_token"
IDTokenContextKey is the context key for storing the raw OIDC ID token associated with the current session, when available. Consumers (e.g. the SSO single-logout handler) can retrieve it via GetIDToken.
const UserContextKey contextKey = "user"
UserContextKey is the context key for storing UserInfo.
Variables ¶
This section is empty.
Functions ¶
func GetIDToken ¶
GetIDToken returns the raw OIDC ID token attached to the request context, or the empty string if there is none (basic / dev modes, or no session).
Types ¶
type AuthConfig ¶
type AuthConfig struct {
Mode string // "dev", "oidc", "basic"
OIDCIssuerURL string
OIDCClientID string
OIDCClientSecret string
OIDCRedirectURL string
OIDCPostLogoutRedirectURL string
OIDCEndSessionURL string
OIDCGroupsClaim string
OIDCAdminGroups string
OIDCAdminEmails string
OIDCSigningAlg string
SessionSecret string
DevUserName string
DevUserEmail string
BasicUsername string
BasicPassword string
}
AuthConfig holds authentication configuration.
type AuthMiddleware ¶
type AuthMiddleware struct {
// contains filtered or unexported fields
}
AuthMiddleware provides authentication for HTTP handlers.
func NewAuthMiddleware ¶
func NewAuthMiddleware(cfg AuthConfig) (*AuthMiddleware, error)
NewAuthMiddleware creates a new AuthMiddleware with the given configuration. SessionSecret must be non-empty; callers should obtain it from config.Load, which enforces a strong secret in non-dev modes. In OIDC mode, this performs provider discovery against OIDCIssuerURL and returns an error if discovery fails.
func (*AuthMiddleware) Handler ¶
func (a *AuthMiddleware) Handler(next http.Handler) http.Handler
Handler wraps an http.Handler with authentication.
func (*AuthMiddleware) RegisterAuthRoutes ¶
func (a *AuthMiddleware) RegisterAuthRoutes(mux *runtime.ServeMux)
RegisterAuthRoutes registers authentication endpoints on the grpc-gateway mux.
Routes registered:
GET /api/v1/auth/config -> returns auth mode info (public) GET /api/v1/auth/login -> redirect to OIDC provider (oidc mode) POST /api/v1/auth/login -> basic auth login (basic mode) GET /api/v1/auth/callback -> OIDC callback handler (oidc mode) GET /api/v1/auth/userinfo -> current user info (all modes) POST /api/v1/auth/logout -> clear session (all modes)