session

package
v0.0.0-...-c4f7e29 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AppSessionTokenCookieDef = &httputil.CookieDef{
	NameSuffix: "app_session",
	Path:       "/",
	SameSite:   http.SameSiteLaxMode,
}
View Source
var ErrInvalidSession = errors.New("provided session is invalid")
View Source
var ErrSessionNotFound = errors.New("session not found")

Functions

func GetUserID

func GetUserID(ctx context.Context) *string

func HasValidSession

func HasValidSession(ctx context.Context) bool

func NewInfo

func NewInfo(s Session, isAnonymous bool, isVerified bool, userCanReauthenticate bool, effectiveRoles []string) *model.SessionInfo

func WithInvalidSession

func WithInvalidSession(ctx context.Context) context.Context

func WithSession

func WithSession(ctx context.Context, s Session) 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 NewAttrs

func NewAttrs(userID string) *Attrs

func NewAttrsFromAuthenticationInfo

func NewAttrsFromAuthenticationInfo(info authenticationinfo.T) *Attrs

func (*Attrs) GetAMR

func (a *Attrs) GetAMR() ([]string, bool)

func (*Attrs) SetAMR

func (a *Attrs) SetAMR(value []string)

type CookieDef

type CookieDef struct {
	Def               *httputil.CookieDef
	SameSiteStrictDef *httputil.CookieDef
}

func NewSessionCookieDef

func NewSessionCookieDef(sessionCfg *config.SessionConfig) CookieDef

type CookieManager

type CookieManager interface {
	GetCookie(r *http.Request, def *httputil.CookieDef) (*http.Cookie, error)
	ClearCookie(def *httputil.CookieDef) *http.Cookie
}

type CreateReason

type CreateReason string
const (
	CreateReasonSignup         CreateReason = "signup"
	CreateReasonLogin          CreateReason = "login"
	CreateReasonPromote        CreateReason = "promote"
	CreateReasonReauthenticate CreateReason = "reauthenticate"
)

type EventService

type EventService interface {
	DispatchEventOnCommit(payload event.Payload) error
}

type IDPSessionManager

type IDPSessionManager ManagementService

type IDPSessionResolver

type IDPSessionResolver Resolver

type ManagementService

type ManagementService interface {
	ClearCookie() []*http.Cookie
	Get(id string) (Session, error)
	Delete(Session) error
	List(userID string) ([]Session, error)
	TerminateAllExcept(userID string, currentSession Session) ([]Session, error)
}

type Manager

type Manager struct {
	IDPSessions         IDPSessionManager
	AccessTokenSessions AccessTokenSessionManager
	Events              EventService
}

func (*Manager) Get

func (m *Manager) Get(id string) (Session, error)

func (*Manager) List

func (m *Manager) List(userID string) ([]Session, error)

func (*Manager) Logout

func (m *Manager) Logout(session Session, rw http.ResponseWriter) error

func (*Manager) RevokeWithEvent

func (m *Manager) RevokeWithEvent(session Session, isTermination bool, isAdminAPI bool) error

func (*Manager) RevokeWithoutEvent

func (m *Manager) RevokeWithoutEvent(session Session) error

func (*Manager) TerminateAllExcept

func (m *Manager) TerminateAllExcept(userID string, currentSession Session, isAdminAPI bool) error

type MeterService

type MeterService interface {
	TrackActiveUser(userID string) error
}

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
	IDPSessionOnly             bool
}

func (*Middleware) Handle

func (m *Middleware) Handle(next http.Handler) http.Handler

type MiddlewareLogger

type MiddlewareLogger struct{ *log.Logger }

func NewMiddlewareLogger

func NewMiddlewareLogger(lf *log.Factory) MiddlewareLogger

type Resolver

type Resolver interface {
	Resolve(rw http.ResponseWriter, r *http.Request) (Session, error)
}

type Session

type Session interface {
	SessionID() string
	SessionType() Type

	GetClientID() string
	GetCreatedAt() time.Time
	GetAccessInfo() *access.Info
	GetDeviceInfo() (map[string]interface{}, bool)

	GetAuthenticationInfo() authenticationinfo.T

	ToAPIModel() *model.Session

	// SSOGroupIDPSessionID returns the IDP session id of the SSO group
	// if the session is not SSO enabled, SSOGroupIDPSessionID will be empty
	SSOGroupIDPSessionID() string
	// IsSameSSOGroup indicates whether the session is in the same SSO group
	IsSameSSOGroup(s Session) bool
	Equal(s Session) bool
}

func GetSession

func GetSession(ctx context.Context) Session

type Type

type Type string
const (
	TypeIdentityProvider Type = "idp"
	TypeOfflineGrant     Type = "offline_grant"
)

type UserQuery

type UserQuery interface {
	Get(id string, role accesscontrol.Role) (*model.User, error)
	GetRaw(id string) (*user.User, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL