Documentation
¶
Overview ¶
Package session provides session handlers for various authentication implementations. Curretnly supported are: 1) Azure OIDC Authorization Code Flow with PKCE 2) Preauth: Allows you to implement your own authentication, but still use session handlers 3) Username/Password: Implements user storage and password management
Index ¶
- type BaseSessionOption
- type CookieOption
- type DisabledUserRoleManager
- func (d DisabledUserRoleManager) AddUserRoles(_ context.Context, _ accesstypes.Domain, _ accesstypes.User, ...) error
- func (d DisabledUserRoleManager) DeleteUserRoles(_ context.Context, _ accesstypes.Domain, _ accesstypes.User, ...) error
- func (d DisabledUserRoleManager) Domains(_ context.Context) ([]accesstypes.Domain, error)
- func (d DisabledUserRoleManager) RoleExists(_ context.Context, _ accesstypes.Domain, _ accesstypes.Role) bool
- func (d DisabledUserRoleManager) UserRoles(_ context.Context, _ accesstypes.User, _ ...accesstypes.Domain) (accesstypes.RoleCollection, error)
- type LogHandler
- type OIDCAzure
- type OIDCAzureHandlers
- type OIDCAzureOption
- type OIDCOption
- type Preauth
- type PreauthHandlers
- type PreauthOption
- type UserRoleManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseSessionOption ¶ added in v0.6.0
type BaseSessionOption func(*basesession.BaseSession)
BaseSessionOption defines a function signature for setting session options.
func WithLogHandler ¶ added in v0.6.0
func WithLogHandler(l LogHandler) BaseSessionOption
WithLogHandler sets the LogHandler. (default: httpio.Log)
func WithSessionTimeout ¶ added in v0.6.0
func WithSessionTimeout(d time.Duration) BaseSessionOption
WithSessionTimeout sets the session timeout. (default: 10m)
type CookieOption ¶ added in v0.5.8
type CookieOption func(*cookie.CookieClient)
CookieOption defines a function signature for setting cookie client options.
func WithCookieDomain ¶ added in v0.5.8
func WithCookieDomain(domain string) CookieOption
WithCookieDomain sets the domain for the session cookie.
func WithCookieName ¶ added in v0.5.8
func WithCookieName(name string) CookieOption
WithCookieName sets the cookie name for the session cookie.
type DisabledUserRoleManager ¶ added in v0.6.0
type DisabledUserRoleManager struct{}
DisabledUserRoleManager implements the UserManager interface but disables all user management functions.
func DisableUserRoleManagement ¶ added in v0.6.0
func DisableUserRoleManagement() DisabledUserRoleManager
DisableUserRoleManagement returns a DisabledUserRoleManager instance.
func (DisabledUserRoleManager) AddUserRoles ¶ added in v0.6.0
func (d DisabledUserRoleManager) AddUserRoles(_ context.Context, _ accesstypes.Domain, _ accesstypes.User, _ ...accesstypes.Role) error
AddUserRoles does nothing and returns nil.
func (DisabledUserRoleManager) DeleteUserRoles ¶ added in v0.6.0
func (d DisabledUserRoleManager) DeleteUserRoles(_ context.Context, _ accesstypes.Domain, _ accesstypes.User, _ ...accesstypes.Role) error
DeleteUserRoles does nothing and returns nil.
func (DisabledUserRoleManager) Domains ¶ added in v0.6.0
func (d DisabledUserRoleManager) Domains(_ context.Context) ([]accesstypes.Domain, error)
Domains returns a default global domain.
func (DisabledUserRoleManager) RoleExists ¶ added in v0.6.0
func (d DisabledUserRoleManager) RoleExists(_ context.Context, _ accesstypes.Domain, _ accesstypes.Role) bool
RoleExists always returns true, indicating that any role exists.
func (DisabledUserRoleManager) UserRoles ¶ added in v0.6.0
func (d DisabledUserRoleManager) UserRoles(_ context.Context, _ accesstypes.User, _ ...accesstypes.Domain) (accesstypes.RoleCollection, error)
UserRoles always returns an empty RoleCollection.
type LogHandler ¶
type LogHandler = basesession.LogHandler
LogHandler defines the handler signature required for handling logs.
type OIDCAzure ¶ added in v0.6.0
type OIDCAzure struct {
*basesession.BaseSession
// contains filtered or unexported fields
}
OIDCAzure implements the OIDCAzureHandlers interface for handling OIDC authentication with Azure.
func NewOIDCAzure ¶
func NewOIDCAzure( storage sessionstorage.OIDCAzure, userRoleManager UserRoleManager, secureCookie *securecookie.SecureCookie, issuerURL, clientID, clientSecret, redirectURL string, options ...OIDCAzureOption, ) *OIDCAzure
NewOIDCAzure creates a new OIDCAzure.
func (*OIDCAzure) CallbackOIDC ¶ added in v0.6.0
func (o *OIDCAzure) CallbackOIDC() http.HandlerFunc
CallbackOIDC is the handler for the callback from the OIDC auth provider
func (*OIDCAzure) FrontChannelLogout ¶ added in v0.6.0
func (o *OIDCAzure) FrontChannelLogout() http.HandlerFunc
FrontChannelLogout is a handler which destroys the current session for a logout request initiated by the OIDC provider
func (*OIDCAzure) Login ¶ added in v0.6.0
func (o *OIDCAzure) Login() http.HandlerFunc
Login initiates the OIDC login flow by redirecting the user to the authorization URL.
type OIDCAzureHandlers ¶
type OIDCAzureHandlers interface {
CallbackOIDC() http.HandlerFunc
FrontChannelLogout() http.HandlerFunc
Login() http.HandlerFunc
basesession.Handlers
}
OIDCAzureHandlers defines the interface for OIDC Azure session handlers.
type OIDCAzureOption ¶ added in v0.5.8
type OIDCAzureOption interface {
// contains filtered or unexported methods
}
OIDCAzureOption defines the interface for functional options used when creating a new OIDCAzure.
type OIDCOption ¶ added in v0.6.0
OIDCOption defines a function signature for setting OIDC options.
func WithLoginURL ¶ added in v0.6.0
func WithLoginURL(l string) OIDCOption
WithLoginURL sets the LoginURL for the SPA. (default: /login)
type Preauth ¶ added in v0.6.0
type Preauth struct {
*basesession.BaseSession
// contains filtered or unexported fields
}
Preauth handles session management for pre-authentication scenarios.
func NewPreauth ¶ added in v0.4.0
func NewPreauth(storage sessionstorage.Preauth, secureCookie *securecookie.SecureCookie, options ...PreauthOption) *Preauth
NewPreauth creates a new PreauthSession instance.
type PreauthHandlers ¶ added in v0.6.0
type PreauthHandlers interface {
basesession.Handlers
NewSession(ctx context.Context, w http.ResponseWriter, r *http.Request, username string) (ccc.UUID, error)
}
PreauthHandlers defines the interface for pre-authentication session handlers.
type PreauthOption ¶ added in v0.6.0
type PreauthOption interface {
// contains filtered or unexported methods
}
PreauthOption defines the functional option type for configuring PreauthSession.
type UserRoleManager ¶ added in v0.6.0
type UserRoleManager interface {
Domains(ctx context.Context) ([]accesstypes.Domain, error)
UserRoles(ctx context.Context, user accesstypes.User, domains ...accesstypes.Domain) (accesstypes.RoleCollection, error)
RoleExists(ctx context.Context, domain accesstypes.Domain, role accesstypes.Role) bool
AddUserRoles(ctx context.Context, domain accesstypes.Domain, user accesstypes.User, roles ...accesstypes.Role) error
DeleteUserRoles(ctx context.Context, domain accesstypes.Domain, user accesstypes.User, roles ...accesstypes.Role) error
}
UserRoleManager defines an interface for managing user roles.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
azureoidc
Package azureoidc implements a client for Azure OIDC Authorization Code Flow with PKCE (Proof Key for Code Exchange).
|
Package azureoidc implements a client for Azure OIDC Authorization Code Flow with PKCE (Proof Key for Code Exchange). |
|
azureoidc/loader
Package loader contains interfaces for safely accessing an OIDC Provider.
|
Package loader contains interfaces for safely accessing an OIDC Provider. |
|
basesession
Package basesession implements the session management for the application.
|
Package basesession implements the session management for the application. |
|
cookie
Package cookie implements all cookie handling for the session package
|
Package cookie implements all cookie handling for the session package |
|
types
Package types defines common types and constants used across the session package.
|
Package types defines common types and constants used across the session package. |
|
util
Package util is used for general utility function such as generic sorting/filtering and more.
|
Package util is used for general utility function such as generic sorting/filtering and more. |
|
Package mock is used to generate mock files for testing.
|
Package mock is used to generate mock files for testing. |
|
mock_azureoidc
Package mock_azureoidc is a generated GoMock package.
|
Package mock_azureoidc is a generated GoMock package. |
|
mock_azureoidc/mock_loader
Package mock_loader is a generated GoMock package.
|
Package mock_loader is a generated GoMock package. |
|
mock_basesession
Package mock_basesession is a generated GoMock package.
|
Package mock_basesession is a generated GoMock package. |
|
mock_cookie
Package mock_cookie is a generated GoMock package.
|
Package mock_cookie is a generated GoMock package. |
|
mock_postgres
Package mock_postgres is a generated GoMock package.
|
Package mock_postgres is a generated GoMock package. |
|
mock_session
Package mock_session is a generated GoMock package.
|
Package mock_session is a generated GoMock package. |
|
Package sessioninfo handles session information.
|
Package sessioninfo handles session information. |
|
Package sessionstorage implements database storage for session data.
|
Package sessionstorage implements database storage for session data. |
|
internal/dbtype
Package dbtype contains types used by the database driver packages for session storage.
|
Package dbtype contains types used by the database driver packages for session storage. |
|
internal/postgres
Package postgres implements the session storage driver for PostgreSQL.
|
Package postgres implements the session storage driver for PostgreSQL. |
|
internal/spanner
Package spanner provides the session storage driver for Spanner.
|
Package spanner provides the session storage driver for Spanner. |
|
mock/mock_sessionstorage
Package mock_sessionstorage is a generated GoMock package.
|
Package mock_sessionstorage is a generated GoMock package. |