sessions

package
v0.0.0-...-84f1f66 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidScope

func ValidScope(scope SessionScope) bool

Types

type ScopeSubject

type ScopeSubject struct {
	Scope     string
	SessionId string
}

func ParseScopeSubject

func ParseScopeSubject(subject string) (res ScopeSubject, err error)

type Session

type Session struct {
	Id         string          `json:"_id" bson:"_id"`
	Scope      SessionScope    `json:"scope" bson:"scope"`
	EntityId   string          `json:"entityId" bson:"entityId"`
	Expire     time.Time       `json:"expire" bson:"expire"`
	AllowedIPs SessionIPs      `json:"allowedIps" bson:"allowedIps"`
	Key        keys.SecuredKey `json:"key" bson:"key"`
}

func NewSession

func NewSession(scope SessionScope, username string, duration time.Duration, allowedIps []string, mk keys.MasterKey) (s Session, err error)

NewSession create a new Session object with the username and duration specified

func (*Session) AddAllowedIPs

func (s *Session) AddAllowedIPs(ips SessionIPs)

func (*Session) CreateSessionJWT

func (s *Session) CreateSessionJWT(issuer string, mk keys.MasterKey) (string, error)

func (*Session) DeleteAllowedIP

func (s *Session) DeleteAllowedIP(ip SessionIP)

func (*Session) Extend

func (s *Session) Extend(duration time.Duration)

Extend set the time limit for the session from now

func (*Session) GetAllowedIPs

func (s *Session) GetAllowedIPs() SessionIPs

func (*Session) GetEntityname

func (s *Session) GetEntityname() string

GetEntityname returns the username of the user associated to the session

func (*Session) GetID

func (s *Session) GetID() string

getID returns the identifier of the session

func (*Session) GetJwtSubject

func (s *Session) GetJwtSubject() string

func (*Session) GetTtl

func (s *Session) GetTtl() time.Duration

func (*Session) HasAllowedIP

func (s *Session) HasAllowedIP(ip SessionIP) (bool, error)

func (*Session) IsExpired

func (s *Session) IsExpired() bool

IsExpired returns a boolean that indicate if the time limit of the session is elapsed

func (*Session) ResetAllowedIPs

func (s *Session) ResetAllowedIPs()

func (*Session) SetAllowedIPs

func (s *Session) SetAllowedIPs(ips SessionIPs)

func (*Session) Valid

func (s *Session) Valid() bool

Valid returns a boolean that indicate if the session data is not empty

func (*Session) VerifySessionJWT

func (s *Session) VerifySessionJWT(jwtString string, mk keys.MasterKey) error

type SessionExpiredError

type SessionExpiredError struct{}

func (*SessionExpiredError) Error

func (m *SessionExpiredError) Error() string

type SessionIP

type SessionIP = string

type SessionIPs

type SessionIPs []SessionIP

type SessionScope

type SessionScope string
const (
	ScopeTotp       SessionScope = "otp"
	ScopeValidation SessionScope = "vld"
	ScopeLogin      SessionScope = "sid"
	ScopeAuthChange SessionScope = "aut"
	ScopeWebauthn   SessionScope = "wau"
	ScopeMachine    SessionScope = "mac"
)

Jump to

Keyboard shortcuts

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