Documentation
¶
Index ¶
- Variables
- type Lock
- type NoOpLock
- type SessionState
- func (s *SessionState) Age() time.Duration
- func (s *SessionState) CheckNonce(hashed string) bool
- func (s *SessionState) CreatedAtNow()
- func (s *SessionState) EncodeSessionState(c encryption.Cipher, compress bool) ([]byte, error)
- func (s *SessionState) ExpiresIn(d time.Duration)
- func (s *SessionState) GetClaim(claim string) []string
- func (s *SessionState) IsExpired() bool
- func (s *SessionState) ObtainLock(ctx context.Context, expiration time.Duration) error
- func (s *SessionState) PeekLock(ctx context.Context) (bool, error)
- func (s *SessionState) RefreshLock(ctx context.Context, expiration time.Duration) error
- func (s *SessionState) ReleaseLock(ctx context.Context) error
- func (s *SessionState) SetExpiresOn(exp time.Time)
- func (s *SessionState) String() string
- type SessionStore
Constants ¶
This section is empty.
Variables ¶
var ErrLockNotObtained = errors.New("lock: not obtained")
Functions ¶
This section is empty.
Types ¶
type Lock ¶
type Lock interface {
// Obtain obtains the lock on the distributed
// lock resource if no lock exists yet.
// Otherwise it will return ErrLockNotObtained
Obtain(ctx context.Context, expiration time.Duration) error
// Peek returns true if the lock currently exists
// Otherwise it returns false.
Peek(ctx context.Context) (bool, error)
// Refresh refreshes the expiration time of the lock,
// if is still applied.
// Otherwise it will return ErrNotLocked
Refresh(ctx context.Context, expiration time.Duration) error
// Release removes the existing lock,
// Otherwise it will return ErrNotLocked
Release(ctx context.Context) error
}
Lock is an interface for controlling session locks
type SessionState ¶
type SessionState struct {
CreatedAt *time.Time `json:"ca,omitempty"`
ExpiresOn *time.Time `json:"eo,omitempty"`
AccessToken string `json:"at,omitempty"`
IDToken string `json:"it,omitempty"`
RefreshToken string `json:"rt,omitempty"`
Nonce []byte `json:"n,omitempty"`
Email string `json:"e,omitempty"`
User string `json:"u,omitempty"`
Groups []string `json:"g,omitempty"`
PreferredUsername string `json:"pu,omitempty"`
// Internal helpers, not serialized
Clock clock.Clock `json:"-"`
Lock Lock `json:"-"`
}
// SessionState is used to store information about the currently authenticated user session
func DecodeSessionState ¶
func DecodeSessionState(data []byte, c encryption.Cipher, compressed bool) (*SessionState, error)
DecodeSessionState decodes a LZ4 compressed MessagePack into a Session State
func (*SessionState) Age ¶
func (s *SessionState) Age() time.Duration
Age returns the age of a session
func (*SessionState) CheckNonce ¶
func (s *SessionState) CheckNonce(hashed string) bool
CheckNonce compares the Nonce against a potential hash of it
func (*SessionState) CreatedAtNow ¶
func (s *SessionState) CreatedAtNow()
CreatedAtNow sets a SessionState's CreatedAt to now
func (*SessionState) EncodeSessionState ¶
func (s *SessionState) EncodeSessionState(c encryption.Cipher, compress bool) ([]byte, error)
EncodeSessionState returns an encrypted, lz4 compressed, MessagePack encoded session
func (*SessionState) ExpiresIn ¶
func (s *SessionState) ExpiresIn(d time.Duration)
ExpiresIn sets an expiration a certain duration from CreatedAt. CreatedAt will be set to time.Now if it is unset.
func (*SessionState) GetClaim ¶
func (s *SessionState) GetClaim(claim string) []string
func (*SessionState) IsExpired ¶
func (s *SessionState) IsExpired() bool
IsExpired checks whether the session has expired
func (*SessionState) ObtainLock ¶
func (*SessionState) RefreshLock ¶
func (*SessionState) ReleaseLock ¶
func (s *SessionState) ReleaseLock(ctx context.Context) error
func (*SessionState) SetExpiresOn ¶
func (s *SessionState) SetExpiresOn(exp time.Time)
SetExpiresOn sets an expiration
func (*SessionState) String ¶
func (s *SessionState) String() string
String constructs a summary of the session state
type SessionStore ¶
type SessionStore interface {
Save(rw http.ResponseWriter, req *http.Request, s *SessionState) error
Load(req *http.Request) (*SessionState, error)
Clear(rw http.ResponseWriter, req *http.Request) error
VerifyConnection(ctx context.Context) error
}
SessionStore is an interface to storing user sessions in the proxy