Shield: Authentication & Administration Service
:::info readme This document specifies the system requirements for Sparki Shield, the authentication and administrative service providing user management, SSO integration, workspace administration, RBAC, and internal operational tooling for the Sparki CI/CD platform. Shield is the identity layer that enables secure, compliant, and team-friendly authentication across all Sparki services. ::: :::success takeaways Key takeaways of this document include:- Understanding Shield’s authentication architecture and SSO capabilities
- Recognizing workspace and team administration features
- Identifying RBAC patterns and permission enforcement
- Establishing security and compliance standards
- Building scalable user management infrastructure
- Enabling seamless enterprise SSO integration
Date: December 3, 2025
Repository: sparki-shield
Service Type: Authentication & Admin (Django + PostgreSQL)
1. Introduction
1.1 Purpose
This document specifies the system requirements for Sparki Shield, the authentication and administrative service. Shield provides user account lifecycle management, OAuth 2.0 and SAML 2.0 authentication, JWT token issuance and validation, workspace administration, role-based access control (RBAC), and internal operational dashboards.1.2 Scope
Sparki Shield is a Django-based service that provides:- User account lifecycle management (registration, password management, profile)
- OAuth 2.0 and SAML 2.0 authentication and SSO
- JWT token issuance, validation, and refresh token management
- Workspace and organization administration
- Team member management and invitations
- Role-based access control (RBAC) with fine-grained permissions
- Permission caching for sub-millisecond authorization
- Internal admin dashboard for platform management
- Audit logging and compliance reporting
- User activity tracking and analytics
1.3 Definitions
| Property | Value |
|---|---|
| User | Individual with Sparki account credentials |
| Workspace | Team’s organizational container |
| Role | Set of permissions (owner, admin, developer, viewer) |
| SSO | Single Sign-On via OAuth 2.0/SAML 2.0 |
| JWT | JSON Web Token for stateless authentication |
| Refresh Token | Long-lived token for obtaining new access tokens |
| Permission | Fine-grained authorization right |
| Audit Log | Immutable record of authentication events |
1.4 Document Conventions
- SHALL: Mandatory requirement
- SHOULD: Recommended requirement
- MAY: Optional requirement
- WILL: External dependency or future intention
2. System Overview
2.1 System Context
Sparki Shield serves as the identity and access management (IAM) layer for the platform with integrated workspace collaboration and comprehensive operational standardization. It:- Authentication Gateway: Central authentication point for all Sparki services
- Token Management: Issues and validates JWT tokens with Redis-based caching
- User Lifecycle: Manages account creation, password management, and account deletion
- Workspace Administration: Enables team management and organizational structure
- SSO Integration: Supports enterprise SSO via OAuth 2.0, SAML 2.0, and identity providers
- Permission Caching: Redis-based permission cache for <1ms authorization validation
- Audit Logging: Comprehensive logging for compliance and security investigation
- Admin Interface: Operations dashboard for platform administration
- Event Publishing: Publishes authentication/authorization events for cross-service sync
- Observability: Structured logging, Prometheus metrics, distributed tracing integration
2.2 System Objectives
- Authentication Excellence: Industry-standard OAuth 2.0/SAML 2.0 with seamless UX
- Ultra-Fast Validation: Sub-1ms token and permission validation via caching
- Enterprise Scale: Support 1M+ users with sub-millisecond permission checks
- High Availability: 99.95% uptime for authentication operations
- Compliance: SOC 2, GDPR, HIPAA compliance with audit trails
- Zero-Trust Architecture: Validate every request regardless of source
- Developer Friendly: Simple API for authentication integration
- Team Collaboration: Seamless workspace and team management
- Security First: Industry-leading authentication practices
- Operational Excellence: Comprehensive observability and alerting
3. Functional Requirements
3.1 User Management
REQ-SHIELD-USER-001: User Registration
| Property | Value |
|---|---|
| ID | REQ-SHIELD-USER-001 |
| Requirement | Shield SHALL support user registration with email verification via the POST /auth/register endpoint. |
| Rationale | Email verification prevents spam accounts and confirms user owns email address. Essential security practice. |
| Inputs | {email, password, name} |
| Outputs | User object and verification email sent |
| Verify Method | Test |
| Acceptance Criteria: |
|
REQ-SHIELD-USER-002: Email Verification
| Property | Value |
|---|---|
| ID | REQ-SHIELD-USER-002 |
| Requirement | Shield SHALL verify user email addresses through GET /auth/verify/{token}. |
| Rationale | Confirmed email enables password recovery and prevents account impersonation. |
| Inputs | Verification token from email |
| Outputs | Success page or error message |
| Verify Method | Test |
| Acceptance Criteria: |
|
REQ-SHIELD-USER-003: Password Management
| Property | Value |
|---|---|
| ID | REQ-SHIELD-USER-003 |
| Requirement | Shield SHALL support password reset and change flows through POST /auth/password-reset and POST /auth/password-change. |
| Rationale | Users forget passwords or need to change them for security. Secure password flows maintain account security while enabling access. |
| Inputs | Email for reset request, old_password + new_password for change |
| Outputs | Password reset email or success response |
| Verify Method | Test |
| Acceptance Criteria: |
|
REQ-SHIELD-USER-004: Profile Management
| Property | Value |
|---|---|
| ID | REQ-SHIELD-USER-004 |
| Requirement | Shield SHALL support user profile updates through PATCH /api/users/{id}/profile. |
| Rationale | Users need to update profile information without changing credentials. |
| Inputs | User ID, partial profile data (name, avatar, timezone, language) |
| Outputs | Updated user object |
| Verify Method | Test |
| Acceptance Criteria: |
|
REQ-SHIELD-USER-005: Account Deletion
| Property | Value |
|---|---|
| ID | REQ-SHIELD-USER-005 |
| Requirement | Shield SHALL support account deletion through DELETE /api/users/{id} with confirmation requirements. |
| Rationale | GDPR and data privacy regulations require ability to delete personal account data. Confirmation prevents accidental deletion. |
| Inputs | User ID, password confirmation |
| Outputs | 204 No Content on success or error response |
| Verify Method | Test |
| Acceptance Criteria: |
|
3.2 Authentication & Authorization
REQ-SHIELD-AUTH-001: OAuth 2.0 Authentication
| Property | Value |
|---|---|
| ID | REQ-SHIELD-AUTH-001 |
| Requirement | Shield SHALL support OAuth 2.0 authentication (Authorization Code flow) with Google, GitHub, and GitLab identity providers. |
| Rationale | OAuth 2.0 enables seamless social login, reducing signup friction and leveraging existing developer identities. |
| Inputs | OAuth provider (google, github, gitlab), authorization code |
| Outputs | Access token, refresh token, user information |
| Verify Method | Test + Demonstration |
| Acceptance Criteria: |
|
REQ-SHIELD-AUTH-002: SAML 2.0 SSO
| Property | Value |
|---|---|
| ID | REQ-SHIELD-AUTH-002 |
| Requirement | Shield SHALL support SAML 2.0 Single Sign-On for enterprise identity providers (Okta, Azure AD, Google Workspace). |
| Rationale | SAML 2.0 enables enterprise SSO integration, essential for large organizations with centralized identity management. |
| Inputs | SAML 2.0 response from identity provider |
| Outputs | Access token, refresh token, user information |
| Verify Method | Test + Demonstration |
| Acceptance Criteria: |
|
REQ-SHIELD-AUTH-003: JWT Token Management
| Property | Value |
|---|---|
| ID | REQ-SHIELD-AUTH-003 |
| Requirement | Shield SHALL issue, validate, and manage JWT tokens with configurable expiration and refresh token rotation. |
| Rationale | JWT tokens enable stateless authentication across all Sparki services without session storage overhead. |
| Inputs | User credentials or refresh token |
| Outputs | Access token (short-lived), refresh token (long-lived), token type |
| Verify Method | Test |
| Acceptance Criteria: |
|
REQ-SHIELD-AUTH-004: Multi-Factor Authentication (MFA)
| Property | Value |
|---|---|
| ID | REQ-SHIELD-AUTH-004 |
| Requirement | Shield SHOULD support optional MFA via TOTP (Time-based One-Time Password) for enhanced security. |
| Rationale | MFA provides defense against credential compromise, essential for privileged accounts. |
| Inputs | User credentials, MFA code |
| Outputs | Access token if MFA verification succeeds |
| Verify Method | Test + Demonstration |
| Acceptance Criteria: |
|
3.3 Workspace & Team Management
REQ-SHIELD-WORKSPACE-001: Workspace Creation & Management
| Property | Value |
|---|---|
| ID | REQ-SHIELD-WORKSPACE-001 |
| Requirement | Shield SHALL support workspace creation, configuration, and lifecycle management via /api/workspaces endpoints. |
| Rationale | Workspaces provide organizational boundaries for teams and their CI/CD workflows. |
| Inputs | Workspace name, description, settings |
| Outputs | Workspace object with generated workspace ID |
| Verify Method | Test |
| Acceptance Criteria: |
|
REQ-SHIELD-WORKSPACE-002: Team Member Management
| Property | Value |
|---|---|
| ID | REQ-SHIELD-WORKSPACE-002 |
| Requirement | Shield SHALL support team member management (invitations, roles, removals) via /api/workspaces/{id}/members. |
| Rationale | Team member management enables collaborative CI/CD workflows within workspaces. |
| Inputs | User email, role, invitation expiration |
| Outputs | Workspace member object or invitation token |
| Verify Method | Test + Demonstration |
| Acceptance Criteria: |
|
REQ-SHIELD-WORKSPACE-003: Role-Based Access Control (RBAC)
| Property | Value |
|---|---|
| ID | REQ-SHIELD-WORKSPACE-003 |
| Requirement | Shield SHALL implement comprehensive RBAC with predefined roles (owner, admin, developer, viewer) and fine-grained permissions. |
| Rationale | RBAC enables secure delegation of responsibilities while maintaining control over sensitive operations. |
| Inputs | User, role, resource context |
| Outputs | Access decision (allow/deny) based on role and permissions |
| Verify Method | Test |
| Acceptance Criteria: |
|
3.4 Permission Caching & Authorization
REQ-SHIELD-CACHE-001: Redis Permission Cache
| Property | Value |
|---|---|
| ID | REQ-SHIELD-CACHE-001 |
| Requirement | Shield SHALL cache user permissions in Redis with automatic invalidation on permission changes for sub-1ms authorization. |
| Rationale | Permission caching enables real-time services to perform authorization checks in <1ms without database queries. |
| Inputs | User ID, workspace ID |
| Outputs | Cached permission set from Redis or database lookup |
| Verify Method | Test + Performance Testing |
| Acceptance Criteria: |
|
REQ-SHIELD-CACHE-002: Authorization Service for Other Services
| Property | Value |
|---|---|
| ID | REQ-SHIELD-CACHE-002 |
| Requirement | Shield SHALL provide authorization service via POST /auth/authorize for other Sparki services to validate permissions. |
| Rationale | Distributed authorization enables every Sparki service to perform quick permission checks without direct database access. |
| Inputs | User ID/token, resource, action |
| Outputs | Authorization result (allow/deny) with cached permissions |
| Verify Method | Test + Performance Testing |
| Acceptance Criteria: |
|
3.5 Audit Logging & Compliance
REQ-SHIELD-AUDIT-001: Authentication Event Logging
| Property | Value |
|---|---|
| ID | REQ-SHIELD-AUDIT-001 |
| Requirement | Shield SHALL log all authentication events (login, logout, SSO, MFA) with complete context for compliance and security. |
| Rationale | Authentication audit logging enables incident investigation and compliance verification. |
| Inputs | Authentication event (login, logout, SSO, MFA) |
| Outputs | Immutable audit log entry |
| Verify Method | Test |
| Acceptance Criteria: |
|
REQ-SHIELD-AUDIT-002: Authorization Event Logging
| Property | Value |
|---|---|
| ID | REQ-SHIELD-AUDIT-002 |
| Requirement | Shield SHALL log authorization decisions (access granted/denied) with decision rationale for audit trails. |
| Rationale | Authorization audit logging enables investigation of unauthorized access attempts and permission configuration errors. |
| Inputs | Authorization request (user, resource, action) |
| Outputs | Audit log entry with decision and rationale |
| Verify Method | Test |
| Acceptance Criteria: |
|
4. Non-Functional Requirements
4.1 Performance Requirements
| Requirement | Target | Measurement Method | Rationale |
|---|---|---|---|
| Login Response Time | <500ms | Auth latency tracking | Snappy authentication UX |
| Token Validation Latency | <5ms | Cache hit metrics | Real-time service authorization |
| Permission Cache Hit Rate | >95% | Cache metrics | Minimal database load |
| Password Hashing (bcrypt) | <200ms | Password hash timing | Balanced security/performance |
| SAML Assertion Processing | <100ms | SAML processing time | Enterprise SSO responsiveness |
4.2 Scalability Requirements
| Requirement | Target | Measurement Method | Rationale |
|---|---|---|---|
| Concurrent Users | 1M+ | Load testing | Global developer market scale |
| Concurrent Logins | 10K+/sec | Load testing | Peak onboarding periods |
| Workspaces per User | 100+ | Database scaling | Power users with multiple orgs |
| Team Members per Workspace | 10K+ | Database scaling | Large enterprise teams |
4.3 Reliability Requirements
| Requirement | Target | Measurement Method | Rationale |
|---|---|---|---|
| Authentication Availability | 99.95% | Uptime monitoring | Mission-critical service |
| Permission Cache Consistency | 99.99% | Cache verification | Authorization accuracy |
| Audit Log Durability | 99.999% | Storage durability | Compliance audit trail |
4.4 Security Requirements
| Requirement | Target | Measurement Method | Rationale |
|---|---|---|---|
| Password Hashing | bcrypt + salt | Code audit | Industry-standard protection |
| Token Encryption | TLS 1.3 + JWT | Security audit | Encrypted transmission and storage |
| Audit Log Tampering Prevention | Cryptographic | Hash verification | Compliance audit trail integrity |
| Rate Limiting on Auth | 10/minute/IP | Traffic analysis | Brute force attack prevention |
5. Integration Points
5.1 External Identity Providers
- Google OAuth 2.0:
https://accounts.google.com - GitHub OAuth 2.0:
https://github.com/login/oauth - GitLab OAuth 2.0:
https://gitlab.com/oauth - Okta SAML:
https://{organization}.okta.com - Azure AD:
https://login.microsoftonline.com
5.2 Cross-Service Integration
6. Success Metrics
| Metric | Year 1 Target | Measurement Method |
|---|---|---|
| Login Success Rate | >99.5% | Authentication metrics |
| Token Validation Latency | <5ms | Performance tracking |
| Permission Cache Hit Rate | >95% | Cache metrics |
| SSO Adoption | 70% of enterprise | Usage analytics |
| User Security Score | >8/10 | Security audit |
Document History:
| Version | Date | Author | Changes |
|---|---|---|---|
| 1.0 | 2025-12-03 | Sparki Engineering | Initial Shield SRS creation |