Authentication & Multi-Tenancy
Relevant source files
The following files were used as context for generating this wiki page:
KudosWall implements a robust authentication and multi-tenancy system designed for secure, isolated workspace management. The platform leverages a unified security stack to handle user identities, session persistence, and data isolation across different organizational tiers. This architecture ensures that sensitive customer testimonials and project configurations remain protected and accessible only to authorized personnel within specific workspace boundaries.
The system is built on a "Privacy by Design" philosophy, utilizing encrypted data storage and secure session management to maintain integrity. Multi-tenancy is enforced through a hierarchical structure involving organizations, workspaces, and projects, allowing for scalable management from solo founders to large agencies.
Sources: README.md:16-24, SECURITY.md:27-35, apps/web/src/app/(marketing)/privacy/page.tsx:68-75
Authentication Architecture
The authentication layer is primarily powered by Better-Auth, providing a comprehensive suite of security features including secure session management, Multi-Factor Authentication (MFA), and OAuth integration for third-party providers such as Google and GitHub.
Core Components
| Component | Technology | Description |
|---|---|---|
| Auth Provider | Better-Auth | Handles session lifecycle, MFA, and secure token management. |
| OAuth | Google/GitHub | Provides social login capabilities for streamlined user onboarding. |
| Identity Verification | LinkedIn/Google | Used to verify the identity of testimonial authors to increase social proof credibility. |
| Session Security | HMAC-SHA256 | Used for signing session tokens and media delivery URLs. |
Sources: README.md:91-100, SECURITY.md:29-30, apps/web/src/app/wall/[slug]/page.tsx:125-131
Authentication Flow
The following diagram illustrates the high-level authentication and initialization flow during user signup:
Multi-Tenancy and Workspace Isolation
KudosWall utilizes a decoupled workspace layer governed by Turborepo, where data isolation is maintained through database-level schemas and organizational relationships.
Organizational Hierarchy
Multi-tenancy is structured around three primary levels:
- Organization: The top-level entity that owns subscription plans (Free, Pro, Agency, Lifetime).
- Workspace: A logical grouping within an organization that contains projects. Agency plans support multiple workspaces (up to 5).
- Project: Specific testimonial collection campaigns tied to a workspace.
Sources: README.md:65-72, AGENTS.md:112-118, apps/web/src/app/wall/[slug]/page.tsx:61-75
Data Access and Procedures
Access control is enforced through tRPC procedures. Business logic defined in packages/api uses protectedProcedure to ensure that actions requiring authentication are gated. Database queries for public "Walls of Love" are filtered by project slugs and validated against the workspace's plan status to determine feature availability (e.g., badge removal).
Data Protection and Security Standards
The project follows strict security guidelines to prevent common vulnerabilities and ensure data privacy.
- SQL Injection Prevention: All database interactions are performed via Drizzle ORM, which ensures queries are parameterized.
- CSRF & XSS Protection: Leverages Next.js built-in protections combined with strict Content Security Policies (CSP).
- Audit Logging: Critical CRUD operations are recorded in an
audit_logtable for traceability. - Encryption: Data is encrypted in transit via TLS and at rest using AES-256 standards.
- Cookie-less Tracking: For public widget visitors, KudosWall uses anonymized IP/User-Agent hashing for impression tracking to maintain visitor privacy.
Sources: SECURITY.md:31-33, AGENTS.md:95-97, apps/web/src/app/(marketing)/privacy/page.tsx:71-75
Conclusion
The Authentication & Multi-Tenancy system in KudosWall provides a scalable foundation for managing social proof. By combining the security of Better-Auth with a strictly hierarchical workspace model, the platform ensures that user data is isolated and protected. The integration of automated marketing syncs and identity verification protocols further enhances the system's utility for business growth while maintaining a "Privacy by Design" approach.