Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateSession ¶
func DeactivateSessionByID ¶ added in v1.0.0
func HandleLogout ¶
func HandleLogout(w http.ResponseWriter, r *http.Request)
HandleLogout godoc @Summary Log out a user @Description Terminates the user's session @Tags session @Accept json @Produce json @Param Authorization header string true "Bearer access token" @Success 200 {string} string "Session terminated successfully" @Failure 401 {object} model.ApiError @Failure 500 {object} model.ApiError @Router /oauth2/logout [post]
func HandleSessionAdminEndpoint ¶ added in v1.0.0
func HandleSessionAdminEndpoint(w http.ResponseWriter, r *http.Request)
HandleSessionAdminEndpoint is the combined handler for /admin/api/sessions @Summary Session administration @Description GET: List all active sessions or filter by user ID. DELETE: Deactivate a specific session. @Tags sessions-admin @Accept json @Produce json @Param user_id query string false "Filter sessions by User ID (GET)" @Param id query string false "Session ID to deactivate (DELETE)" @Security BearerAuth @Success 200 {array} SessionResponse "List of sessions (GET)" @Success 200 {object} map[string]string "Deactivation result (DELETE)" @Router /admin/api/sessions [get] @Router /admin/api/sessions [delete]
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 ListSessionsByUser ¶ added in v1.0.0
func SessionByAccessToken ¶
func SessionByID ¶
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)