Skip to main content
Version: 0.3.x(Latest)

Introduction​

SessionService provides plugins with the ability to query and manage online sessions. Plugins obtain the service via services.Session() to paginate through online session lists and revoke sessions by TokenID.

A typical consumer is the linapro-monitor-online plugin, which provides online user monitoring functionality, displaying currently online users through SessionService and allowing administrators to kick sessions.

Design Philosophy​

SessionService is built around two core capabilities: session projection and session management.

Session projection. The Session struct is a stable projection of an online session, containing the following fields:

FieldDescription
TokenIdUnique token identifier for the session
TenantIdTenant the session belongs to; 0 means platform
UserIdAuthenticated user ID
UsernameAuthenticated username
ClientTypeClient type
DeptNameDepartment name projection
IpLogin IP address
BrowserBrowser fingerprint
OsOperating system fingerprint
LoginTimeInitial login time
LastActiveTimeMost recent activity time

Session filtering. ListFilter supports fuzzy matching by username and login IP, useful for administrators searching for specific users among a large number of sessions.

Architectural Position​

SessionService sits at the query and management layer in the session management chain, complementing the session registration layer of AuthService:

  • AuthService registers and revokes sessions in the authentication flow
  • SessionService queries and revokes sessions in the management flow
  • Both share the same session store, but with different responsibilities

Key Capabilities​

MethodDescription
ListPagePaginated query of online sessions, with fuzzy filtering by username and IP
RevokeRevoke a single online session by token ID, kicking the user out

Design Constraints​

  • Sessions are read-only projections. The Session struct is read-only; modifying it does not change session state. Use Revoke to terminate a session.
  • Paginated queries are scoped by tenant. Platform administrators can query sessions across all tenants; tenant administrators can only query sessions within their own tenant.
  • Revocation takes effect immediately. After Revoke is executed, the corresponding token is invalidated instantly, and the client's next request will be rejected.
  • DeptName is a projection field. The department name is projected from the organization capability provider; if the organization capability is unavailable, this field may be empty.
  • AuthService - AuthService registers sessions in the authentication flow; SessionService queries sessions in the management flow
  • BizCtxService - Current request session information is projected into BizCtx
  • OrgService - The DeptName field in Session is projected from the organization capability