Documentation ¶
Index ¶
- Constants
- type Config
- type Consent
- type ConsentRequest
- type HelloRequest
- type HelloResponse
- type IdentifiedUser
- func (u *IdentifiedUser) Claims() jwt.MapClaims
- func (u *IdentifiedUser) Email() string
- func (u *IdentifiedUser) EmailVerified() bool
- func (u *IdentifiedUser) FamilyName() string
- func (u *IdentifiedUser) GivenName() string
- func (u *IdentifiedUser) ID() int64
- func (u *IdentifiedUser) LoggedOn() (bool, time.Time)
- func (u *IdentifiedUser) Name() string
- func (u *IdentifiedUser) ScopedClaims(authorizedScopes map[string]bool) jwt.MapClaims
- func (u *IdentifiedUser) Subject() string
- func (u *IdentifiedUser) UniqueID() string
- func (u *IdentifiedUser) Username() string
- type Identifier
- func (i *Identifier) AddRoutes(ctx context.Context, router *mux.Router)
- func (i *Identifier) ErrorPage(rw http.ResponseWriter, code int, title string, message string)
- func (i *Identifier) GetConsentFromConsentCookie(ctx context.Context, rw http.ResponseWriter, req *http.Request) (*Consent, error)
- func (i *Identifier) GetUserFromLogonCookie(ctx context.Context, req *http.Request, maxAge time.Duration) (*IdentifiedUser, error)
- func (i *Identifier) GetUserFromSubject(ctx context.Context, sub string) (*IdentifiedUser, error)
- func (i *Identifier) ScopesSupported() []string
- func (i *Identifier) ServeHTTP(rw http.ResponseWriter, req *http.Request)
- func (i *Identifier) SetConsentToConsentCookie(ctx context.Context, rw http.ResponseWriter, cr *ConsentRequest, ...) error
- func (i *Identifier) SetKey(key []byte) error
- func (i *Identifier) SetUserToLogonCookie(ctx context.Context, rw http.ResponseWriter, user *IdentifiedUser) error
- func (i *Identifier) UnsetLogonCookie(ctx context.Context, rw http.ResponseWriter) error
- type LogonRequest
- type LogonResponse
- type StateRequest
- type StateResponse
Constants ¶
const ( // FlowOIDC is the string value for the oidc flow. FlowOIDC = "oidc" // FlowOAuth is the string value for the oauth flow. FlowOAuth = "oauth" // FlowConsent is the string value for the consent flow. FlowConsent = "consent" )
const ( // ModeLogonUsernameEmptyPasswordCookie is the logon mode which requires a // username which matches the currently signed in user in the cookie and an // empty password. ModeLogonUsernameEmptyPasswordCookie = "0" // ModeLogonUsernamePassword is the logon mode which requires a username // and a password. ModeLogonUsernamePassword = "1" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Config *config.Config PathPrefix string StaticFolder string LogonCookieName string AuthorizationEndpointURI *url.URL Backend backends.Backend Clients *clients.Registry }
Config defines a Server's configuration settings.
type Consent ¶ added in v0.2.0
Consent is the data received and sent to allow or cancel consent flows.
type ConsentRequest ¶ added in v0.2.0
type ConsentRequest struct { State string `json:"state"` Allow bool `json:"allow"` RawScope string `json:"scope"` ClientID string `json:"client_id"` RawRedirectURI string `json:"redirect_uri"` Ref string `json:"ref"` Nonce string `json:"flow_nonce"` }
A ConsentRequest is the request data as sent to the consent endpoint.
type HelloRequest ¶
type HelloRequest struct { State string `json:"state"` Flow string `json:"flow"` RawScope string `json:"scope"` RawPrompt string `json:"prompt"` ClientID string `json:"client_id"` RawRedirectURI string `json:"redirect_uri"` RawIDTokenHint string `json:"id_token_hint"` RawMaxAge string `json:"max_age"` Scopes map[string]bool `json:"-"` Prompts map[string]bool `json:"-"` RedirectURI *url.URL `json:"-"` IDTokenHint *jwt.Token `json:"-"` MaxAge time.Duration `json:"-"` }
A HelloRequest is the request data as send to the hello endpoint.
type HelloResponse ¶
type HelloResponse struct { State string `json:"state"` Flow string `json:"flow"` Success bool `json:"success"` Username string `json:"username,omitempty"` DisplayName string `json:"displayName,omitempty"` Next string `json:"next,omitempty"` ContinueURI string `json:"continue_uri,omitempty"` RequestedScopes map[string]bool `json:"scopes,omitempty"` ClientDetails *clients.Details `json:"client,omitempty"` }
A HelloResponse holds a response as sent by the hello endpoint.
type IdentifiedUser ¶
type IdentifiedUser struct {
// contains filtered or unexported fields
}
A IdentifiedUser is a user with meta data.
func (*IdentifiedUser) Claims ¶
func (u *IdentifiedUser) Claims() jwt.MapClaims
Claims returns extra claims of the accociated user.
func (*IdentifiedUser) Email ¶
func (u *IdentifiedUser) Email() string
Email returns the associated users email field.
func (*IdentifiedUser) EmailVerified ¶
func (u *IdentifiedUser) EmailVerified() bool
EmailVerified returns trye if the associated users email field was verified.
func (*IdentifiedUser) FamilyName ¶ added in v0.4.0
func (u *IdentifiedUser) FamilyName() string
FamilyName returns the associated users family name field.
func (*IdentifiedUser) GivenName ¶ added in v0.4.0
func (u *IdentifiedUser) GivenName() string
GivenName returns the associated users given name field.
func (*IdentifiedUser) ID ¶
func (u *IdentifiedUser) ID() int64
ID returns the associated users numeric user id. If it is 0, it means that this user does not have a numeric ID. Do not use this field to identify a user - always use the subject instead. The numeric ID is kept for compatibilty with systems which require user identification to be numeric.
func (*IdentifiedUser) LoggedOn ¶ added in v0.3.0
func (u *IdentifiedUser) LoggedOn() (bool, time.Time)
LoggedOn returns true if the accociated user has a logonAt time set.
func (*IdentifiedUser) Name ¶
func (u *IdentifiedUser) Name() string
Name returns the associated users name field. This is the display name of the accociated user.
func (*IdentifiedUser) ScopedClaims ¶ added in v0.9.0
func (u *IdentifiedUser) ScopedClaims(authorizedScopes map[string]bool) jwt.MapClaims
ScopedClaims returns scope bound extra claims of the accociated user.
func (*IdentifiedUser) Subject ¶
func (u *IdentifiedUser) Subject() string
Subject returns the associated users subject field. The subject is the main authentication identifier of the user.
func (*IdentifiedUser) UniqueID ¶ added in v0.4.0
func (u *IdentifiedUser) UniqueID() string
UniqueID returns the accociated users unique user id. When empty, then this user does not have a unique ID. This field can be used for unique user mapping to external systems which use the same authentication source as Konnect. The value depends entirely on the identifier backend.
func (*IdentifiedUser) Username ¶
func (u *IdentifiedUser) Username() string
Username returns the accociated users username. This might be different or the same as the subject, depending on the backend in use. If can also be empty, which means that the accociated user does not have a username.
type Identifier ¶
type Identifier struct { Config *Config // contains filtered or unexported fields }
Identifier defines a identification login area with its endpoints using a Kopano Core server as backend logon provider.
func NewIdentifier ¶
func NewIdentifier(c *Config) (*Identifier, error)
NewIdentifier returns a new Identifier.
func (*Identifier) AddRoutes ¶
func (i *Identifier) AddRoutes(ctx context.Context, router *mux.Router)
AddRoutes adds the endpoint routes of the accociated Identifier to the provided router with the provided context.
func (*Identifier) ErrorPage ¶
func (i *Identifier) ErrorPage(rw http.ResponseWriter, code int, title string, message string)
ErrorPage writes a HTML error page to the provided ResponseWriter.
func (*Identifier) GetConsentFromConsentCookie ¶ added in v0.2.0
func (i *Identifier) GetConsentFromConsentCookie(ctx context.Context, rw http.ResponseWriter, req *http.Request) (*Consent, error)
GetConsentFromConsentCookie extract consent information for the provided request.
func (*Identifier) GetUserFromLogonCookie ¶
func (i *Identifier) GetUserFromLogonCookie(ctx context.Context, req *http.Request, maxAge time.Duration) (*IdentifiedUser, error)
GetUserFromLogonCookie looks up the associated cookie name from the provided request, parses it and returns the user containing the information found in the coookie payload data.
func (*Identifier) GetUserFromSubject ¶
func (i *Identifier) GetUserFromSubject(ctx context.Context, sub string) (*IdentifiedUser, error)
GetUserFromSubject looks up the user identified by the provided subject by requesting the associated backend.
func (*Identifier) ScopesSupported ¶ added in v0.7.0
func (i *Identifier) ScopesSupported() []string
ScopesSupported return the scopes supported by the accociaged Identifier.
func (*Identifier) ServeHTTP ¶
func (i *Identifier) ServeHTTP(rw http.ResponseWriter, req *http.Request)
ServeHTTP implements the http.Handler interface.
func (*Identifier) SetConsentToConsentCookie ¶ added in v0.3.0
func (i *Identifier) SetConsentToConsentCookie(ctx context.Context, rw http.ResponseWriter, cr *ConsentRequest, consent *Consent) error
SetConsentToConsentCookie serializses the provided Consent using the provided ConsentRequest and sets it as cookie on the provided ReponseWriter.
func (*Identifier) SetKey ¶
func (i *Identifier) SetKey(key []byte) error
SetKey sets the provided key for the accociated identifier.
func (*Identifier) SetUserToLogonCookie ¶ added in v0.3.0
func (i *Identifier) SetUserToLogonCookie(ctx context.Context, rw http.ResponseWriter, user *IdentifiedUser) error
SetUserToLogonCookie serializes the provided user into an encrypted string and sets it as cookie on the provided http.ResponseWriter.
func (*Identifier) UnsetLogonCookie ¶ added in v0.6.0
func (i *Identifier) UnsetLogonCookie(ctx context.Context, rw http.ResponseWriter) error
UnsetLogonCookie adds cookie remove headers to the provided http.ResponseWriter effectively implementing logout.
type LogonRequest ¶
type LogonRequest struct { State string `json:"state"` Params []string `json:"params"` Hello *HelloRequest `json:"hello"` }
A LogonRequest is the request data as sent to the logon endpoint
type LogonResponse ¶
type LogonResponse struct { Success bool `json:"success"` State string `json:"state"` Hello *HelloResponse `json:"hello"` }
A LogonResponse holds a response as sent by the logon endpoint.
type StateRequest ¶
type StateRequest struct {
State string
}
A StateRequest is a general request with a state.
type StateResponse ¶
A StateResponse hilds a response as reply to a StateRequest.