Documentation
¶
Index ¶
- Variables
- func EnsureFirstUserIsAdmin(ctx context.Context, userID, orgID xid.ID, ...) error
- func EnsureFirstUserIsSuperAdmin(ctx context.Context, userID, orgID xid.ID, ...) error
- func RegisterDashboardRoles(registry *rbac.RoleRegistry) error
- func RenderNavigationItems(items []ui.NavigationItem, basePath string, currentApp *app.App, ...) []g.Node
- func SetupDefaultPolicies(rbacSvc *rbac.Service) error
- type ActivityItem
- type CSRFProtector
- func (c *CSRFProtector) CleanupExpiredTokens()
- func (c *CSRFProtector) GenerateToken(sessionID string) (string, error)
- func (c *CSRFProtector) InvalidateToken(token string)
- func (c *CSRFProtector) RotateSecret() error
- func (c *CSRFProtector) Stats() map[string]interface{}
- func (c *CSRFProtector) ValidateToken(token, sessionID string) bool
- type Config
- type DashboardError
- type DashboardErrorResponse
- type DashboardHTMLResponse
- type DashboardLoginResponse
- type DashboardPermissions
- func (d *DashboardPermissions) CanAccess() bool
- func (d *DashboardPermissions) CanManageSessions() bool
- func (d *DashboardPermissions) CanManageUsers() bool
- func (d *DashboardPermissions) CanViewAuditLogs() bool
- func (d *DashboardPermissions) CanViewSessions() bool
- func (d *DashboardPermissions) CanViewUsers() bool
- type DashboardPingResponse
- type DashboardStaticResponse
- type DashboardStats
- type DashboardStatusResponse
- type ErrorResponse
- type ExtensionRegistry
- func (r *ExtensionRegistry) Get(id string) (ui.DashboardExtension, bool)
- func (r *ExtensionRegistry) GetAllRoutes() []ui.Route
- func (r *ExtensionRegistry) GetDashboardWidgets() []ui.DashboardWidget
- func (r *ExtensionRegistry) GetHandler() *Handler
- func (r *ExtensionRegistry) GetNavigationItems(position ui.NavigationPosition, enabledPlugins map[string]bool) []ui.NavigationItem
- func (r *ExtensionRegistry) GetSettingsPages(enabledPlugins map[string]bool) []ui.SettingsPage
- func (r *ExtensionRegistry) GetSettingsSections() []ui.SettingsSection
- func (r *ExtensionRegistry) List() []ui.DashboardExtension
- func (r *ExtensionRegistry) Register(ext ui.DashboardExtension) error
- func (r *ExtensionRegistry) SetHandler(h *Handler)
- type Handler
- func (h *Handler) GetBasePath() string
- func (h *Handler) GetCSRFToken(c forge.Context) string
- func (h *Handler) GetCurrentApp(c forge.Context) (*app.App, error)
- func (h *Handler) GetCurrentEnvironment(c forge.Context, appID xid.ID) (*environment.Environment, error)
- func (h *Handler) GetEnabledPlugins() map[string]bool
- func (h *Handler) GetUserApps(c forge.Context, userID xid.ID) ([]*app.App, error)
- func (h *Handler) GetUserEnvironments(c forge.Context, appID xid.ID) ([]*environment.Environment, error)
- func (h *Handler) GetUserFromContext(c forge.Context) *user.User
- func (h *Handler) HandleAppMgmtCreate(c forge.Context) error
- func (h *Handler) HandleAppMgmtDelete(c forge.Context) error
- func (h *Handler) HandleAppMgmtEdit(c forge.Context) error
- func (h *Handler) HandleEnvironmentCreate(c forge.Context) error
- func (h *Handler) HandleEnvironmentDelete(c forge.Context) error
- func (h *Handler) HandleEnvironmentEdit(c forge.Context) error
- func (h *Handler) HandleEnvironmentSwitch(c forge.Context) error
- func (h *Handler) HandleLogin(c forge.Context) error
- func (h *Handler) HandleLogout(c forge.Context) error
- func (h *Handler) HandleOrganizationCreate(c forge.Context) error
- func (h *Handler) HandleOrganizationDelete(c forge.Context) error
- func (h *Handler) HandleOrganizationEdit(c forge.Context) error
- func (h *Handler) HandleRevokeSession(c forge.Context) error
- func (h *Handler) HandleRevokeUserSessions(c forge.Context) error
- func (h *Handler) HandleSignup(c forge.Context) error
- func (h *Handler) HandleUserDelete(c forge.Context) error
- func (h *Handler) HandleUserEdit(c forge.Context) error
- func (h *Handler) RenderSettingsPage(c forge.Context, pageID string, content g.Node) error
- func (h *Handler) RenderWithBaseLayout(c forge.Context, pageData components.PageData, content g.Node) error
- func (h *Handler) RenderWithHeaderLayout(c forge.Context, pageData components.PageData, content g.Node) error
- func (h *Handler) RenderWithLayout(c forge.Context, pageData components.PageData, content g.Node) error
- func (h *Handler) RenderWithSidebarLayout(c forge.Context, pageData components.PageData, content g.Node) error
- func (h *Handler) Serve404(c forge.Context) error
- func (h *Handler) ServeAppMgmtCreate(c forge.Context) error
- func (h *Handler) ServeAppMgmtDetail(c forge.Context) error
- func (h *Handler) ServeAppMgmtEdit(c forge.Context) error
- func (h *Handler) ServeAppsList(c forge.Context) error
- func (h *Handler) ServeConfigViewer(c forge.Context) error
- func (h *Handler) ServeDashboard(c forge.Context) error
- func (h *Handler) ServeEnvironmentCreate(c forge.Context) error
- func (h *Handler) ServeEnvironmentDetail(c forge.Context) error
- func (h *Handler) ServeEnvironmentEdit(c forge.Context) error
- func (h *Handler) ServeEnvironments(c forge.Context) error
- func (h *Handler) ServeLogin(c forge.Context) error
- func (h *Handler) ServeOrganizationCreate(c forge.Context) error
- func (h *Handler) ServeOrganizationDetail(c forge.Context) error
- func (h *Handler) ServeOrganizationEdit(c forge.Context) error
- func (h *Handler) ServeOrganizations(c forge.Context) error
- func (h *Handler) ServePlugins(c forge.Context) error
- func (h *Handler) ServeSessions(c forge.Context) error
- func (h *Handler) ServeSettings(c forge.Context) error
- func (h *Handler) ServeSettingsGeneral(c forge.Context) error
- func (h *Handler) ServeSignup(c forge.Context) error
- func (h *Handler) ServeStatic(c forge.Context) error
- func (h *Handler) ServeUserDetail(c forge.Context) error
- func (h *Handler) ServeUserEdit(c forge.Context) error
- func (h *Handler) ServeUsers(c forge.Context) error
- type MessageResponse
- type PageData
- type Permission
- type PermissionBuilder
- func (b *PermissionBuilder) Can(action, resource string) bool
- func (b *PermissionBuilder) CanCreate(resource string) bool
- func (b *PermissionBuilder) CanDelete(resource string) bool
- func (b *PermissionBuilder) CanEdit(resource string) bool
- func (b *PermissionBuilder) CanView(resource string) bool
- func (b *PermissionBuilder) Dashboard() *DashboardPermissions
- func (b *PermissionBuilder) HasRole(roleName string) bool
- func (b *PermissionBuilder) IsAdmin() bool
- func (b *PermissionBuilder) IsOwner() bool
- func (b *PermissionBuilder) IsSuperAdmin() bool
- type PermissionChecker
- func (p *PermissionChecker) Can(ctx context.Context, userID xid.ID, action, resource string) bool
- func (p *PermissionChecker) CanAll(ctx context.Context, userID xid.ID, permissions ...Permission) bool
- func (p *PermissionChecker) CanAny(ctx context.Context, userID xid.ID, permissions ...Permission) bool
- func (p *PermissionChecker) For(ctx context.Context, userID xid.ID) *PermissionBuilder
- func (p *PermissionChecker) HasAnyRole(ctx context.Context, userID xid.ID, roleNames ...string) bool
- func (p *PermissionChecker) HasRole(ctx context.Context, userID xid.ID, roleName string) bool
- func (p *PermissionChecker) InvalidateUserCache(userID xid.ID)
- type Plugin
- func (p *Plugin) AppContext() func(func(forge.Context) error) func(forge.Context) error
- func (p *Plugin) AuditLog() func(func(forge.Context) error) func(forge.Context) error
- func (p *Plugin) CSRF() func(func(forge.Context) error) func(forge.Context) error
- func (p *Plugin) Dependencies() []string
- func (p *Plugin) EnvironmentContext() func(func(forge.Context) error) func(forge.Context) error
- func (p *Plugin) ID() string
- func (p *Plugin) Init(authInstance core.Authsome) error
- func (p *Plugin) Migrate() error
- func (p *Plugin) PlatformOrgContext() func(func(forge.Context) error) func(forge.Context) error
- func (p *Plugin) RateLimit() func(func(forge.Context) error) func(forge.Context) error
- func (p *Plugin) RegisterHooks(hooks *hooks.HookRegistry) error
- func (p *Plugin) RegisterRoles(registry interface{}) error
- func (p *Plugin) RegisterRoutes(router forge.Router) error
- func (p *Plugin) RegisterServiceDecorators(services *registry.ServiceRegistry) error
- func (p *Plugin) RequireAdmin() func(func(forge.Context) error) func(forge.Context) error
- func (p *Plugin) RequireAuth() func(func(forge.Context) error) func(forge.Context) error
- type PluginItem
- type PluginOption
- func WithDefaultConfig(cfg Config) PluginOption
- func WithDefaultTheme(theme string) PluginOption
- func WithEnableSignup(enabled bool) PluginOption
- func WithLockoutDuration(minutes int) PluginOption
- func WithMaxLoginAttempts(max int) PluginOption
- func WithRequireEmailVerification(required bool) PluginOption
- func WithSessionDuration(hours int) PluginOption
- type StatusItem
- type StatusResponse
- type SuccessResponse
Constants ¶
This section is empty.
Variables ¶
var ( // ErrExtensionAlreadyRegistered indicates an extension with the same ID is already registered ErrExtensionAlreadyRegistered = &DashboardError{ Code: "extension_already_registered", Message: "dashboard extension already registered", } )
Functions ¶
func EnsureFirstUserIsAdmin ¶
func EnsureFirstUserIsAdmin(ctx context.Context, userID, orgID xid.ID, userRoleRepo rbac.UserRoleRepository, roleRepo rbac.RoleRepository) error
EnsureFirstUserIsAdmin assigns admin role to the first user DEPRECATED: Use EnsureFirstUserIsSuperAdmin for first user setup
func EnsureFirstUserIsSuperAdmin ¶
func EnsureFirstUserIsSuperAdmin(ctx context.Context, userID, orgID xid.ID, userRoleRepo rbac.UserRoleRepository, roleRepo rbac.RoleRepository) error
EnsureFirstUserIsSuperAdmin assigns superadmin role to the first user This makes them the platform owner with full system access
func RegisterDashboardRoles ¶
func RegisterDashboardRoles(registry *rbac.RoleRegistry) error
RegisterDashboardRoles registers dashboard-specific roles in the RoleRegistry This extends the default platform roles with dashboard-specific permissions Supports override semantics - plugins can modify other plugins' roles
func RenderNavigationItems ¶
func RenderNavigationItems(items []ui.NavigationItem, basePath string, currentApp *app.App, activePage string) []g.Node
RenderNavigationItems renders navigation items as gomponents nodes
func SetupDefaultPolicies ¶
SetupDefaultPolicies creates default RBAC policies for the dashboard Role hierarchy: superadmin > owner > admin > member This is kept for backward compatibility and immediate policy loading The role bootstrap system will persist these roles to the database
Types ¶
type ActivityItem ¶
type ActivityItem struct {
Title string
Description string
Time string
Type string // success, warning, error, info
}
ActivityItem represents a recent activity entry
type CSRFProtector ¶
type CSRFProtector struct {
// contains filtered or unexported fields
}
CSRFProtector provides production-grade CSRF protection
func NewCSRFProtector ¶
func NewCSRFProtector() (*CSRFProtector, error)
NewCSRFProtector creates a new CSRF protector with a random secret
func (*CSRFProtector) CleanupExpiredTokens ¶
func (c *CSRFProtector) CleanupExpiredTokens()
CleanupExpiredTokens manually triggers cleanup of expired tokens
func (*CSRFProtector) GenerateToken ¶
func (c *CSRFProtector) GenerateToken(sessionID string) (string, error)
GenerateToken generates a new CSRF token for a session Format: base64(randomBytes) + "." + base64(hmac(randomBytes + sessionID))
func (*CSRFProtector) InvalidateToken ¶
func (c *CSRFProtector) InvalidateToken(token string)
InvalidateToken removes a token from the store
func (*CSRFProtector) RotateSecret ¶
func (c *CSRFProtector) RotateSecret() error
RotateSecret generates a new CSRF secret Should be called periodically for enhanced security
func (*CSRFProtector) Stats ¶
func (c *CSRFProtector) Stats() map[string]interface{}
Stats returns statistics about the CSRF token store
func (*CSRFProtector) ValidateToken ¶
func (c *CSRFProtector) ValidateToken(token, sessionID string) bool
ValidateToken validates a CSRF token against a session
type Config ¶
type Config struct {
// EnableSignup allows new users to sign up for dashboard access
EnableSignup bool `json:"enableSignup"`
// RequireEmailVerification requires email verification for new signups
RequireEmailVerification bool `json:"requireEmailVerification"`
// SessionDuration sets the duration for dashboard sessions in hours
SessionDuration int `json:"sessionDuration"`
// MaxLoginAttempts sets the maximum login attempts before lockout
MaxLoginAttempts int `json:"maxLoginAttempts"`
// LockoutDuration sets the lockout duration in minutes
LockoutDuration int `json:"lockoutDuration"`
// DefaultTheme sets the default theme (light, dark, auto)
DefaultTheme string `json:"defaultTheme"`
}
Config holds the dashboard plugin configuration
type DashboardError ¶
DashboardError represents a dashboard-specific error
func (*DashboardError) Error ¶
func (e *DashboardError) Error() string
type DashboardErrorResponse ¶
type DashboardErrorResponse struct {
Error string `json:"error" example:"Error message"`
}
DTOs for dashboard routes
type DashboardHTMLResponse ¶
type DashboardHTMLResponse struct {
HTML string `json:"html" example:"<html>...</html>"`
}
type DashboardLoginResponse ¶
type DashboardLoginResponse struct {
RedirectURL string `json:"redirect_url" example:"/dashboard/"`
}
type DashboardPermissions ¶
type DashboardPermissions struct {
*PermissionBuilder
}
DashboardPermissions provides dashboard-specific permission checks
func (*DashboardPermissions) CanAccess ¶
func (d *DashboardPermissions) CanAccess() bool
CanAccess checks if user can access the dashboard
func (*DashboardPermissions) CanManageSessions ¶
func (d *DashboardPermissions) CanManageSessions() bool
CanManageSessions checks if user can manage sessions
func (*DashboardPermissions) CanManageUsers ¶
func (d *DashboardPermissions) CanManageUsers() bool
CanManageUsers checks if user can manage users
func (*DashboardPermissions) CanViewAuditLogs ¶
func (d *DashboardPermissions) CanViewAuditLogs() bool
CanViewAuditLogs checks if user can view audit logs
func (*DashboardPermissions) CanViewSessions ¶
func (d *DashboardPermissions) CanViewSessions() bool
CanViewSessions checks if user can view sessions
func (*DashboardPermissions) CanViewUsers ¶
func (d *DashboardPermissions) CanViewUsers() bool
CanViewUsers checks if user can view users
type DashboardPingResponse ¶
type DashboardPingResponse struct {
Message string `json:"message" example:"Dashboard plugin is working!"`
}
type DashboardStaticResponse ¶
type DashboardStats ¶
type DashboardStats struct {
TotalUsers int
ActiveUsers int
NewUsersToday int
TotalSessions int
ActiveSessions int
FailedLogins int
UserGrowth float64
SessionGrowth float64
RecentActivity []ActivityItem
SystemStatus []StatusItem
Plugins []PluginItem
}
DashboardStats represents statistics for the dashboard
type DashboardStatusResponse ¶
type DashboardStatusResponse struct {
Status string `json:"status" example:"success"`
}
type ErrorResponse ¶
type ErrorResponse = responses.ErrorResponse
Response types - use shared responses from core
type ExtensionRegistry ¶
type ExtensionRegistry struct {
// contains filtered or unexported fields
}
ExtensionRegistry manages dashboard extensions from plugins
func NewExtensionRegistry ¶
func NewExtensionRegistry() *ExtensionRegistry
NewExtensionRegistry creates a new extension registry
func (*ExtensionRegistry) Get ¶
func (r *ExtensionRegistry) Get(id string) (ui.DashboardExtension, bool)
Get retrieves an extension by ID
func (*ExtensionRegistry) GetAllRoutes ¶
func (r *ExtensionRegistry) GetAllRoutes() []ui.Route
GetAllRoutes returns all routes from all extensions
func (*ExtensionRegistry) GetDashboardWidgets ¶
func (r *ExtensionRegistry) GetDashboardWidgets() []ui.DashboardWidget
GetDashboardWidgets returns all dashboard widgets sorted by order
func (*ExtensionRegistry) GetHandler ¶
func (r *ExtensionRegistry) GetHandler() *Handler
GetHandler returns the handler instance for extensions to use Extensions can use this to access renderWithLayout and other helpers
func (*ExtensionRegistry) GetNavigationItems ¶
func (r *ExtensionRegistry) GetNavigationItems(position ui.NavigationPosition, enabledPlugins map[string]bool) []ui.NavigationItem
GetNavigationItems returns all navigation items for a specific position
func (*ExtensionRegistry) GetSettingsPages ¶
func (r *ExtensionRegistry) GetSettingsPages(enabledPlugins map[string]bool) []ui.SettingsPage
GetSettingsPages returns all settings pages from extensions
func (*ExtensionRegistry) GetSettingsSections ¶
func (r *ExtensionRegistry) GetSettingsSections() []ui.SettingsSection
GetSettingsSections returns all settings sections sorted by order Deprecated: Use GetSettingsPages for the new sidebar layout
func (*ExtensionRegistry) List ¶
func (r *ExtensionRegistry) List() []ui.DashboardExtension
List returns all registered extensions
func (*ExtensionRegistry) Register ¶
func (r *ExtensionRegistry) Register(ext ui.DashboardExtension) error
Register registers a dashboard extension
func (*ExtensionRegistry) SetHandler ¶
func (r *ExtensionRegistry) SetHandler(h *Handler)
SetHandler sets the handler instance (called by dashboard plugin during init)
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler handles dashboard HTTP requests
func NewHandler ¶
func NewHandler( assets embed.FS, appService app.Service, userSvc user.ServiceInterface, sessionSvc session.ServiceInterface, auditSvc *audit.Service, rbacSvc *rbac.Service, apikeyService *apikey.Service, orgService *organization.Service, envService environment.EnvironmentService, db *bun.DB, isMultiApp bool, basePath string, enabledPlugins map[string]bool, hookRegistry *hooks.HookRegistry, configManager forge.ConfigManager, ) *Handler
NewHandler creates a new dashboard handler
func (*Handler) GetBasePath ¶
GetBasePath returns the dashboard base path
func (*Handler) GetCSRFToken ¶
GetCSRFToken returns the CSRF token for the request
func (*Handler) GetCurrentApp ¶
GetCurrentApp extracts and returns the current app from URL parameter This handles parsing the appId param and fetching the app
func (*Handler) GetCurrentEnvironment ¶
func (h *Handler) GetCurrentEnvironment(c forge.Context, appID xid.ID) (*environment.Environment, error)
GetCurrentEnvironment returns the current environment from cookie or default
func (*Handler) GetEnabledPlugins ¶
GetEnabledPlugins returns map of enabled plugins
func (*Handler) GetUserApps ¶
GetUserApps returns all apps the user has access to
func (*Handler) GetUserEnvironments ¶
func (h *Handler) GetUserEnvironments(c forge.Context, appID xid.ID) ([]*environment.Environment, error)
GetUserEnvironments returns all environments for the given app
func (*Handler) GetUserFromContext ¶
GetUserFromContext returns the authenticated user from request context Extensions should use this instead of c.Get("user")
func (*Handler) HandleAppMgmtCreate ¶
HandleAppMgmtCreate processes app creation
func (*Handler) HandleAppMgmtDelete ¶
HandleAppMgmtDelete processes app deletion
func (*Handler) HandleAppMgmtEdit ¶
HandleAppMgmtEdit processes app update
func (*Handler) HandleEnvironmentCreate ¶
HandleEnvironmentCreate processes environment creation
func (*Handler) HandleEnvironmentDelete ¶
HandleEnvironmentDelete processes environment deletion
func (*Handler) HandleEnvironmentEdit ¶
HandleEnvironmentEdit processes environment update
func (*Handler) HandleEnvironmentSwitch ¶
HandleEnvironmentSwitch switches the current environment
func (*Handler) HandleLogin ¶
HandleLogin processes the login form
func (*Handler) HandleLogout ¶
HandleLogout processes the logout request
func (*Handler) HandleOrganizationCreate ¶
HandleOrganizationCreate processes organization creation
func (*Handler) HandleOrganizationDelete ¶
HandleOrganizationDelete processes organization deletion
func (*Handler) HandleOrganizationEdit ¶
HandleOrganizationEdit processes organization update
func (*Handler) HandleRevokeSession ¶
HandleRevokeSession revokes a single session
func (*Handler) HandleRevokeUserSessions ¶
HandleRevokeUserSessions revokes all sessions for a specific user
func (*Handler) HandleSignup ¶
HandleSignup processes the signup form
func (*Handler) HandleUserDelete ¶
HandleUserDelete deletes a user
func (*Handler) HandleUserEdit ¶
HandleUserEdit processes the user edit form
func (*Handler) RenderSettingsPage ¶
RenderSettingsPage renders content within the settings layout with sidebar navigation Extensions should use this to render their settings pages instead of RenderWithLayout The pageID should match the ID in the SettingsPage definition
func (*Handler) RenderWithBaseLayout ¶ added in v0.0.3
func (h *Handler) RenderWithBaseLayout(c forge.Context, pageData components.PageData, content g.Node) error
renderWithLayout renders content within the base layout RenderWithLayout renders content with the dashboard layout (public for extensions) This method automatically populates app, environment, and extension data
func (*Handler) RenderWithHeaderLayout ¶ added in v0.0.3
func (h *Handler) RenderWithHeaderLayout(c forge.Context, pageData components.PageData, content g.Node) error
renderWithLayout renders content within the base layout RenderWithLayout renders content with the dashboard layout (public for extensions) This method automatically populates app, environment, and extension data
func (*Handler) RenderWithLayout ¶
func (h *Handler) RenderWithLayout(c forge.Context, pageData components.PageData, content g.Node) error
renderWithLayout renders content within the base layout RenderWithLayout renders content with the dashboard layout (public for extensions) This method automatically populates app, environment, and extension data
func (*Handler) RenderWithSidebarLayout ¶ added in v0.0.3
func (h *Handler) RenderWithSidebarLayout(c forge.Context, pageData components.PageData, content g.Node) error
renderWithLayout renders content within the base layout RenderWithLayout renders content with the dashboard layout (public for extensions) This method automatically populates app, environment, and extension data
func (*Handler) ServeAppMgmtCreate ¶
ServeAppMgmtCreate renders the app creation form
func (*Handler) ServeAppMgmtDetail ¶
ServeAppMgmtDetail renders the app management detail page
func (*Handler) ServeAppMgmtEdit ¶
ServeAppMgmtEdit renders the app edit form
func (*Handler) ServeAppsList ¶
ServeAppsList serves the dashboard index page - shows app cards or redirects to default app
func (*Handler) ServeConfigViewer ¶ added in v0.0.9
ServeConfigViewer serves the configuration viewer page This page displays all configuration values from Forge ConfigManager as YAML
func (*Handler) ServeDashboard ¶
ServeDashboard serves the main dashboard page
func (*Handler) ServeEnvironmentCreate ¶
ServeEnvironmentCreate renders the create environment page
func (*Handler) ServeEnvironmentDetail ¶
ServeEnvironmentDetail renders the environment detail page
func (*Handler) ServeEnvironmentEdit ¶
ServeEnvironmentEdit renders the edit environment page
func (*Handler) ServeEnvironments ¶
ServeEnvironments renders the environments list page
func (*Handler) ServeLogin ¶
ServeLogin serves the login page
func (*Handler) ServeOrganizationCreate ¶
ServeOrganizationCreate renders the organization creation form
func (*Handler) ServeOrganizationDetail ¶
ServeOrganizationDetail renders the organization detail page
func (*Handler) ServeOrganizationEdit ¶
ServeOrganizationEdit renders the organization edit form
func (*Handler) ServeOrganizations ¶
ServeOrganizations renders the organizations list page
func (*Handler) ServePlugins ¶
ServePlugins serves the plugins management page
func (*Handler) ServeSessions ¶
ServeSessions serves the sessions list page
func (*Handler) ServeSettings ¶
ServeSettings serves the settings page
func (*Handler) ServeSettingsGeneral ¶
ServeSettingsGeneral handles the general settings page
func (*Handler) ServeSignup ¶
ServeSignup serves the signup page
func (*Handler) ServeStatic ¶
ServeStatic serves static assets (CSS, JS, images)
func (*Handler) ServeUserDetail ¶
ServeUserDetail serves a single user detail page
func (*Handler) ServeUserEdit ¶
ServeUserEdit serves the user edit page
type MessageResponse ¶
type MessageResponse = responses.MessageResponse
type PageData ¶
type PageData struct {
Title string
User *user.User
CSRFToken string
ActivePage string
BasePath string
Data interface{}
Error string
Success string
Year int
EnabledPlugins map[string]bool
}
PageData represents common data for all pages
type Permission ¶
type Permission struct {
Action string // e.g., "view", "edit", "delete"
Resource string // e.g., "dashboard", "users", "sessions"
}
Permission represents a fine-grained permission check
type PermissionBuilder ¶
type PermissionBuilder struct {
// contains filtered or unexported fields
}
PermissionBuilder provides a fluent API for building permission checks
func (*PermissionBuilder) Can ¶
func (b *PermissionBuilder) Can(action, resource string) bool
Can checks a single permission
func (*PermissionBuilder) CanCreate ¶
func (b *PermissionBuilder) CanCreate(resource string) bool
CanCreate is a shorthand for Can("create", resource)
func (*PermissionBuilder) CanDelete ¶
func (b *PermissionBuilder) CanDelete(resource string) bool
CanDelete is a shorthand for Can("delete", resource)
func (*PermissionBuilder) CanEdit ¶
func (b *PermissionBuilder) CanEdit(resource string) bool
CanEdit is a shorthand for Can("edit", resource)
func (*PermissionBuilder) CanView ¶
func (b *PermissionBuilder) CanView(resource string) bool
CanView is a shorthand for Can("view", resource)
func (*PermissionBuilder) Dashboard ¶
func (b *PermissionBuilder) Dashboard() *DashboardPermissions
Dashboard returns a dashboard-specific permission checker
func (*PermissionBuilder) HasRole ¶
func (b *PermissionBuilder) HasRole(roleName string) bool
HasRole checks if the user has a specific role
func (*PermissionBuilder) IsAdmin ¶
func (b *PermissionBuilder) IsAdmin() bool
IsAdmin checks if the user has the admin role
func (*PermissionBuilder) IsOwner ¶
func (b *PermissionBuilder) IsOwner() bool
IsOwner checks if the user has the owner role
func (*PermissionBuilder) IsSuperAdmin ¶
func (b *PermissionBuilder) IsSuperAdmin() bool
IsSuperAdmin checks if the user has the superadmin role
type PermissionChecker ¶
type PermissionChecker struct {
// contains filtered or unexported fields
}
PermissionChecker provides a fast, expressive API for checking permissions
func NewPermissionChecker ¶
func NewPermissionChecker(rbacSvc *rbac.Service, userRoleRepo rbac.UserRoleRepository) *PermissionChecker
NewPermissionChecker creates a new permission checker
func (*PermissionChecker) Can ¶
Can checks if a user has permission to perform an action on a resource This is the main expressive API for permission checking
func (*PermissionChecker) CanAll ¶
func (p *PermissionChecker) CanAll(ctx context.Context, userID xid.ID, permissions ...Permission) bool
CanAll checks if a user has all of the specified permissions
func (*PermissionChecker) CanAny ¶
func (p *PermissionChecker) CanAny(ctx context.Context, userID xid.ID, permissions ...Permission) bool
CanAny checks if a user has any of the specified permissions
func (*PermissionChecker) For ¶
func (p *PermissionChecker) For(ctx context.Context, userID xid.ID) *PermissionBuilder
For creates a new permission builder for a user
func (*PermissionChecker) HasAnyRole ¶
func (p *PermissionChecker) HasAnyRole(ctx context.Context, userID xid.ID, roleNames ...string) bool
HasAnyRole checks if a user has any of the specified roles
func (*PermissionChecker) InvalidateUserCache ¶
func (p *PermissionChecker) InvalidateUserCache(userID xid.ID)
InvalidateUserCache clears the cached roles for a user Call this when user roles are modified
type Plugin ¶
type Plugin struct {
// contains filtered or unexported fields
}
Plugin implements the dashboard plugin for AuthSome
func NewPlugin ¶
func NewPlugin(opts ...PluginOption) *Plugin
NewPlugin creates a new dashboard plugin instance with optional configuration
func (*Plugin) AppContext ¶
AppContext middleware injects app context into dashboard requests for authless routes
func (*Plugin) Dependencies ¶
Dependencies declares the plugin dependencies Dashboard requires multiapp plugin for environment management
func (*Plugin) EnvironmentContext ¶
EnvironmentContext middleware injects environment context into all dashboard requests
This middleware ensures that every app-scoped dashboard request has an environment ID set in the context. This is critical for: - Environment-scoped data operations - Multi-environment isolation - Audit trails with environment information - Dashboard extensions that need environment context
The middleware follows this flow: 1. Extract app ID from URL path parameter (:appId) 2. Check for environment ID in cookie (authsome_environment) 3. If no cookie, fetch the default environment for the app 4. Set environment context using contexts.SetEnvironmentID() 5. Update cookie for future requests (30-day expiry)
Routes without :appId parameter are skipped (e.g., /dashboard/login) Gracefully handles missing environment service for backward compatibility
func (*Plugin) PlatformOrgContext ¶
PlatformOrgContext middleware injects platform organization context into all dashboard requests Dashboard always operates in the context of the platform organization without requiring API keys
func (*Plugin) RegisterHooks ¶
func (p *Plugin) RegisterHooks(hooks *hooks.HookRegistry) error
RegisterHooks registers hooks for the dashboard plugin
func (*Plugin) RegisterRoles ¶
RegisterRoles implements the PluginWithRoles optional interface This is called automatically during server initialization to register dashboard roles
func (*Plugin) RegisterRoutes ¶
RegisterRoutes registers the dashboard routes
func (*Plugin) RegisterServiceDecorators ¶
func (p *Plugin) RegisterServiceDecorators(services *registry.ServiceRegistry) error
RegisterServiceDecorators registers service decorators
func (*Plugin) RequireAdmin ¶
RequireAdmin middleware ensures the user has admin role
type PluginItem ¶
type PluginItem struct {
ID string
Name string
Description string
Category string
Status string // enabled, disabled
Icon string // lucide icon name
}
PluginItem represents a plugin entry
type PluginOption ¶
type PluginOption func(*Plugin)
PluginOption is a functional option for configuring the dashboard plugin
func WithDefaultConfig ¶
func WithDefaultConfig(cfg Config) PluginOption
WithDefaultConfig sets the default configuration for the plugin
func WithDefaultTheme ¶
func WithDefaultTheme(theme string) PluginOption
WithDefaultTheme sets the default theme
func WithEnableSignup ¶
func WithEnableSignup(enabled bool) PluginOption
WithEnableSignup sets whether signup is enabled
func WithLockoutDuration ¶
func WithLockoutDuration(minutes int) PluginOption
WithLockoutDuration sets the lockout duration in minutes
func WithMaxLoginAttempts ¶
func WithMaxLoginAttempts(max int) PluginOption
WithMaxLoginAttempts sets the maximum login attempts
func WithRequireEmailVerification ¶
func WithRequireEmailVerification(required bool) PluginOption
WithRequireEmailVerification sets whether email verification is required
func WithSessionDuration ¶
func WithSessionDuration(hours int) PluginOption
WithSessionDuration sets the session duration in hours
type StatusItem ¶
type StatusItem struct {
Name string
Status string // operational, degraded, down
Color string // green, yellow, red
}
StatusItem represents a system status entry
type StatusResponse ¶
type StatusResponse = responses.StatusResponse
type SuccessResponse ¶
type SuccessResponse = responses.SuccessResponse