Documentation
¶
Index ¶
- Constants
- type AccessDecisionManager
- type AccessDeniedHandler
- type Actor
- type ActorAware
- type ActorData
- type ActorImpersonating
- type Authenticator
- type Claims
- type DecisionStrategy
- type EntryPoint
- type Firewall
- type FirewallManager
- type ImpersonatedUserResolver
- type Impersonating
- type LoginHandler
- type LoginInput
- type LoginResult
- type LogoutHandler
- type LogoutInput
- type LogoutResult
- type Matcher
- type NonceGuard
- type RevocableTokenStore
- type Rule
- type Token
- type TokenEnricher
- type TokenResolver
- type TokenSource
- type TokenStore
- type TokenValidator
- type TwoFactorEnrollmentStore
- type TwoFactorPending
- type TwoFactorRecoveryStore
- type VoteResult
- type Voter
Constants ¶
const ( ActorTypeUser = "user" ActorTypeApiClient = "api-client" ActorTypeSystem = "system" )
const ( ServiceSecurityContext = "service.security.context" EventSecurityAuthorizationGranted = "security.authorization.granted" EventSecurityAuthorizationDenied = "security.authorization.denied" EventSecurityLoginSuccess = "security.login.success" EventSecurityLoginFailure = "security.login.failure" EventSecurityLogoutSuccess = "security.logout.success" EventSecurityLogoutFailure = "security.logout.failure" AttributePublicAccess = "PUBLIC_ACCESS" RoleAllowedToSwitch = "ROLE_ALLOWED_TO_SWITCH" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccessDecisionManager ¶
type AccessDeniedHandler ¶
type AccessDeniedHandler interface {
Handle(runtimeInstance runtimecontract.Runtime, request httpcontract.Request, decisionErr error) (httpcontract.Response, error)
}
type Actor ¶ added in v3.9.0
type Actor interface {
Identifier() string
/* Type reports the kind of originating actor; one of ActorTypeUser, ActorTypeApiClient or ActorTypeSystem. */
Type() string
Roles() []string
Attributes() map[string]string
}
Actor is the originating principal that started an action upstream (for example the human user or client that called service A), distinct from the authenticated transport principal that is carrying the request now (service B). It is optional context attached to a Token through the ActorAware interface; an absent actor means the token behaves exactly as before.
type ActorAware ¶ added in v3.9.0
ActorAware is implemented by tokens that can carry an originating actor. Consumers (voters, audit) type-assert a Token to ActorAware rather than the core Token interface being widened, so existing Token implementations keep compiling.
type ActorData ¶ added in v3.9.0
type ActorData struct {
Identifier string `json:"Identifier"`
Type string `json:"Type"`
Roles []string `json:"Roles,omitempty"`
Attributes map[string]string `json:"Attributes,omitempty"`
Impersonator *ActorData `json:"Impersonator,omitempty"`
}
ActorData is the serializable carrier for an originating actor inside Claims. The Actor interface itself does not round-trip through JSON, so transports (JWT claims, the HMAC envelope) encode this struct and it is rebuilt into a concrete Actor when a token is constructed. Impersonator, when set, is the admin acting behind this actor, so an impersonation's accountable principal and its roles propagate across services.
type ActorImpersonating ¶ added in v3.9.0
ActorImpersonating is implemented by an Actor an impersonator is acting behind. Consumers type-assert it (rather than widening Actor) to read the accountable impersonator a propagated originating actor carries, so an impersonation started in one service stays auditable in the next.
type Authenticator ¶
type Authenticator interface {
Supports(request httpcontract.Request) bool
Authenticate(request httpcontract.Request) (Token, error)
}
type DecisionStrategy ¶
type DecisionStrategy int
const ( DecisionStrategyAffirmative DecisionStrategy = iota DecisionStrategyConsensus DecisionStrategyUnanimous )
type EntryPoint ¶
type EntryPoint interface {
Start(runtimeInstance runtimecontract.Runtime, request httpcontract.Request) (httpcontract.Response, error)
}
type Firewall ¶
type Firewall interface {
Name() string
LoginPath() string
LogoutPath() string
Login(
runtimeInstance runtimecontract.Runtime,
request httpcontract.Request,
input LoginInput,
) (*LoginResult, error)
Logout(
runtimeInstance runtimecontract.Runtime,
request httpcontract.Request,
input LogoutInput,
) (*LogoutResult, error)
}
type FirewallManager ¶
type ImpersonatedUserResolver ¶ added in v3.9.0
type ImpersonatedUserResolver interface {
ResolveImpersonatedUser(runtimeInstance runtimecontract.Runtime, identifier string) (Token, error)
}
ImpersonatedUserResolver resolves the token of the user an admin is switching to. It is supplied by the application because only the application knows its user store. Returning a nil or unauthenticated token (or an error) denies the switch, and the admin's own token is used unchanged.
type Impersonating ¶ added in v3.9.0
Impersonating is implemented by a token whose visible principal is an impersonated user while a different principal (the admin who initiated the switch) is actually authenticated. Consumers type-assert it to read who is acting behind the impersonated identity, so both identities can be audited. As with ActorAware, the core Token interface is not widened.
type LoginHandler ¶
type LoginHandler interface {
Login(runtimeInstance runtimecontract.Runtime, request httpcontract.Request, input LoginInput) (*LoginResult, error)
}
type LoginInput ¶
type LoginInput struct {
Token Token
}
type LoginResult ¶
type LoginResult struct {
Token Token
Response httpcontract.Response
}
type LogoutHandler ¶
type LogoutHandler interface {
Logout(runtimeInstance runtimecontract.Runtime, request httpcontract.Request, input LogoutInput) (*LogoutResult, error)
}
type LogoutInput ¶
type LogoutInput struct{}
type LogoutResult ¶
type LogoutResult struct {
Response httpcontract.Response
}
type Matcher ¶
type Matcher interface {
Matches(request httpcontract.Request) bool
}
type NonceGuard ¶ added in v3.9.0
type NonceGuard interface {
Remember(runtimeInstance runtimecontract.Runtime, nonce string, ttl time.Duration) (bool, error)
}
NonceGuard provides replay protection for single-use values (the nonce carried by the internal-auth envelope). Remember atomically records a nonce for the given time-to-live and reports whether it had already been recorded and not yet expired; a true result means the nonce is a replay and the request must be rejected. Implementations are expected to be safe for concurrent use and, in a multi-instance deployment, to share state (for example through Redis).
type RevocableTokenStore ¶ added in v3.7.0
type Rule ¶
type Rule interface {
Applies(request httpcontract.Request) bool
Check(request httpcontract.Request) error
}
type TokenEnricher ¶ added in v3.7.0
type TokenEnricher interface {
Enrich(runtimeInstance runtimecontract.Runtime, claims Claims) (Claims, error)
}
type TokenResolver ¶
type TokenResolver func(request httpcontract.Request) Token
type TokenSource ¶
type TokenSource interface {
Name() string
Resolve(runtimeInstance runtimecontract.Runtime, request httpcontract.Request) (Token, error)
}
type TokenStore ¶ added in v3.7.0
type TokenValidator ¶ added in v3.7.0
type TokenValidator interface {
Validate(runtimeInstance runtimecontract.Runtime, tokenString string) (Claims, error)
}
type TwoFactorEnrollmentStore ¶ added in v3.9.0
type TwoFactorEnrollmentStore interface {
FindTotpSecret(runtimeInstance runtimecontract.Runtime, userIdentifier string) (secret string, enrolled bool, err error)
}
TwoFactorEnrollmentStore reports whether a user has a second factor configured and, if so, returns the TOTP secret to verify against. It is supplied by the application because only the application knows where enrollments live (typically an encrypted column). Returning enrolled=false means the user has no second factor and primary authentication stands on its own.
type TwoFactorPending ¶ added in v3.9.0
type TwoFactorPending interface {
PendingUserIdentifier() string
}
TwoFactorPending is implemented by the token returned when a primary credential has been accepted but a required second factor (a TOTP code) has not yet been supplied or did not verify. The token is deliberately not authenticated; the application inspects this interface to know it should prompt for a code rather than treating the request as anonymous.
type TwoFactorRecoveryStore ¶ added in v3.9.0
type TwoFactorRecoveryStore interface {
RedeemRecoveryCode(runtimeInstance runtimecontract.Runtime, userIdentifier string, code string) (redeemed bool, err error)
}
TwoFactorRecoveryStore is an optional companion to TwoFactorEnrollmentStore: when the enrollment store also implements it, TotpSecondFactorAuthenticator accepts a single-use recovery code (on its recovery header) as an alternative to a TOTP code. RedeemRecoveryCode must atomically verify the code is one of the user's currently-unused recovery codes and consume it — remove it so a second presentation of the same code cannot succeed — returning redeemed=true only when a previously-unused code was consumed. A store that does not implement this interface simply makes recovery codes unavailable; TOTP verification is unaffected. The atomic check-and-consume (a transaction or a conditional update) is the store's responsibility, mirroring how FindTotpSecret owns enrollment storage.
type VoteResult ¶
type VoteResult int
const ( VoteAbstain VoteResult = iota VoteDenied VoteGranted )
Source Files
¶
- access_decision_manager.go
- access_denied_handler.go
- actor.go
- authenticator.go
- const.go
- decision.go
- entry_point.go
- firewall.go
- firewall_manager.go
- impersonation.go
- login.go
- login_handler.go
- logout.go
- logout_handler.go
- matcher.go
- nonce_guard.go
- rule.go
- token.go
- token_enricher.go
- token_source.go
- token_store.go
- token_validator.go
- two_factor.go
- voter.go