session

package
v1.6.14 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateSession

func CreateSession(session Session) error

func DeactivateSessionByID added in v1.0.0

func DeactivateSessionByID(sessionID string) error

func HandleDeactivateSession added in v1.4.4

func HandleDeactivateSession(w http.ResponseWriter, r *http.Request)

HandleDeactivateSession godoc @Summary Deactivate a session @Tags admin-sessions @Produce json @Param id path string true "Session ID" @Security AdminAuth @Success 200 {object} map[string]string @Router /admin/api/sessions/{id} [delete]

func HandleListSessions added in v1.4.4

func HandleListSessions(w http.ResponseWriter, r *http.Request)

HandleListSessions godoc @Summary List sessions @Description Lists all active sessions, optionally filtered by user ID. @Tags admin-sessions @Produce json @Param user_id query string false "Filter by User ID" @Security AdminAuth @Success 200 {array} SessionResponse @Router /admin/api/sessions [get]

func HandleLogout

func HandleLogout(w http.ResponseWriter, r *http.Request)

HandleLogout godoc @Summary RP-Initiated Logout (POST) @Description RP-Initiated Logout via POST (form-encoded) per OpenID Connect RP-Initiated Logout 1.0 §2. @Tags oauth2 @Accept application/x-www-form-urlencoded @Produce html @Param id_token_hint formData string false "Previously issued ID token" @Param client_id formData string false "Client identifier" @Param post_logout_redirect_uri formData string false "URI to redirect to after logout" @Param state formData string false "Opaque value passed back to post_logout_redirect_uri" @Success 200 {string} string "Signed-out confirmation page" @Success 302 {string} string "Redirect to post_logout_redirect_uri" @Router /oauth2/logout [post]

func HandleRpInitiatedLogout added in v1.6.0

func HandleRpInitiatedLogout(w http.ResponseWriter, r *http.Request)

HandleRpInitiatedLogout godoc @Summary RP-Initiated Logout (GET) @Description OIDC RP-Initiated Logout per OpenID Connect RP-Initiated Logout 1.0 §2. @Description Clears the IdP session and optionally redirects to post_logout_redirect_uri. @Tags oauth2 @Produce html @Param id_token_hint query string false "Previously issued ID token" @Param post_logout_redirect_uri query string false "URI to redirect to after logout" @Param state query string false "Opaque value passed back to post_logout_redirect_uri" @Param client_id query string false "Client identifier (used to validate post_logout_redirect_uri when no id_token_hint)" @Success 302 {string} string "Redirect" @Router /oauth2/logout [get]

Types

type Session

type Session struct {
	ID             string
	UserID         string
	AccessToken    string
	RefreshToken   string
	UserAgent      string
	IPAddress      string
	DeviceID       *string
	LastActivityAt *time.Time
	CreatedAt      time.Time
	ExpiresAt      time.Time
	DeactivatedAt  *time.Time
	Location       string
}

func ListSessions added in v1.0.0

func ListSessions() ([]*Session, error)

func ListSessionsByUser added in v1.0.0

func ListSessionsByUser(userID string) ([]*Session, error)

func SessionByAccessToken

func SessionByAccessToken(accessToken string) (*Session, error)

func SessionByID

func SessionByID(sessionID string) (*Session, error)

func (*Session) ToResponse added in v1.0.0

func (s *Session) ToResponse() SessionResponse

type SessionResponse added in v1.0.0

type SessionResponse struct {
	ID             string     `json:"id"`
	UserID         string     `json:"user_id"`
	UserAgent      string     `json:"user_agent"`
	IPAddress      string     `json:"ip_address"`
	DeviceID       *string    `json:"device_id"`
	LastActivityAt *time.Time `json:"last_activity_at"`
	CreatedAt      time.Time  `json:"created_at"`
	ExpiresAt      time.Time  `json:"expires_at"`
	DeactivatedAt  *time.Time `json:"deactivated_at"`
	Location       string     `json:"location"`
	Status         string     `json:"status"`
}

SessionResponse is the admin-safe representation (no tokens)

Jump to

Keyboard shortcuts

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