Documentation
¶
Index ¶
- Constants
- Variables
- func GetVerificationLevel(c forge.Context) string
- func GetVerificationStatus(c forge.Context) (*schema.UserVerificationStatus, bool)
- func IsVerified(c forge.Context) bool
- type AMLMatch
- type BlockUserRequest
- type CheckSubResult
- type Config
- type CreateSessionHTTPRequest
- type CreateSessionRequest
- type CreateVerificationRequest
- type DocumentCheckConfig
- type ErrorResponse
- type FacialCheckConfig
- type Handler
- func (h *Handler) AdminBlockUser(c forge.Context) error
- func (h *Handler) AdminGetUserVerificationStatus(c forge.Context) error
- func (h *Handler) AdminGetUserVerifications(c forge.Context) error
- func (h *Handler) AdminUnblockUser(c forge.Context) error
- func (h *Handler) CreateVerificationSession(c forge.Context) error
- func (h *Handler) GetUserVerificationStatus(c forge.Context) error
- func (h *Handler) GetUserVerifications(c forge.Context) error
- func (h *Handler) GetVerification(c forge.Context) error
- func (h *Handler) GetVerificationSession(c forge.Context) error
- func (h *Handler) HandleWebhook(c forge.Context) error
- func (h *Handler) RequestReverification(c forge.Context) error
- type IDVerificationErrorResponse
- type IDVerificationListResponse
- type IDVerificationResponse
- type IDVerificationSessionResponse
- type IDVerificationStatusResponse
- type IDVerificationWebhookResponse
- type JumioConfig
- type JumioProvider
- func (p *JumioProvider) CreateSession(ctx context.Context, req *ProviderSessionRequest) (*ProviderSession, error)
- func (p *JumioProvider) GetCheck(ctx context.Context, checkID string) (*ProviderCheckResult, error)
- func (p *JumioProvider) GetProviderName() string
- func (p *JumioProvider) GetSession(ctx context.Context, sessionID string) (*ProviderSession, error)
- func (p *JumioProvider) ParseWebhook(payload []byte) (*WebhookPayload, error)
- func (p *JumioProvider) VerifyWebhook(signature, payload string) (bool, error)
- type MessageResponse
- type Middleware
- func (m *Middleware) LoadVerificationStatus(next func(forge.Context) error) func(forge.Context) error
- func (m *Middleware) RequireAMLClear() func(next func(forge.Context) error) func(forge.Context) error
- func (m *Middleware) RequireAge(minimumAge int) func(next func(forge.Context) error) func(forge.Context) error
- func (m *Middleware) RequireDocumentVerified() func(next func(forge.Context) error) func(forge.Context) error
- func (m *Middleware) RequireLivenessVerified() func(next func(forge.Context) error) func(forge.Context) error
- func (m *Middleware) RequireNotBlocked() func(next func(forge.Context) error) func(forge.Context) error
- func (m *Middleware) RequireVerificationLevel(level string) func(next func(forge.Context) error) func(forge.Context) error
- func (m *Middleware) RequireVerified() func(next func(forge.Context) error) func(forge.Context) error
- type OnfidoConfig
- type OnfidoProvider
- func (p *OnfidoProvider) CreateSession(ctx context.Context, req *ProviderSessionRequest) (*ProviderSession, error)
- func (p *OnfidoProvider) GetCheck(ctx context.Context, checkID string) (*ProviderCheckResult, error)
- func (p *OnfidoProvider) GetProviderName() string
- func (p *OnfidoProvider) GetSession(ctx context.Context, sessionID string) (*ProviderSession, error)
- func (p *OnfidoProvider) ParseWebhook(payload []byte) (*WebhookPayload, error)
- func (p *OnfidoProvider) VerifyWebhook(signature, payload string) (bool, error)
- type Plugin
- func (p *Plugin) Description() string
- func (p *Plugin) GetConfig() Config
- func (p *Plugin) GetHandler() *Handler
- func (p *Plugin) GetMiddleware() *Middleware
- func (p *Plugin) GetService() *Service
- func (p *Plugin) ID() string
- func (p *Plugin) Init(container interface{}) error
- func (p *Plugin) IsEnabled() bool
- func (p *Plugin) Middleware() func(next func(forge.Context) error) func(forge.Context) error
- func (p *Plugin) Migrate() error
- func (p *Plugin) Name() string
- func (p *Plugin) RegisterRoutes(router forge.Router) error
- func (p *Plugin) Version() string
- type Provider
- type ProviderCheckResult
- type ProviderSession
- type ProviderSessionRequest
- type Repository
- type ReverifyRequest
- type Service
- func (s *Service) BlockUser(ctx context.Context, appID xid.ID, orgID xid.ID, userID xid.ID, reason string) error
- func (s *Service) CreateVerification(ctx context.Context, req *CreateVerificationRequest) (*schema.IdentityVerification, error)
- func (s *Service) CreateVerificationSession(ctx context.Context, req *CreateSessionRequest) (*schema.IdentityVerificationSession, error)
- func (s *Service) GetUserVerificationStatus(ctx context.Context, appID xid.ID, orgID xid.ID, userID xid.ID) (*schema.UserVerificationStatus, error)
- func (s *Service) GetUserVerifications(ctx context.Context, appID xid.ID, userID xid.ID, limit, offset int) ([]*schema.IdentityVerification, error)
- func (s *Service) GetVerification(ctx context.Context, appID xid.ID, id string) (*schema.IdentityVerification, error)
- func (s *Service) GetVerificationSession(ctx context.Context, appID xid.ID, sessionID string) (*schema.IdentityVerificationSession, error)
- func (s *Service) ProcessVerificationResult(ctx context.Context, appID xid.ID, verificationID string, ...) error
- func (s *Service) RequestReverification(ctx context.Context, appID xid.ID, orgID xid.ID, userID xid.ID, reason string) error
- func (s *Service) UnblockUser(ctx context.Context, appID xid.ID, orgID xid.ID, userID xid.ID) error
- type StatusResponse
- type StripeIdentityConfig
- type StripeIdentityProvider
- func (p *StripeIdentityProvider) CreateSession(ctx context.Context, req *ProviderSessionRequest) (*ProviderSession, error)
- func (p *StripeIdentityProvider) GetCheck(ctx context.Context, sessionID string) (*ProviderCheckResult, error)
- func (p *StripeIdentityProvider) GetProviderName() string
- func (p *StripeIdentityProvider) GetSession(ctx context.Context, sessionID string) (*ProviderSession, error)
- func (p *StripeIdentityProvider) ParseWebhook(payload []byte) (*WebhookPayload, error)
- func (p *StripeIdentityProvider) VerifyWebhook(signature, payload string) (bool, error)
- type SuccessResponse
- type UnblockUserRequest
- type UserVerificationStatusResponse
- type VerificationListResponse
- type VerificationResponse
- type VerificationResult
- type VerificationSessionResponse
- type WebhookPayload
- type WebhookResponse
Constants ¶
const ( VerificationStatusContextKey verificationContextKey = "verification_status" VerificationLevelContextKey verificationContextKey = "verification_level" )
Variables ¶
var ( ErrNoProviderEnabled = errors.New("no identity verification provider enabled") ErrInvalidDefaultProvider = errors.New("invalid default provider") ErrProviderNotEnabled = errors.New("provider not enabled") ErrMissingAPIToken = errors.New("missing API token") ErrMissingAPICredentials = errors.New("missing API credentials") ErrMissingAPIKey = errors.New("missing API key") ErrUnsupportedProvider = errors.New("unsupported provider") ErrInvalidRiskScore = errors.New("invalid risk score range (must be 0-100)") ErrInvalidConfidenceScore = errors.New("invalid confidence score range (must be 0-100)") ErrInvalidMinimumAge = errors.New("invalid minimum age") ErrInvalidRateLimit = errors.New("invalid rate limit") ErrInvalidMaxAttempts = errors.New("invalid max verification attempts") )
Configuration errors
var ( ErrVerificationNotFound = errors.New("verification not found") ErrVerificationExpired = errors.New("verification has expired") ErrVerificationFailed = errors.New("verification failed") ErrVerificationPending = errors.New("verification is still pending") ErrMaxAttemptsReached = errors.New("maximum verification attempts reached") ErrSessionNotFound = errors.New("verification session not found") ErrSessionExpired = errors.New("verification session has expired") ErrInvalidVerificationType = errors.New("invalid verification type") ErrUserAlreadyVerified = errors.New("user is already verified") ErrVerificationBlocked = errors.New("user is blocked from verification") )
Verification errors
var ( ErrDocumentNotSupported = errors.New("document type not supported") ErrCountryNotSupported = errors.New("country not supported") ErrDocumentExpired = errors.New("document has expired") ErrDocumentInvalid = errors.New("document is invalid") ErrDocumentNotFound = errors.New("document not found") ErrInvalidDocumentImage = errors.New("invalid document image") ErrDocumentUploadFailed = errors.New("document upload failed") )
Document errors
var ( ErrHighRiskDetected = errors.New("high risk detected") ErrSanctionsListMatch = errors.New("user found on sanctions list") ErrPEPDetected = errors.New("politically exposed person detected") ErrAMLCheckFailed = errors.New("AML check failed") ErrAgeBelowMinimum = errors.New("age below minimum requirement") ErrLivenessCheckFailed = errors.New("liveness check failed") )
Risk and compliance errors
var ( ErrProviderAPIError = errors.New("provider API error") ErrProviderTimeout = errors.New("provider request timeout") ErrProviderRateLimited = errors.New("provider rate limit exceeded") ErrInvalidProviderResponse = errors.New("invalid provider response") ErrProviderWebhookInvalid = errors.New("invalid provider webhook") )
Provider errors
var ( ErrRateLimitExceeded = errors.New("rate limit exceeded") ErrTooManyAttempts = errors.New("too many verification attempts") )
Rate limit errors
Functions ¶
func GetVerificationLevel ¶
GetVerificationLevel retrieves the verification level from context
func GetVerificationStatus ¶
func GetVerificationStatus(c forge.Context) (*schema.UserVerificationStatus, bool)
GetVerificationStatus retrieves the verification status from context
Types ¶
type AMLMatch ¶
type AMLMatch struct {
MatchType string // sanction, pep, adverse_media
Name string
Score float64
Source string
Description string
}
AMLMatch represents a sanctions/PEP match
type BlockUserRequest ¶
type BlockUserRequest struct {
Reason string `json:"reason"`
}
BlockUserRequest represents admin request to block a user
type CheckSubResult ¶
CheckSubResult represents a sub-result within a check
type Config ¶
type Config struct {
// General settings
Enabled bool `json:"enabled" yaml:"enabled"`
DefaultProvider string `json:"defaultProvider" yaml:"defaultProvider"` // onfido, jumio, stripe_identity
SessionExpiryDuration time.Duration `json:"sessionExpiryDuration" yaml:"sessionExpiryDuration"`
VerificationExpiry time.Duration `json:"verificationExpiry" yaml:"verificationExpiry"` // How long verification is valid
// Required checks
RequireDocumentVerification bool `json:"requireDocumentVerification" yaml:"requireDocumentVerification"`
RequireLivenessDetection bool `json:"requireLivenessDetection" yaml:"requireLivenessDetection"`
RequireAgeVerification bool `json:"requireAgeVerification" yaml:"requireAgeVerification"`
RequireAMLScreening bool `json:"requireAMLScreening" yaml:"requireAMLScreening"`
MinimumAge int `json:"minimumAge" yaml:"minimumAge"` // For age verification
// Accepted document types
AcceptedDocuments []string `json:"acceptedDocuments" yaml:"acceptedDocuments"` // passport, drivers_license, national_id
AcceptedCountries []string `json:"acceptedCountries" yaml:"acceptedCountries"` // ISO 3166-1 alpha-2 codes, empty = all
// Risk scoring
MaxAllowedRiskScore int `json:"maxAllowedRiskScore" yaml:"maxAllowedRiskScore"` // 0-100
AutoRejectHighRisk bool `json:"autoRejectHighRisk" yaml:"autoRejectHighRisk"`
MinConfidenceScore int `json:"minConfidenceScore" yaml:"minConfidenceScore"` // Minimum confidence to pass
// Document retention
RetainDocuments bool `json:"retainDocuments" yaml:"retainDocuments"`
DocumentRetentionPeriod time.Duration `json:"documentRetentionPeriod" yaml:"documentRetentionPeriod"`
AutoDeleteAfterExpiry bool `json:"autoDeleteAfterExpiry" yaml:"autoDeleteAfterExpiry"`
// Webhook configuration
WebhooksEnabled bool `json:"webhooksEnabled" yaml:"webhooksEnabled"`
WebhookURL string `json:"webhookUrl" yaml:"webhookUrl"`
WebhookEvents []string `json:"webhookEvents" yaml:"webhookEvents"` // verification.completed, verification.failed, etc.
WebhookSecret string `json:"webhookSecret" yaml:"webhookSecret"`
WebhookRetryCount int `json:"webhookRetryCount" yaml:"webhookRetryCount"`
// Callback URLs (defaults)
DefaultSuccessURL string `json:"defaultSuccessUrl" yaml:"defaultSuccessUrl"`
DefaultCancelURL string `json:"defaultCancelUrl" yaml:"defaultCancelUrl"`
// Provider configurations
Onfido OnfidoConfig `json:"onfido" yaml:"onfido"`
Jumio JumioConfig `json:"jumio" yaml:"jumio"`
StripeIdentity StripeIdentityConfig `json:"stripeIdentity" yaml:"stripeIdentity"`
// Features
EnableManualReview bool `json:"enableManualReview" yaml:"enableManualReview"` // Allow manual review of failed verifications
EnableReverification bool `json:"enableReverification" yaml:"enableReverification"` // Allow re-verification
MaxVerificationAttempts int `json:"maxVerificationAttempts" yaml:"maxVerificationAttempts"`
// Compliance
EnableAuditLog bool `json:"enableAuditLog" yaml:"enableAuditLog"`
ComplianceMode string `json:"complianceMode" yaml:"complianceMode"` // standard, strict, custom
GDPRCompliant bool `json:"gdprCompliant" yaml:"gdprCompliant"`
DataResidency string `json:"dataResidency" yaml:"dataResidency"` // us, eu, uk, global
// Rate limiting
RateLimitEnabled bool `json:"rateLimitEnabled" yaml:"rateLimitEnabled"`
MaxVerificationsPerHour int `json:"maxVerificationsPerHour" yaml:"maxVerificationsPerHour"`
MaxVerificationsPerDay int `json:"maxVerificationsPerDay" yaml:"maxVerificationsPerDay"`
// Metadata
CustomFields map[string]interface{} `json:"customFields" yaml:"customFields"`
}
Config holds the identity verification plugin configuration
type CreateSessionHTTPRequest ¶
type CreateSessionHTTPRequest struct {
Provider string `json:"provider"`
RequiredChecks []string `json:"requiredChecks,omitempty"`
SuccessURL string `json:"successUrl,omitempty"`
CancelURL string `json:"cancelUrl,omitempty"`
Config map[string]interface{} `json:"config,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
CreateSessionHTTPRequest represents the HTTP request body for session creation
type CreateSessionRequest ¶
type CreateSessionRequest struct {
// V2 Context
AppID xid.ID
EnvironmentID *xid.ID
OrganizationID xid.ID
UserID xid.ID
// Session configuration
Provider string // onfido, jumio, stripe_identity
RequiredChecks []string // document, liveness, age, aml
SuccessURL string
CancelURL string
Config map[string]interface{}
Metadata map[string]interface{}
// Tracking
IPAddress string
UserAgent string
}
CreateSessionRequest represents a request to create a verification session
type CreateVerificationRequest ¶
type CreateVerificationRequest struct {
// V2 Context
AppID xid.ID
EnvironmentID *xid.ID
OrganizationID xid.ID
UserID xid.ID
// Verification details
Provider string
ProviderCheckID string
VerificationType string
DocumentType string
Metadata map[string]interface{}
// Tracking
IPAddress string
UserAgent string
}
CreateVerificationRequest represents a request to create a verification
type DocumentCheckConfig ¶
type DocumentCheckConfig struct {
Enabled bool `json:"enabled" yaml:"enabled"`
ValidateExpiry bool `json:"validateExpiry" yaml:"validateExpiry"`
ValidateDataConsistency bool `json:"validateDataConsistency" yaml:"validateDataConsistency"`
ExtractData bool `json:"extractData" yaml:"extractData"`
}
DocumentCheckConfig configures document verification
type ErrorResponse ¶
type ErrorResponse = responses.ErrorResponse
Response types - use shared responses from core
type FacialCheckConfig ¶
type FacialCheckConfig struct {
Enabled bool `json:"enabled" yaml:"enabled"`
Variant string `json:"variant" yaml:"variant"` // standard, video
MotionCapture bool `json:"motionCapture" yaml:"motionCapture"`
}
FacialCheckConfig configures facial/liveness verification
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler handles HTTP requests for identity verification
func NewHandler ¶
NewHandler creates a new identity verification handler
func (*Handler) AdminBlockUser ¶
AdminBlockUser blocks a user from verification (admin only) POST /verification/admin/users/:userId/block
func (*Handler) AdminGetUserVerificationStatus ¶
AdminGetUserVerificationStatus retrieves verification status for any user (admin only) GET /verification/admin/users/:userId/status
func (*Handler) AdminGetUserVerifications ¶
AdminGetUserVerifications retrieves all verifications for any user (admin only) GET /verification/admin/users/:userId/verifications
func (*Handler) AdminUnblockUser ¶
AdminUnblockUser unblocks a user (admin only) POST /verification/admin/users/:userId/unblock
func (*Handler) CreateVerificationSession ¶
CreateVerificationSession creates a new verification session POST /verification/sessions
func (*Handler) GetUserVerificationStatus ¶
GetUserVerificationStatus retrieves the verification status for the current user GET /verification/me/status
func (*Handler) GetUserVerifications ¶
GetUserVerifications retrieves all verifications for the current user GET /verification/me
func (*Handler) GetVerification ¶
GetVerification retrieves a verification by ID GET /verification/:id
func (*Handler) GetVerificationSession ¶
GetVerificationSession retrieves a verification session GET /verification/sessions/:id
func (*Handler) HandleWebhook ¶
HandleWebhook handles provider webhook callbacks POST /verification/webhook/:provider
type IDVerificationErrorResponse ¶
type IDVerificationErrorResponse struct {
Error string `json:"error" example:"Error message"`
}
Response types for identity verification routes
type IDVerificationListResponse ¶
type IDVerificationListResponse struct {
Verifications []interface{} `json:"verifications"`
}
type IDVerificationResponse ¶
type IDVerificationResponse struct {
Verification interface{} `json:"verification"`
}
type IDVerificationSessionResponse ¶
type IDVerificationSessionResponse struct {
Session interface{} `json:"session"`
}
type IDVerificationStatusResponse ¶
type IDVerificationStatusResponse struct {
Status interface{} `json:"status"`
}
type IDVerificationWebhookResponse ¶
type IDVerificationWebhookResponse struct {
Status string `json:"status" example:"processed"`
}
type JumioConfig ¶
type JumioConfig struct {
Enabled bool `json:"enabled" yaml:"enabled"`
APIToken string `json:"apiToken" yaml:"apiToken"`
APISecret string `json:"apiSecret" yaml:"apiSecret"`
DataCenter string `json:"dataCenter" yaml:"dataCenter"` // us, eu, sg
// Verification settings
VerificationType string `json:"verificationType" yaml:"verificationType"` // identity, document, similarity
PresetID string `json:"presetId" yaml:"presetId"` // Jumio preset configuration
// Document settings
EnabledDocumentTypes []string `json:"enabledDocumentTypes" yaml:"enabledDocumentTypes"`
EnabledCountries []string `json:"enabledCountries" yaml:"enabledCountries"`
// Features
EnableLiveness bool `json:"enableLiveness" yaml:"enableLiveness"`
EnableAMLScreening bool `json:"enableAMLScreening" yaml:"enableAMLScreening"`
EnableExtraction bool `json:"enableExtraction" yaml:"enableExtraction"`
// Callback
CallbackURL string `json:"callbackUrl" yaml:"callbackUrl"`
}
JumioConfig holds Jumio-specific configuration
type JumioProvider ¶
type JumioProvider struct {
// contains filtered or unexported fields
}
JumioProvider implements the Provider interface for Jumio
func NewJumioProvider ¶
func NewJumioProvider(config JumioConfig) (*JumioProvider, error)
NewJumioProvider creates a new Jumio provider
func (*JumioProvider) CreateSession ¶
func (p *JumioProvider) CreateSession(ctx context.Context, req *ProviderSessionRequest) (*ProviderSession, error)
CreateSession creates a Jumio verification session
func (*JumioProvider) GetCheck ¶
func (p *JumioProvider) GetCheck(ctx context.Context, checkID string) (*ProviderCheckResult, error)
GetCheck retrieves a Jumio verification result
func (*JumioProvider) GetProviderName ¶
func (p *JumioProvider) GetProviderName() string
GetProviderName returns the provider name
func (*JumioProvider) GetSession ¶
func (p *JumioProvider) GetSession(ctx context.Context, sessionID string) (*ProviderSession, error)
GetSession retrieves a Jumio session status
func (*JumioProvider) ParseWebhook ¶
func (p *JumioProvider) ParseWebhook(payload []byte) (*WebhookPayload, error)
ParseWebhook parses a Jumio webhook payload
func (*JumioProvider) VerifyWebhook ¶
func (p *JumioProvider) VerifyWebhook(signature, payload string) (bool, error)
VerifyWebhook verifies a Jumio webhook signature
type MessageResponse ¶
type MessageResponse = responses.MessageResponse
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
Middleware handles identity verification checks
func NewMiddleware ¶
func NewMiddleware(service *Service) *Middleware
NewMiddleware creates a new identity verification middleware
func (*Middleware) LoadVerificationStatus ¶
func (m *Middleware) LoadVerificationStatus(next func(forge.Context) error) func(forge.Context) error
LoadVerificationStatus loads the user's verification status into context This middleware is non-blocking - it will set context values if found, but will not reject requests (use RequireVerified for that)
func (*Middleware) RequireAMLClear ¶
func (m *Middleware) RequireAMLClear() func(next func(forge.Context) error) func(forge.Context) error
RequireAMLClear enforces that AML screening is complete and clear
func (*Middleware) RequireAge ¶
func (m *Middleware) RequireAge(minimumAge int) func(next func(forge.Context) error) func(forge.Context) error
RequireAge enforces minimum age requirement
func (*Middleware) RequireDocumentVerified ¶
func (m *Middleware) RequireDocumentVerified() func(next func(forge.Context) error) func(forge.Context) error
RequireDocumentVerified enforces that document verification is complete
func (*Middleware) RequireLivenessVerified ¶
func (m *Middleware) RequireLivenessVerified() func(next func(forge.Context) error) func(forge.Context) error
RequireLivenessVerified enforces that liveness detection is complete
func (*Middleware) RequireNotBlocked ¶
func (m *Middleware) RequireNotBlocked() func(next func(forge.Context) error) func(forge.Context) error
RequireNotBlocked ensures the user is not blocked from verification
func (*Middleware) RequireVerificationLevel ¶
func (m *Middleware) RequireVerificationLevel(level string) func(next func(forge.Context) error) func(forge.Context) error
RequireVerificationLevel enforces a specific verification level Levels: none, basic, enhanced, full
func (*Middleware) RequireVerified ¶
func (m *Middleware) RequireVerified() func(next func(forge.Context) error) func(forge.Context) error
RequireVerified enforces that the user must be verified
type OnfidoConfig ¶
type OnfidoConfig struct {
Enabled bool `json:"enabled" yaml:"enabled"`
APIToken string `json:"apiToken" yaml:"apiToken"`
Region string `json:"region" yaml:"region"` // us, eu, ca
WebhookToken string `json:"webhookToken" yaml:"webhookToken"`
// Check configuration
DocumentCheck DocumentCheckConfig `json:"documentCheck" yaml:"documentCheck"`
FacialCheck FacialCheckConfig `json:"facialCheck" yaml:"facialCheck"`
// Workflow
WorkflowID string `json:"workflowId" yaml:"workflowId"` // Predefined Onfido workflow
// Reports
IncludeDocumentReport bool `json:"includeDocumentReport" yaml:"includeDocumentReport"`
IncludeFacialReport bool `json:"includeFacialReport" yaml:"includeFacialReport"`
IncludeWatchlistReport bool `json:"includeWatchlistReport" yaml:"includeWatchlistReport"`
}
OnfidoConfig holds Onfido-specific configuration
type OnfidoProvider ¶
type OnfidoProvider struct {
// contains filtered or unexported fields
}
OnfidoProvider implements the Provider interface for Onfido
func NewOnfidoProvider ¶
func NewOnfidoProvider(config OnfidoConfig) (*OnfidoProvider, error)
NewOnfidoProvider creates a new Onfido provider
func (*OnfidoProvider) CreateSession ¶
func (p *OnfidoProvider) CreateSession(ctx context.Context, req *ProviderSessionRequest) (*ProviderSession, error)
CreateSession creates an Onfido verification session
func (*OnfidoProvider) GetCheck ¶
func (p *OnfidoProvider) GetCheck(ctx context.Context, checkID string) (*ProviderCheckResult, error)
GetCheck retrieves an Onfido check result
func (*OnfidoProvider) GetProviderName ¶
func (p *OnfidoProvider) GetProviderName() string
GetProviderName returns the provider name
func (*OnfidoProvider) GetSession ¶
func (p *OnfidoProvider) GetSession(ctx context.Context, sessionID string) (*ProviderSession, error)
GetSession retrieves an Onfido session status
func (*OnfidoProvider) ParseWebhook ¶
func (p *OnfidoProvider) ParseWebhook(payload []byte) (*WebhookPayload, error)
ParseWebhook parses an Onfido webhook payload
func (*OnfidoProvider) VerifyWebhook ¶
func (p *OnfidoProvider) VerifyWebhook(signature, payload string) (bool, error)
VerifyWebhook verifies an Onfido webhook signature
type Plugin ¶
type Plugin struct {
// contains filtered or unexported fields
}
Plugin implements the identity verification plugin
func (*Plugin) Description ¶
Description returns the plugin description
func (*Plugin) GetHandler ¶
GetHandler returns the HTTP handler
func (*Plugin) GetMiddleware ¶
func (p *Plugin) GetMiddleware() *Middleware
GetMiddleware returns the verification middleware
func (*Plugin) GetService ¶
GetService returns the verification service
func (*Plugin) Middleware ¶
Middleware returns the LoadVerificationStatus middleware function This is a convenience method for registering the middleware with Forge
func (*Plugin) RegisterRoutes ¶
RegisterRoutes registers the plugin routes
type Provider ¶
type Provider interface {
// CreateSession creates a verification session with the provider
CreateSession(ctx context.Context, req *ProviderSessionRequest) (*ProviderSession, error)
// GetSession retrieves session status from the provider
GetSession(ctx context.Context, sessionID string) (*ProviderSession, error)
// GetCheck retrieves a verification check result
GetCheck(ctx context.Context, checkID string) (*ProviderCheckResult, error)
// VerifyWebhook verifies a webhook signature
VerifyWebhook(signature, payload string) (bool, error)
// ParseWebhook parses a webhook payload
ParseWebhook(payload []byte) (*WebhookPayload, error)
// GetProviderName returns the provider name
GetProviderName() string
}
Provider interface for KYC providers
type ProviderCheckResult ¶
type ProviderCheckResult struct {
ID string
Type string // document, liveness, aml
Status string
Result string // clear, consider, rejected
SubResults []CheckSubResult
Properties map[string]interface{}
RiskScore int
ConfidenceScore int
// Document-specific
DocumentType string
DocumentCountry string
DocumentNumber string
DocumentExpiry *time.Time
IsDocumentValid bool
// Personal data extraction
FirstName string
LastName string
DateOfBirth *time.Time
Gender string
Nationality string
// Liveness-specific
IsLive bool
LivenessScore int
// AML-specific
IsOnSanctionsList bool
IsPEP bool
Matches []AMLMatch
CreatedAt time.Time
CompletedAt *time.Time
}
ProviderCheckResult represents the result of a provider check
type ProviderSession ¶
type ProviderSession struct {
ID string
URL string // URL for the user to complete verification
Token string // Session token
Status string
ExpiresAt time.Time
CreatedAt time.Time
}
ProviderSession represents a provider verification session
type ProviderSessionRequest ¶
type ProviderSessionRequest struct {
// V2 Context
AppID xid.ID
EnvironmentID *xid.ID
OrganizationID xid.ID
UserID xid.ID
// Session configuration
RequiredChecks []string
SuccessURL string
CancelURL string
Metadata map[string]interface{}
}
ProviderSessionRequest represents a provider session creation request
type Repository ¶
type Repository interface {
// Identity Verification CRUD
CreateVerification(ctx context.Context, verification *schema.IdentityVerification) error
GetVerificationByID(ctx context.Context, appID xid.ID, id string) (*schema.IdentityVerification, error)
GetVerificationsByUserID(ctx context.Context, appID xid.ID, userID xid.ID, limit, offset int) ([]*schema.IdentityVerification, error)
GetVerificationsByOrgID(ctx context.Context, appID xid.ID, orgID xid.ID, limit, offset int) ([]*schema.IdentityVerification, error)
UpdateVerification(ctx context.Context, verification *schema.IdentityVerification) error
DeleteVerification(ctx context.Context, appID xid.ID, id string) error
// Query methods
GetLatestVerificationByUser(ctx context.Context, appID xid.ID, userID xid.ID) (*schema.IdentityVerification, error)
GetVerificationByProviderCheckID(ctx context.Context, appID xid.ID, providerCheckID string) (*schema.IdentityVerification, error)
GetVerificationsByStatus(ctx context.Context, appID xid.ID, status string, limit, offset int) ([]*schema.IdentityVerification, error)
GetVerificationsByType(ctx context.Context, appID xid.ID, verificationType string, limit, offset int) ([]*schema.IdentityVerification, error)
CountVerificationsByUser(ctx context.Context, appID xid.ID, userID xid.ID, since time.Time) (int, error)
GetExpiredVerifications(ctx context.Context, appID xid.ID, before time.Time, limit int) ([]*schema.IdentityVerification, error)
// Document operations
CreateDocument(ctx context.Context, document *schema.IdentityVerificationDocument) error
GetDocumentByID(ctx context.Context, appID xid.ID, id string) (*schema.IdentityVerificationDocument, error)
GetDocumentsByVerificationID(ctx context.Context, appID xid.ID, verificationID string) ([]*schema.IdentityVerificationDocument, error)
UpdateDocument(ctx context.Context, document *schema.IdentityVerificationDocument) error
DeleteDocument(ctx context.Context, appID xid.ID, id string) error
GetDocumentsForDeletion(ctx context.Context, appID xid.ID, before time.Time, limit int) ([]*schema.IdentityVerificationDocument, error)
// Session operations
CreateSession(ctx context.Context, session *schema.IdentityVerificationSession) error
GetSessionByID(ctx context.Context, appID xid.ID, id string) (*schema.IdentityVerificationSession, error)
GetSessionsByUserID(ctx context.Context, appID xid.ID, userID xid.ID, limit, offset int) ([]*schema.IdentityVerificationSession, error)
UpdateSession(ctx context.Context, session *schema.IdentityVerificationSession) error
DeleteSession(ctx context.Context, appID xid.ID, id string) error
GetExpiredSessions(ctx context.Context, appID xid.ID, before time.Time, limit int) ([]*schema.IdentityVerificationSession, error)
// User verification status
CreateUserVerificationStatus(ctx context.Context, status *schema.UserVerificationStatus) error
GetUserVerificationStatus(ctx context.Context, appID xid.ID, orgID xid.ID, userID xid.ID) (*schema.UserVerificationStatus, error)
UpdateUserVerificationStatus(ctx context.Context, status *schema.UserVerificationStatus) error
DeleteUserVerificationStatus(ctx context.Context, appID xid.ID, orgID xid.ID, userID xid.ID) error
GetUsersRequiringReverification(ctx context.Context, appID xid.ID, limit int) ([]*schema.UserVerificationStatus, error)
GetUsersByVerificationLevel(ctx context.Context, appID xid.ID, level string, limit, offset int) ([]*schema.UserVerificationStatus, error)
GetBlockedUsers(ctx context.Context, appID xid.ID, limit, offset int) ([]*schema.UserVerificationStatus, error)
// Analytics and reporting - Returns map[string]interface{} for flexibility
GetVerificationStats(ctx context.Context, appID xid.ID, orgID xid.ID, from, to time.Time) (map[string]interface{}, error)
GetProviderStats(ctx context.Context, appID xid.ID, provider string, from, to time.Time) (map[string]interface{}, error)
}
Repository defines the interface for identity verification data operations Updated for V2 architecture with App → Environment → Organization hierarchy
type ReverifyRequest ¶
type ReverifyRequest struct {
Reason string `json:"reason,omitempty"`
}
ReverifyRequest represents a request for re-verification
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service handles identity verification operations
func NewService ¶
func NewService( repo Repository, config Config, auditService *audit.Service, webhookService *webhook.Service, ) (*Service, error)
NewService creates a new identity verification service
func (*Service) BlockUser ¶
func (s *Service) BlockUser(ctx context.Context, appID xid.ID, orgID xid.ID, userID xid.ID, reason string) error
BlockUser blocks a user from verification with V2 context
func (*Service) CreateVerification ¶
func (s *Service) CreateVerification(ctx context.Context, req *CreateVerificationRequest) (*schema.IdentityVerification, error)
CreateVerification creates a new verification record with V2 context
func (*Service) CreateVerificationSession ¶
func (s *Service) CreateVerificationSession(ctx context.Context, req *CreateSessionRequest) (*schema.IdentityVerificationSession, error)
CreateVerificationSession creates a new verification session for a user with V2 context
func (*Service) GetUserVerificationStatus ¶
func (s *Service) GetUserVerificationStatus(ctx context.Context, appID xid.ID, orgID xid.ID, userID xid.ID) (*schema.UserVerificationStatus, error)
GetUserVerificationStatus retrieves the verification status for a user with V2 context
func (*Service) GetUserVerifications ¶
func (s *Service) GetUserVerifications(ctx context.Context, appID xid.ID, userID xid.ID, limit, offset int) ([]*schema.IdentityVerification, error)
GetUserVerifications retrieves all verifications for a user with V2 context
func (*Service) GetVerification ¶
func (s *Service) GetVerification(ctx context.Context, appID xid.ID, id string) (*schema.IdentityVerification, error)
GetVerification retrieves a verification by ID with V2 context
func (*Service) GetVerificationSession ¶
func (s *Service) GetVerificationSession(ctx context.Context, appID xid.ID, sessionID string) (*schema.IdentityVerificationSession, error)
GetVerificationSession retrieves a verification session with V2 context
func (*Service) ProcessVerificationResult ¶
func (s *Service) ProcessVerificationResult(ctx context.Context, appID xid.ID, verificationID string, result *VerificationResult) error
ProcessVerificationResult processes the result from a provider with V2 context
type StatusResponse ¶
type StatusResponse = responses.StatusResponse
type StripeIdentityConfig ¶
type StripeIdentityConfig struct {
Enabled bool `json:"enabled" yaml:"enabled"`
APIKey string `json:"apiKey" yaml:"apiKey"`
WebhookSecret string `json:"webhookSecret" yaml:"webhookSecret"`
// Verification options
RequireLiveCapture bool `json:"requireLiveCapture" yaml:"requireLiveCapture"`
AllowedTypes []string `json:"allowedTypes" yaml:"allowedTypes"` // document, id_number
// Document options
RequireMatchingSelfie bool `json:"requireMatchingSelfie" yaml:"requireMatchingSelfie"`
// Return URL
ReturnURL string `json:"returnUrl" yaml:"returnUrl"`
// Testing
UseMock bool `json:"useMock" yaml:"useMock"` // Use mock implementation for testing/development
}
StripeIdentityConfig holds Stripe Identity-specific configuration
type StripeIdentityProvider ¶
type StripeIdentityProvider struct {
// contains filtered or unexported fields
}
StripeIdentityProvider implements the Provider interface for Stripe Identity
func NewStripeIdentityProvider ¶
func NewStripeIdentityProvider(config StripeIdentityConfig) (*StripeIdentityProvider, error)
NewStripeIdentityProvider creates a new Stripe Identity provider
func (*StripeIdentityProvider) CreateSession ¶
func (p *StripeIdentityProvider) CreateSession(ctx context.Context, req *ProviderSessionRequest) (*ProviderSession, error)
CreateSession creates a Stripe Identity verification session
func (*StripeIdentityProvider) GetCheck ¶
func (p *StripeIdentityProvider) GetCheck(ctx context.Context, sessionID string) (*ProviderCheckResult, error)
GetCheck retrieves a Stripe Identity verification result
func (*StripeIdentityProvider) GetProviderName ¶
func (p *StripeIdentityProvider) GetProviderName() string
GetProviderName returns the provider name
func (*StripeIdentityProvider) GetSession ¶
func (p *StripeIdentityProvider) GetSession(ctx context.Context, sessionID string) (*ProviderSession, error)
GetSession retrieves a Stripe Identity verification session status
func (*StripeIdentityProvider) ParseWebhook ¶
func (p *StripeIdentityProvider) ParseWebhook(payload []byte) (*WebhookPayload, error)
ParseWebhook parses a Stripe webhook payload
func (*StripeIdentityProvider) VerifyWebhook ¶
func (p *StripeIdentityProvider) VerifyWebhook(signature, payload string) (bool, error)
VerifyWebhook verifies a Stripe webhook signature
type SuccessResponse ¶
type SuccessResponse = responses.SuccessResponse
type UnblockUserRequest ¶
type UnblockUserRequest struct {
}
UnblockUserRequest represents admin request to unblock a user
type UserVerificationStatusResponse ¶
type UserVerificationStatusResponse struct {
Status *base.UserVerificationStatus `json:"status"`
}
UserVerificationStatusResponse represents a user's verification status
type VerificationListResponse ¶
type VerificationListResponse struct {
Verifications []*base.IdentityVerification `json:"verifications"`
Limit int `json:"limit"`
Offset int `json:"offset"`
Total int `json:"total,omitempty"`
}
VerificationListResponse represents a list of verifications with pagination
type VerificationResponse ¶
type VerificationResponse struct {
Verification *base.IdentityVerification `json:"verification"`
}
VerificationResponse represents a single verification response
type VerificationResult ¶
type VerificationResult struct {
Status string
IsVerified bool
RiskScore int
RiskLevel string
ConfidenceScore int
RejectionReasons []string
FailureReason string
ProviderData map[string]interface{}
// Personal information
FirstName string
LastName string
DateOfBirth *time.Time
DocumentNumber string
DocumentCountry string
Nationality string
Gender string
// AML/Sanctions
IsOnSanctionsList bool
IsPEP bool
SanctionsDetails string
// Liveness
LivenessScore int
IsLive bool
}
VerificationResult represents the result from a provider
type VerificationSessionResponse ¶
type VerificationSessionResponse struct {
Session *base.IdentityVerificationSession `json:"session"`
}
VerificationSessionResponse represents a single verification session response
type WebhookPayload ¶
type WebhookPayload struct {
EventType string
CheckID string
SessionID string
Status string
Result *ProviderCheckResult
Timestamp time.Time
RawPayload map[string]interface{}
}
WebhookPayload represents a parsed webhook from a provider
type WebhookResponse ¶
type WebhookResponse struct {
Received bool `json:"received"`
ProcessedStatus string `json:"status,omitempty"`
}
WebhookResponse represents a webhook processing response