Afunana
Afunana Documentation

Security & Compliance

Defense-in-depth security controls aligned with ISO 27001 and SOC 2 requirements.

← Back to Docs

Authentication & Sessions

JWT Token Management

PropertyValue
AlgorithmHS256 (HMAC-SHA256)
Idle timeout15 minutes (configurable)
Absolute session limit8 hours (configurable)
Token claimssub, role, jti, iat, exp, session_start
RefreshPOST /auth/refresh extends idle timeout, preserves session start

Password Security

SSO

OIDC/OAuth 2.0 support for Azure AD, Google Workspace, Okta, and other providers. Auto-provisioning of new users on first SSO login (configurable).

Token Revocation

EventRevocation Scope
User logoutSingle token (JTI)
Password changeAll user tokens (session-level)
Admin force-logoutAll user tokens (session-level)
Account deactivationAll user tokens (session-level)

Authorization (RBAC)

RolePermissions
adminFull access: user management, collections, configuration, builds, audit, deploy
userAccess assigned collections, view documentation, use chat
viewerRead-only access to assigned collections
qaRead-only collection access, build triggers, project management access

Users are assigned to specific collections via user_collections table. Every API request validates collection access. Unauthorized access returns 404 (not 403) to prevent enumeration. Rate limiting protects auth endpoints: 10/min login, 5/min signup, 5/min password reset.

Encryption

LayerImplementation
In transitTLS 1.2+ via Caddy (automatic Let's Encrypt). HSTS with 2-year max-age, includeSubDomains, preload.
At restSQL Server TDE (AES-256). Docker secrets stored as files, not env vars.
Passwordsbcrypt with per-user salt (12 rounds)
Audit integritySHA-256 hash chain linking each event to its predecessor

Audit Logging & SIEM

All security-relevant events are written to an immutable security_event_log table. A database trigger blocks all UPDATE and DELETE operations. Each event is SHA-256 hash-chained to the previous for tamper detection.

Event Categories

CategoryExamples
authLogin success/failure, lockout, logout, password change/reset
authzAccess denied, unauthorized collection access
dataProgram view, source download, export
adminUser CRUD, config changes, collection management
systemStartup, deploy, errors, security events

Each event captures: UUID, UTC timestamp, severity, actor, IP, user agent, target, outcome, JSON context, session/correlation IDs, and integrity hash.

SIEM Integration

PropertyOptions
ProtocolsTCP+TLS (syslog), TCP, UDP, HTTPS (Splunk HEC, Datadog)
FormatsCEF (Common Event Format), JSON
ForwardingReal-time with forwarded_at timestamp tracking
RetentionEvents purged only after confirmed SIEM forwarding

Security Headers

Applied by Caddy on all responses:

HeaderValue
Strict-Transport-Securitymax-age=63072000; includeSubDomains; preload
Content-Security-Policydefault-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com
X-Frame-OptionsSAMEORIGIN
X-Content-Type-Optionsnosniff
Referrer-Policystrict-origin-when-cross-origin
Permissions-Policygeolocation=(), microphone=(), camera=()

ISO 27001:2022 — Annex A Controls

A.5 — Organizational Controls

ControlRequirementImplementation
A.5.15Access controlRBAC (admin/user/viewer/QA), collection-based isolation, least privilege at DB and API levels
A.5.23Cloud servicesOn-premise by default. LLM provider configurable (cloud or local via Ollama)

A.8 — Technological Controls

ControlRequirementImplementation
A.8.2Privileged accessAdmin role restricted. DB app user has minimal permissions. Container runs as non-root.
A.8.5Secure authenticationJWT with idle/absolute timeout, token revocation, account lockout after 5 failures
A.8.9Configuration managementVersioned DB table, changes audited with before/after values, secrets as Docker files
A.8.15LoggingImmutable INSERT-only table, trigger blocks UPDATE/DELETE, SHA-256 hash chain
A.8.16MonitoringReal-time SIEM forwarding, admin audit viewer, health endpoint
A.8.24CryptographyTLS 1.2+ in transit, AES-256 TDE at rest, bcrypt for passwords
A.8.25Secure developmentBandit static analysis, dependency scanning, parameterized SQL, Pydantic validation
A.8.26Application securityRate limiting, CORS validation, CSP headers, HSTS, session management with revocation

SOC 2 Type II — Trust Services Criteria

CriteriaRequirementImplementation
CC6.1Logical access securityRBAC, collection isolation, JWT auth, restricted DB user, non-root container
CC6.2Segregation of dutiesAdmins cannot modify their own audit trail (DB trigger prevents modification)
CC6.3Role-based accessFour roles (admin, user, viewer, qa) with logged changes. Deactivation revokes all sessions immediately.
CC6.6Authenticationbcrypt, complexity rules, lockout, SSO/OIDC, session timeout, token revocation
CC7.1–7.4System operationsComprehensive event logging, SIEM forwarding, hash chain integrity, force-logout/deactivation
CC8.1Change managementGit version control, automated deploy, idempotent migrations, vulnerability scanning
CC9.1Risk identificationDependency scanning, security headers, rate limiting, input validation
A1.1AvailabilityDocker health checks with auto-restart (30s/3 retries), systemd service, daily backups
C1.1ConfidentialityCollection isolation, TLS/TDE, Docker secrets, configurable chat content audit logging

Evidence Artifacts

EvidenceLocation
Access control policybackend/auth.py (RBAC), backend/utils.py (collection access)
Password policybackend/auth.py:validate_password_complexity()
Audit logdbo.security_event_log, backend/src/security_log.py
Hash chain verificationGET /compliance/audit/verify-hash-chain
Encryption configCaddyfile.docker (TLS), db/enable_tde.sql (TDE)
Session managementbackend/auth.py:create_token(), backend/src/token_revocation.py
Backup proceduresscripts/backup-db.sh, cron at /etc/cron.d/afunana-backup
Vulnerability scansdeploy_receiver.py — Bandit, pip audit, npm audit

Shared Responsibility

Afunana ProvidesCustomer Provides
SSO/OIDC integrationIdentity Provider configuration, MFA enforcement
RBAC + collection isolationUser provisioning/de-provisioning
Immutable audit logging + SIEM forwardingLong-term log retention (7+ years), SIEM CA certs
TLS + TDE encryptionNetwork access control (firewall), physical security
Vulnerability scanning + incident responsePenetration testing (third-party), regulatory notifications

Application Security Scanning

For detailed OWASP Top 10 coverage, AppScan readiness, and vulnerability management procedures, see the dedicated AppScan & OWASP page.