Authentication flows
Client credentials flow
Service-to-service authentication for API access:- Client registration: Register client in IdentityServerClient table
- Token request: Request access token with client credentials
- Token validation: API validates token signature and claims
- Scope authorization: Check token scopes against endpoint requirements
Scopes
AdminUIScope
Full administrative access to all API endpoints:- Company and project management
- User management
- Transaction queries
- Report generation
- Background process monitoring
- System configuration
/api/admin/*
PaymentScope
Limited access for payment processing:- Transaction creation (authorize, capture, refund, void)
- Payment info queries
- Chargeback notifications
/api/payment/*
InternalScope
Internal system operations:- Payflow webhook callbacks
- Background process execution
- System health checks
/api/internal/*
Client management
Client registration
Clients are stored in theIdentityServerClient table:
Client secret rotation
Clients support key rotation for security:- Generate new secret: Create new client secret
- Update client: Store new secret hash
- Notify client: Send notification with new secret
- Grace period: Old secret remains valid for transition
- Deactivate old secret: Remove old secret after grace period
- 30 days before expiration
- 7 days before expiration
- On expiration day
Client scopes
Clients can have multiple scopes:Token validation
JWT structure
Tokens are signed JWTs with the following claims:Signature validation
Tokens are signed with RSA256:- Public key retrieval: Get public key from
/.well-known/openid-configuration/jwks - Signature verification: Verify token signature with public key
- Claims validation: Validate issuer, audience, expiration
- Scope validation: Check required scopes for endpoint
Token caching
Validated tokens are cached for performance:- Cache key: Token hash
- Cache duration: Token lifetime
- Cache invalidation: On client deactivation
Authorization policies
Scope-based authorization
Controllers use scope-based authorization:Policy configuration
Policies are configured inStartup.cs:
Security considerations
Client secrets
- Hashing: Secrets are hashed with SHA256 before storage
- Transmission: Secrets are transmitted over HTTPS only
- Storage: Never log or display secrets in plain text
- Rotation: Rotate secrets every 90 days
Token security
- Lifetime: Tokens expire after 1 hour (configurable)
- Refresh: No refresh tokens (use client credentials for new token)
- Revocation: Tokens cannot be revoked (short lifetime mitigates risk)
- Scope limitation: Request minimum required scopes
IP whitelisting
Additional security via IP whitelisting:Configuration
IdentityServer configuration
Signing key management
Signing keys are stored in the Key database:- Key rotation: Rotate signing keys every 90 days
- Key storage: Store keys in
Keytable with encryption - Key retrieval: Load keys on application startup
- Key validation: Validate key expiration on each token issuance
Discovery endpoint
IdentityServer exposes discovery endpoint at/.well-known/openid-configuration:
