Documentation ¶
Overview ¶
Package lico is a Go implementation of an OpenID Connect server with flexibale authorization and authentication backends and consent screen.
See README.md for more info.
Index ¶
- Constants
- func FromClaimsContext(ctx context.Context) (jwt.Claims, bool)
- func FromRequestContext(ctx context.Context) (*http.Request, bool)
- func NewClaimsContext(ctx context.Context, claims jwt.Claims) context.Context
- func NewRequestContext(ctx context.Context, req *http.Request) context.Context
- type AccessTokenClaims
- type AccessTokenProvider
- type NumericIDClaims
- type RefreshTokenClaims
- type TokenTypeValue
- type UniqueUserIDClaims
- type UserInfoResponse
Constants ¶
const ( RefClaim = "lg.r" IdentityClaim = "lg.i" IdentityProviderClaim = "lg.p" ScopesClaim = "scp" )
Access token claims used.
const ( IdentifiedUserClaim = "us" IdentifiedUserIDClaim = "id" IdentifiedUsernameClaim = "un" IdentifiedDisplayNameClaim = "dn" IdentifiedData = "da" IdentifiedUserIsGuest = "gu" )
Identifier identity sub claims used.
const ( InternalExtraIDTokenClaimsClaim = "$lico.id.extra" InternalExtraAccessTokenClaimsClaim = "$lico.at.extra" )
Internal claim names used for special things.
const ( // ScopeNumericID is the string value for the built-in Numeric ID scope. ScopeNumericID = "LibgreGraph.NumericID" // ScopeUniqueUserID is the string value for the built-in Unique User ID scope. ScopeUniqueUserID = "LibgreGraph.UUID" // ScopeRawSubject is the string value for the built-in Raw Subject scope. ScopeRawSubject = "LibreGraph.RawSub" // ScopeGuestOK is the string value for the built-in Guest OK scope. ScopeGuestOK = "LibreGraph.GuestOK" )
Variables ¶
This section is empty.
Functions ¶
func FromClaimsContext ¶
FromClaimsContext returns the AuthRecord value stored in ctx, if any.
func FromRequestContext ¶ added in v0.64.0
FromRequestContext returns the Request object stored in ctx, if any.
func NewClaimsContext ¶
NewClaimsContext returns a new Context that carries value auth.
Types ¶
type AccessTokenClaims ¶
type AccessTokenClaims struct { jwt.StandardClaims TokenType TokenTypeValue `json:"lg.t"` AuthorizedClaimsRequest *payload.ClaimsRequest `json:"lg.acr,omitempty"` AuthorizedScopesList payload.ScopesValue `json:"scp"` IdentityClaims jwt.MapClaims `json:"lg.i"` IdentityProvider string `json:"lg.p,omitempty"` *oidc.SessionClaims }
AccessTokenClaims define the claims found in access tokens issued.
func (AccessTokenClaims) AuthorizedScopes ¶
func (c AccessTokenClaims) AuthorizedScopes() map[string]bool
AuthorizedScopes returns a map with scope keys and true value of all scopes set in the accociated access token.
func (AccessTokenClaims) Valid ¶
func (c AccessTokenClaims) Valid() error
Valid implements the jwt.Claims interface.
type AccessTokenProvider ¶
type AccessTokenProvider interface {
MakeAccessToken(ctx context.Context, audience string, auth identity.AuthRecord) (string, error)
}
AccessTokenProvider is an interface for something which can create access tokens.
type NumericIDClaims ¶ added in v0.52.0
type NumericIDClaims struct { // NOTE(longsleep): Always keep these claims compatible with the GitLab API // https://docs.gitlab.com/ce/api/users.html#for-user. NumericID int64 `json:"id,omitempty"` NumericIDUsername string `json:"username,omitempty"` }
NumericIDClaims define the claims used with the konnect/id scope.
func (NumericIDClaims) Valid ¶ added in v0.52.0
func (c NumericIDClaims) Valid() error
Valid implements the jwt.Claims interface.
type RefreshTokenClaims ¶
type RefreshTokenClaims struct { jwt.StandardClaims TokenType TokenTypeValue `json:"lg.t"` ApprovedScopesList payload.ScopesValue `json:"scp"` ApprovedClaimsRequest *payload.ClaimsRequest `json:"lg.acr,omitempty"` Ref string `json:"lg.r"` IdentityClaims jwt.MapClaims `json:"lg.i"` IdentityProvider string `json:"lg.p,omitempty"` }
RefreshTokenClaims define the claims used by refresh tokens.
func (RefreshTokenClaims) Valid ¶
func (c RefreshTokenClaims) Valid() error
Valid implements the jwt.Claims interface.
type TokenTypeValue ¶ added in v0.52.0
type TokenTypeValue string
TokenType defines the token type value.
const ( TokenTypeIDToken TokenTypeValue = "" // Just a placeholder, not actually set in ID Tokens. TokenTypeAccessToken TokenTypeValue = "1" TokenTypeRefreshToken TokenTypeValue = "2" )
The known token type values.
func (TokenTypeValue) Is ¶ added in v0.52.0
func (ttv TokenTypeValue) Is(value TokenTypeValue) bool
Is compares the associated TokenTypeValue to the provided one.
type UniqueUserIDClaims ¶
type UniqueUserIDClaims struct {
UniqueUserID string `json:"lg.uuid,omitempty"`
}
UniqueUserIDClaims define the claims used with the konnect/uuid scope.
func (UniqueUserIDClaims) Valid ¶
func (c UniqueUserIDClaims) Valid() error
Valid implements the jwt.Claims interface.
type UserInfoResponse ¶
type UserInfoResponse struct { *payload.UserInfoResponse *NumericIDClaims *UniqueUserIDClaims }
UserInfoResponse defines the data returned from the Konnect UserInfo endpoint. It is the standard ODIC response, extended with additional claims.