Documentation ¶
Index ¶
- Variables
- func GetUserID(ctx context.Context) *string
- func HasValidSession(ctx context.Context) bool
- func NewInfo(s ResolvedSession, isAnonymous bool, isVerified bool, ...) *model.SessionInfo
- func WithInvalidSession(ctx context.Context) context.Context
- func WithSession(ctx context.Context, s ResolvedSession) context.Context
- type AccessTokenSessionManager
- type AccessTokenSessionResolver
- type Attrs
- type CookieDef
- type CookieManager
- type CreateReason
- type EventService
- type IDPSessionManager
- type IDPSessionResolver
- type ListableSession
- type ManagementService
- type Manager
- func (m *Manager) Get(ctx context.Context, id string) (ListableSession, error)
- func (m *Manager) List(ctx context.Context, userID string) ([]ListableSession, error)
- func (m *Manager) Logout(ctx context.Context, session SessionBase, rw http.ResponseWriter) ([]ListableSession, error)
- func (m *Manager) RevokeWithEvent(ctx context.Context, session SessionBase, isTermination bool, isAdminAPI bool) error
- func (m *Manager) RevokeWithoutEvent(ctx context.Context, session SessionBase) error
- func (m *Manager) TerminateAllExcept(ctx context.Context, userID string, currentSession ResolvedSession, ...) error
- type MeterService
- type Middleware
- type MiddlewareLogger
- type ResolvedSession
- type Resolver
- type SessionBase
- type Type
- type UserQuery
Constants ¶
This section is empty.
Variables ¶
View Source
var AppAccessTokenCookieDef = &httputil.CookieDef{ NameSuffix: "app_access_token", Path: "/", SameSite: http.SameSiteLaxMode, IsNonHostOnly: true, }
View Source
var AppSessionTokenCookieDef = &httputil.CookieDef{ NameSuffix: "app_session", Path: "/", SameSite: http.SameSiteLaxMode, IsNonHostOnly: true, }
View Source
var DependencySet = wire.NewSet( NewMiddlewareLogger, wire.Struct(new(Middleware), "*"), wire.Struct(new(Manager), "*"), NewSessionCookieDef, )
View Source
var ErrInvalidSession = errors.New("provided session is invalid")
View Source
var ErrSessionNotFound = errors.New("session not found")
Functions ¶
func HasValidSession ¶
func NewInfo ¶
func NewInfo(s ResolvedSession, isAnonymous bool, isVerified bool, userCanReauthenticate bool, effectiveRoles []string) *model.SessionInfo
func WithSession ¶
func WithSession(ctx context.Context, s ResolvedSession) context.Context
Types ¶
type AccessTokenSessionManager ¶
type AccessTokenSessionManager ManagementService
type AccessTokenSessionResolver ¶
type AccessTokenSessionResolver Resolver
type Attrs ¶
type Attrs struct { UserID string `json:"user_id"` Claims map[model.ClaimName]interface{} `json:"claims"` }
func NewAttrsFromAuthenticationInfo ¶
func NewAttrsFromAuthenticationInfo(info authenticationinfo.T) *Attrs
type CookieDef ¶
func NewSessionCookieDef ¶
func NewSessionCookieDef(sessionCfg *config.SessionConfig) CookieDef
type CookieManager ¶
type CreateReason ¶
type CreateReason string
const ( CreateReasonSignup CreateReason = "signup" CreateReasonLogin CreateReason = "login" CreateReasonPromote CreateReason = "promote" CreateReasonReauthenticate CreateReason = "reauthenticate" )
type EventService ¶
type IDPSessionManager ¶
type IDPSessionManager ManagementService
type IDPSessionResolver ¶
type IDPSessionResolver Resolver
type ListableSession ¶
type ListableSession interface { SessionBase ListableSession() GetCreatedAt() time.Time GetAccessInfo() *access.Info GetDeviceInfo() (map[string]interface{}, bool) ToAPIModel() *model.Session // IsSameSSOGroup indicates whether the session is in the same SSO group IsSameSSOGroup(s SessionBase) bool EqualSession(s SessionBase) bool GetParticipatedSAMLServiceProviderIDsSet() setutil.Set[string] }
type ManagementService ¶
type ManagementService interface { ClearCookie() []*http.Cookie Get(ctx context.Context, id string) (ListableSession, error) Delete(ctx context.Context, s ListableSession) error List(ctx context.Context, userID string) ([]ListableSession, error) TerminateAllExcept(ctx context.Context, userID string, currentSession ResolvedSession) ([]ListableSession, error) }
type Manager ¶
type Manager struct { IDPSessions IDPSessionManager AccessTokenSessions AccessTokenSessionManager Events EventService }
func (*Manager) Logout ¶
func (m *Manager) Logout(ctx context.Context, session SessionBase, rw http.ResponseWriter) ([]ListableSession, error)
func (*Manager) RevokeWithEvent ¶
func (*Manager) RevokeWithoutEvent ¶
func (m *Manager) RevokeWithoutEvent(ctx context.Context, session SessionBase) error
func (*Manager) TerminateAllExcept ¶
type MeterService ¶
type Middleware ¶
type Middleware struct { SessionCookie CookieDef Cookies CookieManager IDPSessionResolver IDPSessionResolver AccessTokenSessionResolver AccessTokenSessionResolver AccessEvents *access.EventProvider Users UserQuery Database *appdb.Handle Logger MiddlewareLogger MeterService MeterService }
type MiddlewareLogger ¶
func NewMiddlewareLogger ¶
func NewMiddlewareLogger(lf *log.Factory) MiddlewareLogger
type ResolvedSession ¶
type ResolvedSession interface { SessionBase Session() GetCreatedAt() time.Time GetExpireAt() time.Time GetAccessInfo() *access.Info CreateNewAuthenticationInfoByThisSession() authenticationinfo.T }
func GetSession ¶
func GetSession(ctx context.Context) ResolvedSession
type Resolver ¶
type Resolver interface {
Resolve(ctx context.Context, rw http.ResponseWriter, r *http.Request) (ResolvedSession, error)
}
type SessionBase ¶
type SessionBase interface { SessionID() string SessionType() Type GetAuthenticationInfo() authenticationinfo.T // SSOGroupIDPSessionID returns the IDP session id of the SSO group // if the session is not SSO enabled, SSOGroupIDPSessionID will be empty SSOGroupIDPSessionID() string }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.