Documentation
¶
Index ¶
- type TwoFAConfig
- type TwoFAProvider
- func (tp *TwoFAProvider) Authenticate(ctx context.Context, request *types.AuthRequest) (*types.AuthResponse, error)
- func (tp *TwoFAProvider) Authorize(ctx context.Context, request *types.AuthorizationRequest) (*types.AuthorizationResponse, error)
- func (tp *TwoFAProvider) CheckPermission(ctx context.Context, request *types.PermissionRequest) (*types.PermissionResponse, error)
- func (tp *TwoFAProvider) Close() error
- func (tp *TwoFAProvider) Configure(config map[string]interface{}) error
- func (tp *TwoFAProvider) GenerateSecret(ctx context.Context, userID, userEmail string) (*TwoFASecret, error)
- func (tp *TwoFAProvider) GetConnectionInfo() *types.ConnectionInfo
- func (tp *TwoFAProvider) GetName() string
- func (tp *TwoFAProvider) GetStats(ctx context.Context) (*types.AuthStats, error)
- func (tp *TwoFAProvider) GetSupportedFeatures() []types.AuthFeature
- func (tp *TwoFAProvider) HealthCheck(ctx context.Context) error
- func (tp *TwoFAProvider) IsConfigured() bool
- func (tp *TwoFAProvider) RefreshToken(ctx context.Context, request *types.TokenRefreshRequest) (*types.TokenRefreshResponse, error)
- func (tp *TwoFAProvider) RevokeToken(ctx context.Context, request *types.TokenRevocationRequest) error
- func (tp *TwoFAProvider) ValidateToken(ctx context.Context, request *types.TokenValidationRequest) (*types.TokenValidationResponse, error)
- func (tp *TwoFAProvider) VerifyBackupCode(ctx context.Context, userID, backupCode string) (*TwoFAVerification, error)
- func (tp *TwoFAProvider) VerifyCode(ctx context.Context, secret, code string) (*TwoFAVerification, error)
- type TwoFASecret
- type TwoFAVerification
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TwoFAConfig ¶
type TwoFAConfig struct { SecretKey string `json:"secret_key"` Issuer string `json:"issuer"` Algorithm string `json:"algorithm"` }
TwoFAConfig holds 2FA provider configuration
func DefaultTwoFAConfig ¶
func DefaultTwoFAConfig() *TwoFAConfig
DefaultTwoFAConfig returns default 2FA configuration
type TwoFAProvider ¶
type TwoFAProvider struct {
// contains filtered or unexported fields
}
TwoFAProvider implements Two-Factor Authentication
func NewTwoFAProvider ¶
func NewTwoFAProvider(config *TwoFAConfig, logger *logrus.Logger) *TwoFAProvider
NewTwoFAProvider creates a new 2FA provider
func (*TwoFAProvider) Authenticate ¶
func (tp *TwoFAProvider) Authenticate(ctx context.Context, request *types.AuthRequest) (*types.AuthResponse, error)
Authenticate authenticates a user with 2FA
func (*TwoFAProvider) Authorize ¶
func (tp *TwoFAProvider) Authorize(ctx context.Context, request *types.AuthorizationRequest) (*types.AuthorizationResponse, error)
Authorize authorizes a user
func (*TwoFAProvider) CheckPermission ¶
func (tp *TwoFAProvider) CheckPermission(ctx context.Context, request *types.PermissionRequest) (*types.PermissionResponse, error)
CheckPermission checks if a user has a specific permission
func (*TwoFAProvider) Configure ¶
func (tp *TwoFAProvider) Configure(config map[string]interface{}) error
Configure configures the 2FA provider
func (*TwoFAProvider) GenerateSecret ¶
func (tp *TwoFAProvider) GenerateSecret(ctx context.Context, userID, userEmail string) (*TwoFASecret, error)
GenerateSecret generates a new 2FA secret for a user
func (*TwoFAProvider) GetConnectionInfo ¶
func (tp *TwoFAProvider) GetConnectionInfo() *types.ConnectionInfo
GetConnectionInfo returns connection information
func (*TwoFAProvider) GetName ¶
func (tp *TwoFAProvider) GetName() string
GetName returns the provider name
func (*TwoFAProvider) GetSupportedFeatures ¶
func (tp *TwoFAProvider) GetSupportedFeatures() []types.AuthFeature
GetSupportedFeatures returns supported features
func (*TwoFAProvider) HealthCheck ¶
func (tp *TwoFAProvider) HealthCheck(ctx context.Context) error
HealthCheck performs health check
func (*TwoFAProvider) IsConfigured ¶
func (tp *TwoFAProvider) IsConfigured() bool
IsConfigured returns whether the provider is configured
func (*TwoFAProvider) RefreshToken ¶
func (tp *TwoFAProvider) RefreshToken(ctx context.Context, request *types.TokenRefreshRequest) (*types.TokenRefreshResponse, error)
RefreshToken refreshes a 2FA token
func (*TwoFAProvider) RevokeToken ¶
func (tp *TwoFAProvider) RevokeToken(ctx context.Context, request *types.TokenRevocationRequest) error
RevokeToken revokes a 2FA token
func (*TwoFAProvider) ValidateToken ¶
func (tp *TwoFAProvider) ValidateToken(ctx context.Context, request *types.TokenValidationRequest) (*types.TokenValidationResponse, error)
ValidateToken validates a 2FA token
func (*TwoFAProvider) VerifyBackupCode ¶
func (tp *TwoFAProvider) VerifyBackupCode(ctx context.Context, userID, backupCode string) (*TwoFAVerification, error)
VerifyBackupCode verifies a backup code
func (*TwoFAProvider) VerifyCode ¶
func (tp *TwoFAProvider) VerifyCode(ctx context.Context, secret, code string) (*TwoFAVerification, error)
VerifyCode verifies a 2FA code
type TwoFASecret ¶
type TwoFASecret struct { Secret string `json:"secret"` QRCodeURL string `json:"qr_code_url"` BackupCodes []string `json:"backup_codes"` CreatedAt time.Time `json:"created_at"` }
TwoFASecret represents a 2FA secret
type TwoFAVerification ¶
type TwoFAVerification struct { Valid bool `json:"valid"` Message string `json:"message"` BackupUsed bool `json:"backup_used"` }
TwoFAVerification represents 2FA verification result