Documentation
¶
Index ¶
- Constants
- func GetImpersonatorID(c forge.Context) *xid.ID
- func GetTargetUserID(c forge.Context) *xid.ID
- func IsImpersonating(c forge.Context) bool
- type Config
- type ContextKey
- type EndImpersonationRequest
- type ErrorResponse
- type GetImpersonationRequest
- type Handler
- func (h *Handler) EndImpersonation(c forge.Context) error
- func (h *Handler) GetImpersonation(c forge.Context) error
- func (h *Handler) ListAuditEvents(c forge.Context) error
- func (h *Handler) ListImpersonations(c forge.Context) error
- func (h *Handler) StartImpersonation(c forge.Context) error
- func (h *Handler) VerifyImpersonation(c forge.Context) error
- type ImpersonationAuditResponse
- type ImpersonationContext
- type ImpersonationEndResponse
- type ImpersonationErrorResponse
- type ImpersonationListResponse
- type ImpersonationMiddleware
- func (m *ImpersonationMiddleware) AuditImpersonationAction() func(forge.Context) error
- func (m *ImpersonationMiddleware) Handle() func(forge.Context) error
- func (m *ImpersonationMiddleware) RequireImpersonation() func(forge.Context) error
- func (m *ImpersonationMiddleware) RequireNoImpersonation() func(forge.Context) error
- type ImpersonationSession
- type ImpersonationStartResponse
- type ImpersonationVerifyResponse
- type ListAuditEventsRequest
- type ListImpersonationsRequest
- type MessageResponse
- type Plugin
- func (p *Plugin) Description() string
- func (p *Plugin) GetMiddleware() *ImpersonationMiddleware
- func (p *Plugin) GetService() *impersonation.Service
- func (p *Plugin) Health(ctx context.Context) error
- func (p *Plugin) ID() string
- func (p *Plugin) Init(authInst core.Authsome) error
- func (p *Plugin) Migrate() error
- func (p *Plugin) Name() string
- func (p *Plugin) RegisterHooks(hookRegistry *hooks.HookRegistry) error
- func (p *Plugin) RegisterRoutes(router forge.Router) error
- func (p *Plugin) RegisterServiceDecorators(serviceRegistry *registry.ServiceRegistry) error
- func (p *Plugin) Shutdown(ctx context.Context) error
- func (p *Plugin) Version() string
- type StartImpersonationRequest
- type StatusResponse
- type SuccessResponse
- type VerifyImpersonationRequest
Constants ¶
const ( PluginID = "impersonation" PluginName = "User Impersonation" PluginVersion = "1.0.0" )
Variables ¶
This section is empty.
Functions ¶
func GetImpersonatorID ¶
GetImpersonatorID returns the impersonator's user ID if impersonating
func GetTargetUserID ¶
GetTargetUserID returns the target user's ID if impersonating
func IsImpersonating ¶
IsImpersonating checks if the current request is from an impersonation session
Types ¶
type Config ¶
type Config struct {
// Time limits
DefaultDurationMinutes int `json:"default_duration_minutes" yaml:"default_duration_minutes"`
MaxDurationMinutes int `json:"max_duration_minutes" yaml:"max_duration_minutes"`
MinDurationMinutes int `json:"min_duration_minutes" yaml:"min_duration_minutes"`
// Security
RequireReason bool `json:"require_reason" yaml:"require_reason"`
RequireTicket bool `json:"require_ticket" yaml:"require_ticket"`
MinReasonLength int `json:"min_reason_length" yaml:"min_reason_length"`
// RBAC
RequirePermission bool `json:"require_permission" yaml:"require_permission"`
ImpersonatePermission string `json:"impersonate_permission" yaml:"impersonate_permission"`
// Audit
AuditAllActions bool `json:"audit_all_actions" yaml:"audit_all_actions"`
// Auto-cleanup
AutoCleanupEnabled bool `json:"auto_cleanup_enabled" yaml:"auto_cleanup_enabled"`
CleanupInterval time.Duration `json:"cleanup_interval" yaml:"cleanup_interval"`
// UI Indicator
ShowIndicator bool `json:"show_indicator" yaml:"show_indicator"` // Show banner in UI
IndicatorMessage string `json:"indicator_message" yaml:"indicator_message"`
// Webhooks
WebhookOnStart bool `json:"webhook_on_start" yaml:"webhook_on_start"`
WebhookOnEnd bool `json:"webhook_on_end" yaml:"webhook_on_end"`
WebhookURLs []string `json:"webhook_urls" yaml:"webhook_urls"`
}
Config holds the impersonation plugin configuration
type ContextKey ¶
type ContextKey string
ContextKey is the type for context keys
const ( // ImpersonationContextKey is the context key for impersonation data ImpersonationContextKey ContextKey = "impersonation" )
type EndImpersonationRequest ¶ added in v0.0.7
type ErrorResponse ¶
type ErrorResponse = responses.ErrorResponse
Response types - use shared responses from core
type GetImpersonationRequest ¶ added in v0.0.7
type GetImpersonationRequest struct {
ID string `path:"id" validate:"required"`
}
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler handles impersonation HTTP requests Updated for V2 architecture: App → Environment → Organization
func NewHandler ¶
func NewHandler(service *impersonation.Service, config Config) *Handler
NewHandler creates a new impersonation handler
func (*Handler) EndImpersonation ¶
EndImpersonation handles POST /impersonation/end
func (*Handler) GetImpersonation ¶
GetImpersonation handles GET /impersonation/:id
func (*Handler) ListAuditEvents ¶
ListAuditEvents handles GET /impersonation/audit
func (*Handler) ListImpersonations ¶
ListImpersonations handles GET /impersonation
func (*Handler) StartImpersonation ¶
StartImpersonation handles POST /impersonation/start
type ImpersonationAuditResponse ¶
type ImpersonationAuditResponse []interface{}
type ImpersonationContext ¶
type ImpersonationContext struct {
IsImpersonating bool `json:"is_impersonating"`
ImpersonationID *xid.ID `json:"impersonation_id,omitempty"`
ImpersonatorID *xid.ID `json:"impersonator_id,omitempty"`
TargetUserID *xid.ID `json:"target_user_id,omitempty"`
IndicatorMsg string `json:"indicator_message,omitempty"`
}
ImpersonationContext holds impersonation data in the request context
func GetImpersonationContext ¶
func GetImpersonationContext(c forge.Context) *ImpersonationContext
GetImpersonationContext retrieves impersonation context from request context
type ImpersonationErrorResponse ¶
type ImpersonationErrorResponse struct {
Error string `json:"error" example:"Error message"`
}
DTOs for impersonation routes (placeholder types)
type ImpersonationListResponse ¶
type ImpersonationListResponse []interface{}
type ImpersonationMiddleware ¶
type ImpersonationMiddleware struct {
// contains filtered or unexported fields
}
ImpersonationMiddleware adds impersonation context to requests
func NewMiddleware ¶
func NewMiddleware(service *impersonation.Service, config Config) *ImpersonationMiddleware
NewMiddleware creates a new impersonation middleware
func (*ImpersonationMiddleware) AuditImpersonationAction ¶
func (m *ImpersonationMiddleware) AuditImpersonationAction() func(forge.Context) error
AuditImpersonationAction logs all actions during impersonation if enabled
func (*ImpersonationMiddleware) Handle ¶
func (m *ImpersonationMiddleware) Handle() func(forge.Context) error
Handle checks if the current session is an impersonation session and adds context
func (*ImpersonationMiddleware) RequireImpersonation ¶
func (m *ImpersonationMiddleware) RequireImpersonation() func(forge.Context) error
RequireImpersonation ensures the request IS from an impersonation session Useful for impersonation-specific endpoints
func (*ImpersonationMiddleware) RequireNoImpersonation ¶
func (m *ImpersonationMiddleware) RequireNoImpersonation() func(forge.Context) error
RequireNoImpersonation ensures the request is NOT from an impersonation session Useful for sensitive operations that should not be allowed during impersonation
type ImpersonationSession ¶
type ImpersonationSession struct{}
type ListAuditEventsRequest ¶ added in v0.0.7
type ListImpersonationsRequest ¶ added in v0.0.7
type MessageResponse ¶
type MessageResponse = responses.MessageResponse
type Plugin ¶
type Plugin struct {
// contains filtered or unexported fields
}
Plugin implements the AuthSome plugin interface for impersonation
func (*Plugin) Description ¶
Description returns the plugin description
func (*Plugin) GetMiddleware ¶
func (p *Plugin) GetMiddleware() *ImpersonationMiddleware
GetMiddleware returns the impersonation middleware
func (*Plugin) GetService ¶
func (p *Plugin) GetService() *impersonation.Service
GetService returns the impersonation service for programmatic access
func (*Plugin) RegisterHooks ¶
func (p *Plugin) RegisterHooks(hookRegistry *hooks.HookRegistry) error
RegisterHooks registers lifecycle hooks
func (*Plugin) RegisterRoutes ¶
RegisterRoutes registers HTTP routes for the plugin
func (*Plugin) RegisterServiceDecorators ¶
func (p *Plugin) RegisterServiceDecorators(serviceRegistry *registry.ServiceRegistry) error
RegisterServiceDecorators registers service decorators
type StartImpersonationRequest ¶ added in v0.0.7
type StartImpersonationRequest struct {
TargetUserID string `json:"target_user_id" validate:"required"`
Reason string `json:"reason" validate:"required"`
TicketNumber string `json:"ticket_number"`
DurationMinutes int `json:"duration_minutes"`
}
Request types
type StatusResponse ¶
type StatusResponse = responses.StatusResponse
type SuccessResponse ¶
type SuccessResponse = responses.SuccessResponse
type VerifyImpersonationRequest ¶ added in v0.0.7
type VerifyImpersonationRequest struct {
SessionID string `path:"sessionId" validate:"required"`
}