Documentation
¶
Index ¶
- func ClearSessionCookie(w http.ResponseWriter)
- func Middleware(store SessionStore) func(http.Handler) http.Handler
- func RequireAuth(next http.Handler) http.Handler
- func SetSessionCookie(w http.ResponseWriter, sessionID string)
- func WithUserSession(ctx context.Context, s *UserSession) context.Context
- type MemSessionProvider
- func (m *MemSessionProvider) Create(data UserSession) (string, error)
- func (m *MemSessionProvider) Delete(id string) error
- func (m *MemSessionProvider) DeleteByEmail(email string) (int, error)
- func (m *MemSessionProvider) Get(id string) (*UserSession, error)
- func (m *MemSessionProvider) ListAll() (map[string]UserSession, error)
- func (m *MemSessionProvider) Update(id string, data UserSession) error
- type SessionStore
- type UserSession
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClearSessionCookie ¶
func ClearSessionCookie(w http.ResponseWriter)
ClearSessionCookie removes the session cookie from the response.
func Middleware ¶
func Middleware(store SessionStore) func(http.Handler) http.Handler
Middleware reads the session ID from the cookie, looks up the UserSession from the store, and places it on the request context.
func RequireAuth ¶
RequireAuth redirects unauthenticated requests to /login.
func SetSessionCookie ¶
func SetSessionCookie(w http.ResponseWriter, sessionID string)
SetSessionCookie writes the session cookie to the response.
func WithUserSession ¶
func WithUserSession(ctx context.Context, s *UserSession) context.Context
WithUserSession returns a new context with the UserSession attached.
Types ¶
type MemSessionProvider ¶
type MemSessionProvider struct {
// contains filtered or unexported fields
}
func NewMemSessionProvider ¶
func NewMemSessionProvider() *MemSessionProvider
func (*MemSessionProvider) Create ¶
func (m *MemSessionProvider) Create(data UserSession) (string, error)
func (*MemSessionProvider) Delete ¶
func (m *MemSessionProvider) Delete(id string) error
func (*MemSessionProvider) DeleteByEmail ¶
func (m *MemSessionProvider) DeleteByEmail(email string) (int, error)
func (*MemSessionProvider) Get ¶
func (m *MemSessionProvider) Get(id string) (*UserSession, error)
func (*MemSessionProvider) ListAll ¶
func (m *MemSessionProvider) ListAll() (map[string]UserSession, error)
func (*MemSessionProvider) Update ¶
func (m *MemSessionProvider) Update(id string, data UserSession) error
type SessionStore ¶
type SessionStore interface {
Create(data UserSession) (id string, err error)
Get(id string) (*UserSession, error)
Update(id string, data UserSession) error
Delete(id string) error
DeleteByEmail(email string) (int, error)
ListAll() (map[string]UserSession, error)
}
type UserSession ¶
type UserSession struct {
UserId string `json:"user_id"`
Email string `json:"email"`
DisplayName string `json:"display_name"`
ControlPlaneRoles []string `json:"control_plane_roles"`
ConsentComplete bool `json:"consent_complete"`
CreatedAt time.Time `json:"created_at"`
}
func GetUserSession ¶
func GetUserSession(ctx context.Context) *UserSession
GetUserSession returns the UserSession from the context, or nil if not present.
func (*UserSession) IsLoggedIn ¶
func (s *UserSession) IsLoggedIn() bool
Click to show internal directories.
Click to hide internal directories.