Documentation
¶
Overview ¶
Package auth owns the console's platform-authentication client contract.
Package auth owns the UI's platform authentication client and principal contract. Callers inject the HTTP client; session storage and browser-facing handlers remain separate from upstream credential verification.
Index ¶
- func FirstAPIKey(apiKeys string) string
- func ParseAPIKeyList(s string) []string
- type AttemptConfig
- type AttemptTracker
- type Client
- func (c Client) OIDC(ctx context.Context, apiUpstream, idToken string) (Principal, string, time.Time, error)
- func (c Client) Password(ctx context.Context, apiUpstream, email, password string) (Principal, string, time.Time, error)
- func (c Client) Session(ctx context.Context, apiUpstream, idToken string) (Principal, string, time.Time, error)
- func (c Client) VerifyOIDC(ctx context.Context, apiUpstream, idToken string) (Principal, error)
- type Hooks
- type Principal
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FirstAPIKey ¶
func ParseAPIKeyList ¶
parseAPIKeyList splits a comma-separated API-key list into a slice of trimmed, non-empty entries, suitable for use as a per-process lookup.
Types ¶
type AttemptConfig ¶
type AttemptConfig struct {
Capacity int
Refill time.Duration
FailureWindow time.Duration
FailureThreshold int
LockoutDuration time.Duration
}
AttemptConfig is resolved by bootstrap and shared by one login limiter.
func DefaultAttemptConfig ¶
func DefaultAttemptConfig() AttemptConfig
type AttemptTracker ¶
type AttemptTracker struct {
// contains filtered or unexported fields
}
func NewAttemptTracker ¶
func NewAttemptTracker(now func() time.Time, config AttemptConfig) *AttemptTracker
func (*AttemptTracker) Allow ¶
func (t *AttemptTracker) Allow(clientID string) bool
func (*AttemptTracker) RecordFailure ¶
func (t *AttemptTracker) RecordFailure(clientID string) int
func (*AttemptTracker) RecordSuccess ¶
func (t *AttemptTracker) RecordSuccess(clientID string) int
type Client ¶
Client uses the transport selected by the console bootstrap. All calls retain their bounded contexts and platform authentication/expiry semantics.
type Hooks ¶
type Hooks struct {
Password func(context.Context, string, string, string) (Principal, string, time.Time, error)
OIDC func(context.Context, string, string) (Principal, string, time.Time, error)
}
Hooks override credential verification for injected integrations; normal requests use Client. They never replace store issuance or login throttling.
type Server ¶
type Server struct {
Store *session.Store
Client Client
Attempts *AttemptTracker
Hooks *Hooks
ForceSecureCookie bool
PublicRoutes topology.Routes
}
Server owns browser authentication, throttling and session-cookie responses. Bootstrap provides its store, upstream client, limiter and cookie policy.
func (*Server) AdminCheck ¶
func (s *Server) AdminCheck(apiKeys, adminAPIKeys []string, legacyAdminKeys bool) http.HandlerFunc
AdminCheck is the Traefik forwardAuth target for Grafana. Admin sessions and keys pass; denied browser page navigations go through platform sign-in. API requests retain their JSON 401 response. Cache-Control is set by the security headers middleware for /auth/.
func (*Server) Login ¶
func (s *Server) Login(apiKey, upstreamAPIKey, apiUpstream string) http.HandlerFunc
func (*Server) Logout ¶
func (s *Server) Logout() http.HandlerFunc
func (*Server) Status ¶
func (s *Server) Status() http.HandlerFunc