idpsession

package
v0.0.0-...-122f59b Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSessionNotFound = errors.New("session is not found")

Functions

This section is empty.

Types

type AccessEventProvider

type AccessEventProvider interface {
	InitStream(sessionID string, event *access.Event) error
}

type CookieManager

type CookieManager interface {
	ClearCookie(def *httputil.CookieDef) *http.Cookie
}

type IDPSession

type IDPSession struct {
	ID    string `json:"id"`
	AppID string `json:"app_id"`

	// CreatedAt is the timestamp that the user was initially authenticated at.
	CreatedAt time.Time `json:"created_at"`
	// Authenticated is the timestamp that the user was authenticated at.
	// It is equal to CreatedAt if the user has not reauthenticated at all.
	AuthenticatedAt time.Time     `json:"authenticated_at"`
	Attrs           session.Attrs `json:"attrs"`

	AccessInfo access.Info `json:"access_info"`

	TokenHash string `json:"token_hash"`
}

func (*IDPSession) Equal

func (s *IDPSession) Equal(ss session.Session) bool

func (*IDPSession) GetAccessInfo

func (s *IDPSession) GetAccessInfo() *access.Info

func (*IDPSession) GetAuthenticatedAt

func (s *IDPSession) GetAuthenticatedAt() time.Time

func (*IDPSession) GetAuthenticationInfo

func (s *IDPSession) GetAuthenticationInfo() authenticationinfo.T

func (*IDPSession) GetClientID

func (s *IDPSession) GetClientID() string

func (*IDPSession) GetCreatedAt

func (s *IDPSession) GetCreatedAt() time.Time

func (*IDPSession) GetDeviceInfo

func (s *IDPSession) GetDeviceInfo() (map[string]interface{}, bool)

func (*IDPSession) GetOIDCAMR

func (s *IDPSession) GetOIDCAMR() ([]string, bool)

func (*IDPSession) GetUserID

func (s *IDPSession) GetUserID() string

func (*IDPSession) IsSameSSOGroup

func (s *IDPSession) IsSameSSOGroup(ss session.Session) bool

IsSameSSOGroup returns true when the session argument - is the same idp session - is sso enabled offline grant that in the same sso group

func (*IDPSession) SSOGroupIDPSessionID

func (s *IDPSession) SSOGroupIDPSessionID() string

func (*IDPSession) SessionID

func (s *IDPSession) SessionID() string

func (*IDPSession) SessionType

func (s *IDPSession) SessionType() session.Type

func (*IDPSession) ToAPIModel

func (s *IDPSession) ToAPIModel() *model.Session

type Manager

type Manager struct {
	Store     Store
	Config    *config.SessionConfig
	Cookies   CookieManager
	CookieDef session.CookieDef
}

func (*Manager) ClearCookie

func (m *Manager) ClearCookie() []*http.Cookie

func (*Manager) Delete

func (m *Manager) Delete(session session.Session) error

func (*Manager) Get

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

func (*Manager) List

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

func (*Manager) TerminateAllExcept

func (m *Manager) TerminateAllExcept(userID string, currentSession session.Session) ([]session.Session, error)

type Provider

type Provider struct {
	Context         context.Context
	RemoteIP        httputil.RemoteIP
	UserAgentString httputil.UserAgentString
	AppID           config.AppID
	Redis           *appredis.Handle
	Store           Store
	AccessEvents    AccessEventProvider
	TrustProxy      config.TrustProxy
	Config          *config.SessionConfig
	Clock           clock.Clock
	Random          Rand
}

func (*Provider) AccessWithID

func (p *Provider) AccessWithID(id string, accessEvent access.Event) (*IDPSession, error)

func (*Provider) AccessWithToken

func (p *Provider) AccessWithToken(token string, accessEvent access.Event) (*IDPSession, error)

func (*Provider) CheckSessionExpired

func (p *Provider) CheckSessionExpired(session *IDPSession) (expired bool)

func (*Provider) Create

func (p *Provider) Create(session *IDPSession) error

func (*Provider) Get

func (p *Provider) Get(id string) (*IDPSession, error)

func (*Provider) GetByToken

func (p *Provider) GetByToken(token string) (*IDPSession, error)

func (*Provider) MakeSession

func (p *Provider) MakeSession(attrs *session.Attrs) (*IDPSession, string)

func (*Provider) Reauthenticate

func (p *Provider) Reauthenticate(id string, amr []string) (err error)

type Rand

type Rand *rand.Rand

type Resolver

type Resolver struct {
	Cookies         ResolverCookieManager
	CookieDef       session.CookieDef
	Provider        resolverProvider
	RemoteIP        httputil.RemoteIP
	UserAgentString httputil.UserAgentString
	TrustProxy      config.TrustProxy
	Clock           clock.Clock
}

func (*Resolver) Resolve

func (re *Resolver) Resolve(rw http.ResponseWriter, r *http.Request) (session.Session, error)

type ResolverCookieManager

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

type Store

type Store interface {
	// Create creates a session in the Store. It must not allow overwriting existing sessions.
	Create(s *IDPSession, expireAt time.Time) error
	// Update updates a session in the Store. It must return `ErrSessionNotFound` when the session does not exist.
	Update(s *IDPSession, expireAt time.Time) error
	// Get returns the session with id in the Store. It must return `ErrSessionNotFound` when the session does not exist.
	Get(id string) (*IDPSession, error)
	// Delete deletes the session with id in the Store. It must treat deleting non-existent session as successful.
	Delete(*IDPSession) error
	// List lists the sessions belonging to the user, in ascending creation time order
	List(userID string) ([]*IDPSession, error)
}

Store represents the backing store for IdP sessions. Note that the returned sessions may not be valid (e.g. can be expired)

type StoreRedis

type StoreRedis struct {
	Redis  *appredis.Handle
	AppID  config.AppID
	Clock  clock.Clock
	Logger StoreRedisLogger
}

func (*StoreRedis) Create

func (s *StoreRedis) Create(sess *IDPSession, expireAt time.Time) (err error)

func (*StoreRedis) Delete

func (s *StoreRedis) Delete(session *IDPSession) (err error)

func (*StoreRedis) Get

func (s *StoreRedis) Get(id string) (*IDPSession, error)

func (*StoreRedis) List

func (s *StoreRedis) List(userID string) (sessions []*IDPSession, err error)

func (*StoreRedis) Unmarshal

func (s *StoreRedis) Unmarshal(data []byte) (*IDPSession, error)

func (*StoreRedis) Update

func (s *StoreRedis) Update(sess *IDPSession, expireAt time.Time) (err error)

type StoreRedisLogger

type StoreRedisLogger struct{ *log.Logger }

func NewStoreRedisLogger

func NewStoreRedisLogger(lf *log.Factory) StoreRedisLogger

Jump to

Keyboard shortcuts

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