Documentation
¶
Index ¶
- func FormatExpiresIn(t time.Time) string
- func FormatRelativeTime(t time.Time) string
- func IsSessionActive(expiresAt time.Time) bool
- func IsSessionExpiringSoon(expiresAt time.Time, within time.Duration) bool
- type Config
- type DashboardExtension
- func (e *DashboardExtension) DashboardWidgets() []ui.DashboardWidget
- func (e *DashboardExtension) ExtensionID() string
- func (e *DashboardExtension) NavigationItems() []ui.NavigationItem
- func (e *DashboardExtension) RenderDashboardWidget(basePath string, currentApp *app.App) g.Node
- func (e *DashboardExtension) RevokeAllUserSessions(c forge.Context) error
- func (e *DashboardExtension) RevokeSession(c forge.Context) error
- func (e *DashboardExtension) Routes() []ui.Route
- func (e *DashboardExtension) SaveSettings(c forge.Context) error
- func (e *DashboardExtension) ServeMultiSessionPage(c forge.Context) error
- func (e *DashboardExtension) ServeSessionDetailPage(c forge.Context) error
- func (e *DashboardExtension) ServeSettings(c forge.Context) error
- func (e *DashboardExtension) ServeUserSessionsPage(c forge.Context) error
- func (e *DashboardExtension) SetRegistry(registry *dashboard.ExtensionRegistry)
- func (e *DashboardExtension) SettingsPages() []ui.SettingsPage
- func (e *DashboardExtension) SettingsSections() []ui.SettingsSection
- type DeviceInfo
- type ErrorResponse
- type Handler
- type MessageResponse
- type MultiSessionDeleteResponse
- type MultiSessionErrorResponse
- type MultiSessionListResponse
- type MultiSessionSetActiveResponse
- type Plugin
- func (p *Plugin) DashboardExtension() ui.DashboardExtension
- func (p *Plugin) GetAuthService() *auth.Service
- func (p *Plugin) ID() string
- func (p *Plugin) Init(authInst core.Authsome) error
- func (p *Plugin) Migrate() error
- func (p *Plugin) RegisterHooks(_ *hooks.HookRegistry) error
- func (p *Plugin) RegisterRoutes(router forge.Router) error
- func (p *Plugin) RegisterServiceDecorators(_ *registry.ServiceRegistry) error
- type PluginOption
- type Service
- func (s *Service) CurrentUserFromToken(ctx context.Context, token string) (xid.ID, error)
- func (s *Service) Delete(ctx context.Context, userID, id xid.ID) error
- func (s *Service) Find(ctx context.Context, userID xid.ID, id xid.ID) (*session.Session, error)
- func (s *Service) List(ctx context.Context, userID xid.ID) (*session.ListSessionsResponse, error)
- type SessionTokenResponse
- type SessionsResponse
- type StatusResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatExpiresIn ¶ added in v0.0.3
FormatExpiresIn formats time until expiration
func FormatRelativeTime ¶ added in v0.0.3
FormatRelativeTime formats a time as relative time (e.g., "2 hours ago")
func IsSessionActive ¶ added in v0.0.3
IsSessionActive checks if a session is currently active
Types ¶
type Config ¶
type Config struct {
// MaxSessionsPerUser is the maximum concurrent sessions per user
MaxSessionsPerUser int `json:"maxSessionsPerUser"`
// EnableDeviceTracking enables device fingerprinting
EnableDeviceTracking bool `json:"enableDeviceTracking"`
// SessionExpiry is the session expiry time in hours
SessionExpiryHours int `json:"sessionExpiryHours"`
// AllowCrossPlatform allows sessions across different platforms
AllowCrossPlatform bool `json:"allowCrossPlatform"`
}
Config holds the multisession plugin configuration
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns the default multisession plugin configuration
type DashboardExtension ¶
type DashboardExtension struct {
// contains filtered or unexported fields
}
DashboardExtension implements the ui.DashboardExtension interface This allows the multisession plugin to add its own screens to the dashboard
func NewDashboardExtension ¶
func NewDashboardExtension(plugin *Plugin) *DashboardExtension
NewDashboardExtension creates a new dashboard extension for multisession
func (*DashboardExtension) DashboardWidgets ¶
func (e *DashboardExtension) DashboardWidgets() []ui.DashboardWidget
DashboardWidgets returns widgets to show on the main dashboard
func (*DashboardExtension) ExtensionID ¶
func (e *DashboardExtension) ExtensionID() string
ExtensionID returns the unique identifier for this extension
func (*DashboardExtension) NavigationItems ¶
func (e *DashboardExtension) NavigationItems() []ui.NavigationItem
NavigationItems returns navigation items to register
func (*DashboardExtension) RenderDashboardWidget ¶
RenderDashboardWidget renders the dashboard widget showing session stats
func (*DashboardExtension) RevokeAllUserSessions ¶
func (e *DashboardExtension) RevokeAllUserSessions(c forge.Context) error
RevokeAllUserSessions handles revoking all sessions for a user
func (*DashboardExtension) RevokeSession ¶
func (e *DashboardExtension) RevokeSession(c forge.Context) error
RevokeSession handles session revocation
func (*DashboardExtension) Routes ¶
func (e *DashboardExtension) Routes() []ui.Route
Routes returns routes to register under /dashboard/app/:appId/
func (*DashboardExtension) SaveSettings ¶
func (e *DashboardExtension) SaveSettings(c forge.Context) error
SaveSettings handles saving multisession settings
func (*DashboardExtension) ServeMultiSessionPage ¶
func (e *DashboardExtension) ServeMultiSessionPage(c forge.Context) error
ServeMultiSessionPage renders the multi-session management page with dashboard layout
func (*DashboardExtension) ServeSessionDetailPage ¶ added in v0.0.3
func (e *DashboardExtension) ServeSessionDetailPage(c forge.Context) error
ServeSessionDetailPage renders detailed information about a single session
func (*DashboardExtension) ServeSettings ¶
func (e *DashboardExtension) ServeSettings(c forge.Context) error
ServeSettings renders the multisession settings page
func (*DashboardExtension) ServeUserSessionsPage ¶ added in v0.0.3
func (e *DashboardExtension) ServeUserSessionsPage(c forge.Context) error
ServeUserSessionsPage renders all sessions for a specific user
func (*DashboardExtension) SetRegistry ¶
func (e *DashboardExtension) SetRegistry(registry *dashboard.ExtensionRegistry)
SetRegistry sets the extension registry reference (called by dashboard after registration)
func (*DashboardExtension) SettingsPages ¶
func (e *DashboardExtension) SettingsPages() []ui.SettingsPage
SettingsPages returns full settings pages for the new sidebar layout
func (*DashboardExtension) SettingsSections ¶
func (e *DashboardExtension) SettingsSections() []ui.SettingsSection
SettingsSections returns settings sections to add to the settings page Deprecated: Use SettingsPages() instead
type DeviceInfo ¶ added in v0.0.3
type DeviceInfo struct {
DeviceType string // Desktop, Mobile, Tablet, Bot, Unknown
OS string // Windows, macOS, Linux, iOS, Android, ChromeOS, etc.
OSVersion string // OS version if available
Browser string // Chrome, Firefox, Safari, Edge, etc.
BrowserVer string // Browser version if available
IsMobile bool
IsTablet bool
IsDesktop bool
IsBot bool
}
DeviceInfo contains parsed device information from user agent
func ParseUserAgent ¶ added in v0.0.3
func ParseUserAgent(ua string) *DeviceInfo
ParseUserAgent parses a user agent string and extracts device information
func (*DeviceInfo) FormatDeviceInfo ¶ added in v0.0.3
func (d *DeviceInfo) FormatDeviceInfo() string
FormatDeviceInfo returns a human-readable device string
func (*DeviceInfo) ShortDeviceInfo ¶ added in v0.0.3
func (d *DeviceInfo) ShortDeviceInfo() string
ShortDeviceInfo returns a compact device string
type ErrorResponse ¶
type ErrorResponse = responses.ErrorResponse
Response types - use shared responses from core
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func NewHandler ¶
type MessageResponse ¶
type MessageResponse = responses.MessageResponse
type MultiSessionDeleteResponse ¶
type MultiSessionDeleteResponse struct {
Status string `json:"status" example:"deleted"`
}
type MultiSessionErrorResponse ¶
type MultiSessionErrorResponse struct {
Error string `json:"error" example:"Error message"`
}
Response types for multi-session routes
type MultiSessionListResponse ¶
type MultiSessionListResponse struct {
Sessions []interface{} `json:"sessions"`
}
type MultiSessionSetActiveResponse ¶
type MultiSessionSetActiveResponse struct {
Session interface{} `json:"session"`
Token string `json:"token" example:"session_token_abc123"`
}
type Plugin ¶
type Plugin struct {
// contains filtered or unexported fields
}
Plugin wires the multi-session service and registers routes
func NewPlugin ¶
func NewPlugin(opts ...PluginOption) *Plugin
NewPlugin creates a new multisession plugin instance with optional configuration
func (*Plugin) DashboardExtension ¶
func (p *Plugin) DashboardExtension() ui.DashboardExtension
DashboardExtension implements the PluginWithDashboardExtension interface This allows the multisession plugin to extend the dashboard with custom screens
func (*Plugin) GetAuthService ¶
GetAuthService returns the auth service for testing
func (*Plugin) RegisterHooks ¶
func (p *Plugin) RegisterHooks(_ *hooks.HookRegistry) error
func (*Plugin) RegisterRoutes ¶
RegisterRoutes mounts endpoints under /api/auth/multi-session
func (*Plugin) RegisterServiceDecorators ¶
func (p *Plugin) RegisterServiceDecorators(_ *registry.ServiceRegistry) error
type PluginOption ¶
type PluginOption func(*Plugin)
PluginOption is a functional option for configuring the multisession plugin
func WithAllowCrossPlatform ¶
func WithAllowCrossPlatform(allow bool) PluginOption
WithAllowCrossPlatform sets whether cross-platform sessions are allowed
func WithDefaultConfig ¶
func WithDefaultConfig(cfg Config) PluginOption
WithDefaultConfig sets the default configuration for the plugin
func WithEnableDeviceTracking ¶
func WithEnableDeviceTracking(enable bool) PluginOption
WithEnableDeviceTracking sets whether device tracking is enabled
func WithMaxSessionsPerUser ¶
func WithMaxSessionsPerUser(max int) PluginOption
WithMaxSessionsPerUser sets the maximum concurrent sessions per user
func WithSessionExpiryHours ¶
func WithSessionExpiryHours(hours int) PluginOption
WithSessionExpiryHours sets the session expiry time
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides multi-session operations
func NewService ¶
func NewService(sr session.Repository, sessionSvc session.ServiceInterface, dr dev.Repository, a *auth.Service, _ interface{}) *Service
func (*Service) CurrentUserFromToken ¶
CurrentUserFromToken validates token and returns userID
type SessionTokenResponse ¶
type SessionTokenResponse struct {
Session interface{} `json:"session"`
Token string `json:"token"`
}
type SessionsResponse ¶
type SessionsResponse struct {
Sessions interface{} `json:"sessions"`
}
type StatusResponse ¶
type StatusResponse = responses.StatusResponse