Documentation
¶
Index ¶
- func DeleteAllSessions(userID string) error
- func DeleteOtherSessions(userID, currentSessionID string) error
- func DeleteSession(sessionID string) (modeliamsession.Session, error)
- func GetCurrentSession(ctx *types.ServiceContext) (string, modeliamsession.Session, error)
- func GetSessionExpiration() time.Duration
- func InvalidateUserSessions(userID string)
- func SetSessionExpiration(expiration time.Duration)
- func TrackUserSession(session modeliamsession.Session) error
- func UpdateSessionMustChangePassword(sessionID string, mustChange bool) error
- type AdminSessionsDeleteService
- type AdminSessionsGetService
- type AdminSessionsListService
- type AdminUserSessionsDeleteService
- type AdminUserSessionsListService
- type CurrentDeleteService
- type CurrentListService
- type HeartbeatService
- type SessionsDeleteAllService
- type SessionsDeleteService
- type SessionsGetService
- type SessionsListService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteAllSessions ¶
DeleteAllSessions deletes all indexed sessions of a user. Missing session records are treated as stale index entries and cleaned up from the user's ZSET so the operation remains idempotent.
func DeleteOtherSessions ¶
DeleteOtherSessions deletes all indexed sessions of a user except the current session. Missing session records are treated as stale index entries and cleaned up from the user's ZSET so the operation remains idempotent.
func DeleteSession ¶
func DeleteSession(sessionID string) (modeliamsession.Session, error)
DeleteSession deletes the stored session and removes the indexed user-session relation.
func GetCurrentSession ¶
func GetCurrentSession(ctx *types.ServiceContext) (string, modeliamsession.Session, error)
GetCurrentSession loads the current authenticated user session from the request cookie and Redis storage. It only enforces the minimal integrity required by IAM services: the session must exist and be bound to a user. Database-level checks such as user status, permission, or account existence remain the responsibility of the caller.
func GetSessionExpiration ¶
GetSessionExpiration returns the configured session expiration time. If not configured, it returns the default value of 8 hours.
func InvalidateUserSessions ¶
func InvalidateUserSessions(userID string)
InvalidateUserSessions removes all indexed sessions for a user. It is best-effort: failures to talk to Redis do not block password updates.
func SetSessionExpiration ¶
SetSessionExpiration sets the session expiration time for iam module. This function should be called during module registration.
func TrackUserSession ¶
func TrackUserSession(session modeliamsession.Session) error
TrackUserSession adds the session id into the user's indexed session set.
func UpdateSessionMustChangePassword ¶
UpdateSessionMustChangePassword updates the stored session after the user clears MustChangePassword in the database.
Types ¶
type AdminSessionsDeleteService ¶
type AdminSessionsDeleteService struct {
service.Base[*model.Empty, *modeliamsession.AdminSessionsDeleteReq, *modeliamsession.AdminSessionsDeleteRsp]
}
AdminSessionsDeleteService handles invalidation of a specified session for privileged administrators.
func (*AdminSessionsDeleteService) Delete ¶
func (s *AdminSessionsDeleteService) Delete(ctx *types.ServiceContext, req *modeliamsession.AdminSessionsDeleteReq) (rsp *modeliamsession.AdminSessionsDeleteRsp, err error)
Delete invalidates a specified session for a privileged administrator.
type AdminSessionsGetService ¶
type AdminSessionsGetService struct {
service.Base[*model.Empty, *modeliamsession.AdminSessionsGetReq, *modeliamsession.AdminSessionsGetRsp]
}
AdminSessionsGetService handles retrieval of a specified session for privileged administrators.
func (*AdminSessionsGetService) Get ¶
func (s *AdminSessionsGetService) Get(ctx *types.ServiceContext, req *modeliamsession.AdminSessionsGetReq) (rsp *modeliamsession.AdminSessionsGetRsp, err error)
Get returns the detail of a specified session for a privileged administrator.
type AdminSessionsListService ¶
type AdminSessionsListService struct {
service.Base[*model.Empty, *modeliamsession.AdminSessionsListReq, *modeliamsession.AdminSessionsListRsp]
}
AdminSessionsListService handles retrieval of all sessions grouped by user for privileged administrators.
func (*AdminSessionsListService) List ¶
func (s *AdminSessionsListService) List(ctx *types.ServiceContext, req *modeliamsession.AdminSessionsListReq) (rsp *modeliamsession.AdminSessionsListRsp, err error)
List returns all indexed sessions grouped by user for a privileged administrator.
type AdminUserSessionsDeleteService ¶
type AdminUserSessionsDeleteService struct {
service.Base[*model.Empty, *modeliamsession.AdminUserSessionsDeleteReq, *modeliamsession.AdminUserSessionsDeleteRsp]
}
AdminUserSessionsDeleteService handles invalidation of all sessions owned by a specified user for privileged administrators.
func (*AdminUserSessionsDeleteService) Delete ¶
func (s *AdminUserSessionsDeleteService) Delete(ctx *types.ServiceContext, req *modeliamsession.AdminUserSessionsDeleteReq) (rsp *modeliamsession.AdminUserSessionsDeleteRsp, err error)
Delete invalidates all indexed sessions of a specified user for a privileged administrator.
type AdminUserSessionsListService ¶
type AdminUserSessionsListService struct {
service.Base[*model.Empty, *modeliamsession.AdminUserSessionsListReq, *modeliamsession.AdminUserSessionsListRsp]
}
AdminUserSessionsListService handles retrieval of all sessions owned by a specified user for privileged administrators.
func (*AdminUserSessionsListService) List ¶
func (s *AdminUserSessionsListService) List(ctx *types.ServiceContext, req *modeliamsession.AdminUserSessionsListReq) (rsp *modeliamsession.AdminUserSessionsListRsp, err error)
List returns all indexed sessions of a specified user for a privileged administrator.
type CurrentDeleteService ¶
type CurrentDeleteService struct {
service.Base[*model.Empty, *modeliamsession.CurrentDeleteReq, *modeliamsession.CurrentDeleteRsp]
}
CurrentDeleteService handles invalidation of the current authenticated session.
func (*CurrentDeleteService) Delete ¶
func (s *CurrentDeleteService) Delete(ctx *types.ServiceContext, req *modeliamsession.CurrentDeleteReq) (rsp *modeliamsession.CurrentDeleteRsp, err error)
Delete invalidates the current authenticated session and clears the session cookie.
type CurrentListService ¶
type CurrentListService struct {
service.Base[*model.Empty, *modeliamsession.CurrentListReq, *modeliamsession.CurrentListRsp]
}
CurrentListService handles retrieval of the current authenticated session.
func (*CurrentListService) List ¶
func (s *CurrentListService) List(ctx *types.ServiceContext, req *modeliamsession.CurrentListReq) (rsp *modeliamsession.CurrentListRsp, err error)
List returns the current authenticated session together with the latest user snapshot.
type HeartbeatService ¶
type HeartbeatService struct {
service.Base[*modeliamsession.Heartbeat, *modeliamsession.Heartbeat, *modeliamsession.Heartbeat]
}
HeartbeatService records client liveness for the current authenticated session.
func (*HeartbeatService) Create ¶
func (s *HeartbeatService) Create(ctx *types.ServiceContext, req *modeliamsession.Heartbeat) (rsp *modeliamsession.Heartbeat, err error)
Create validates the current session and updates the online-user record without extending the Redis session lifetime.
type SessionsDeleteAllService ¶
type SessionsDeleteAllService struct {
service.Base[*model.Empty, *modeliamsession.SessionsDeleteAllReq, *modeliamsession.SessionsDeleteAllRsp]
}
SessionsDeleteAllService handles invalidation of all sessions for the current authenticated user.
func (*SessionsDeleteAllService) Delete ¶
func (s *SessionsDeleteAllService) Delete(ctx *types.ServiceContext, req *modeliamsession.SessionsDeleteAllReq) (rsp *modeliamsession.SessionsDeleteAllRsp, err error)
Delete invalidates all sessions for the current authenticated user.
type SessionsDeleteService ¶
type SessionsDeleteService struct {
service.Base[*model.Empty, *modeliamsession.SessionsDeleteReq, *modeliamsession.SessionsDeleteRsp]
}
SessionsDeleteService handles invalidation of a specified session for the current authenticated user.
func (*SessionsDeleteService) Delete ¶
func (s *SessionsDeleteService) Delete(ctx *types.ServiceContext, req *modeliamsession.SessionsDeleteReq) (rsp *modeliamsession.SessionsDeleteRsp, err error)
Delete invalidates a specified session for the current authenticated user. When the route id is "others", it keeps the current session active and revokes every other indexed session of the same user. The endpoint remains idempotent: deleting a missing session still returns success.
type SessionsGetService ¶
type SessionsGetService struct {
service.Base[*model.Empty, *modeliamsession.SessionsGetReq, *modeliamsession.SessionsGetRsp]
}
SessionsGetService handles retrieval of a specified session for the current authenticated user.
func (*SessionsGetService) Get ¶
func (s *SessionsGetService) Get(ctx *types.ServiceContext, req *modeliamsession.SessionsGetReq) (rsp *modeliamsession.SessionsGetRsp, err error)
Get returns the detail of a specified session for the current authenticated user.
type SessionsListService ¶
type SessionsListService struct {
service.Base[*model.Empty, *modeliamsession.SessionsListReq, *modeliamsession.SessionsListRsp]
}
SessionsListService handles retrieval of all active sessions for the current authenticated user.
func (*SessionsListService) List ¶
func (s *SessionsListService) List(ctx *types.ServiceContext, req *modeliamsession.SessionsListReq) (rsp *modeliamsession.SessionsListRsp, err error)
List returns all active sessions for the current authenticated user.