auth_session

package
v0.0.0-...-8122643 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthUserFinder

type AuthUserFinder interface {
	FindAuthUser(ctx op_context.Context, login string) (auth.User, error)
}

type AuthUserManager

type AuthUserManager interface {
	UserValidators
	AuthUserFinder
}

type Session

type Session interface {
	common.Object
	auth.WithUser

	SetValid(valid bool)
	SetExpiration(exp time.Time)

	IsValid() bool
	GetExpiration() time.Time
}

func NewSession

func NewSession() Session

type SessionBase

type SessionBase struct {
	common.ObjectBase
	auth.WithUserBase
	Valid      bool      `gorm:"index"`
	Expiration time.Time `gorm:"index"`
}

func (*SessionBase) GetExpiration

func (s *SessionBase) GetExpiration() time.Time

func (*SessionBase) IsValid

func (s *SessionBase) IsValid() bool

func (*SessionBase) SetExpiration

func (s *SessionBase) SetExpiration(exp time.Time)

func (*SessionBase) SetValid

func (s *SessionBase) SetValid(valid bool)

type SessionClient

type SessionClient interface {
	common.Object
	auth.WithUser
	SetSessionId(userId string)
	SetClientIp(clientIp string)
	SetUserAgent(userAgent string)
	SetClientHash(clientHash string)

	GetSessionId() string
	GetClientIp() string
	GetUserAgent() string
	GetClientHash() string
}

func NewSessionClient

func NewSessionClient() SessionClient

type SessionClientBase

type SessionClientBase struct {
	common.ObjectBase
	auth.WithUserBase
	SessionId  string `gorm:"index;index:,unique,composite:client_session"`
	ClientIp   string `gorm:"index"`
	UserAgent  string
	ClientHash string `gorm:"index;index:,unique,composite:client_session"`
}

func (*SessionClientBase) GetClientHash

func (s *SessionClientBase) GetClientHash() string

func (*SessionClientBase) GetClientIp

func (s *SessionClientBase) GetClientIp() string

func (*SessionClientBase) GetSessionId

func (s *SessionClientBase) GetSessionId() string

func (*SessionClientBase) GetUserAgent

func (s *SessionClientBase) GetUserAgent() string

func (*SessionClientBase) SetClientHash

func (s *SessionClientBase) SetClientHash(val string)

func (*SessionClientBase) SetClientIp

func (s *SessionClientBase) SetClientIp(val string)

func (*SessionClientBase) SetSessionId

func (s *SessionClientBase) SetSessionId(sessionId string)

func (*SessionClientBase) SetUserAgent

func (s *SessionClientBase) SetUserAgent(val string)

type SessionController

type SessionController interface {
	CreateSession(ctx auth.ContextWithAuthUser, expiration time.Time) (Session, error)
	FindSession(ctx op_context.Context, sessionId string) (Session, error)
	UpdateSessionClient(ctx auth.AuthContext) error
	UpdateSessionExpiration(ctx auth.AuthContext, session Session) error
	InvalidateSession(ctx op_context.Context, userId string, sessionId string) error
	InvalidateUserSessions(ctx op_context.Context, userId string) error
	InvalidateAllSessions(ctx op_context.Context) error

	GetSessions(ctx op_context.Context, filter *db.Filter, sessions interface{}) (int64, error)
	GetSessionClients(ctx op_context.Context, filter *db.Filter, sessionClients interface{}) (int64, error)

	SetSessionBuilder(func() Session)
	MakeSession() Session
	SetSessionClientBuilder(func() SessionClient)
	MakeSessionClient() SessionClient
}

type SessionControllerBase

type SessionControllerBase struct {
	// contains filtered or unexported fields
}

func LocalSessionController

func LocalSessionController(cr ...crud.CRUD) *SessionControllerBase

func (*SessionControllerBase) CreateSession

func (s *SessionControllerBase) CreateSession(ctx auth.ContextWithAuthUser, expiration time.Time) (Session, error)

func (*SessionControllerBase) FindSession

func (s *SessionControllerBase) FindSession(ctx op_context.Context, sessionId string) (Session, error)

func (*SessionControllerBase) GetSessionClients

func (s *SessionControllerBase) GetSessionClients(ctx op_context.Context, filter *db.Filter, sessions interface{}) (int64, error)

Get sessions using filter. Note that sessions argument must be of *[]SessionClient type.

func (*SessionControllerBase) GetSessions

func (s *SessionControllerBase) GetSessions(ctx op_context.Context, filter *db.Filter, sessions interface{}) (int64, error)

Get sessions using filter. Note that sessions argument must be of *[]Session type.

func (*SessionControllerBase) InvalidateAllSessions

func (s *SessionControllerBase) InvalidateAllSessions(ctx op_context.Context) error

func (*SessionControllerBase) InvalidateSession

func (s *SessionControllerBase) InvalidateSession(ctx op_context.Context, userId string, sessionId string) error

func (*SessionControllerBase) InvalidateUserSessions

func (s *SessionControllerBase) InvalidateUserSessions(ctx op_context.Context, userId string) error

func (*SessionControllerBase) MakeSession

func (s *SessionControllerBase) MakeSession() Session

func (*SessionControllerBase) MakeSessionClient

func (s *SessionControllerBase) MakeSessionClient() SessionClient

func (*SessionControllerBase) SetSessionBuilder

func (s *SessionControllerBase) SetSessionBuilder(sessionBuilder func() Session)

func (*SessionControllerBase) SetSessionClientBuilder

func (s *SessionControllerBase) SetSessionClientBuilder(sessionClientBuilder func() SessionClient)

func (*SessionControllerBase) UpdateSessionClient

func (s *SessionControllerBase) UpdateSessionClient(ctx auth.AuthContext) error

func (*SessionControllerBase) UpdateSessionExpiration

func (s *SessionControllerBase) UpdateSessionExpiration(ctx auth.AuthContext, session Session) error

type UserValidators

type UserValidators interface {
	ValidateLogin(login string) error
	ValidatePassword(password string) error
}

type WithAuthUserManager

type WithAuthUserManager interface {
	AuthUserManager() AuthUserManager
}

type WithSessionManager

type WithSessionManager interface {
	SessionManager() SessionController
}

type WithUserSessionManager

type WithUserSessionManager interface {
	WithAuthUserManager
	WithSessionManager
}

Jump to

Keyboard shortcuts

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