Documentation
¶
Index ¶
- func CreateSession(session Session) error
- func DeactivateSessionByID(sessionID string) error
- func HandleDeactivateSession(w http.ResponseWriter, r *http.Request)
- func HandleListSessions(w http.ResponseWriter, r *http.Request)
- func HandleLogout(w http.ResponseWriter, r *http.Request)
- type Session
- type SessionResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateSession ¶
func DeactivateSessionByID ¶ added in v1.0.0
func HandleDeactivateSession ¶ added in v1.4.4
func HandleDeactivateSession(w http.ResponseWriter, r *http.Request)
HandleDeactivateSession godoc @Summary Deactivate a session @Tags sessions-admin @Produce json @Param id path string true "Session ID" @Security BearerAuth @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 sessions-admin @Produce json @Param user_id query string false "Filter by User ID" @Security BearerAuth @Success 200 {array} SessionResponse @Router /admin/api/sessions [get]
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]
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)