Docs Angular Auth Implementation

Technical documentation for the docs-angular authentication and access control implementation (Session 217–219)

Docs Angular Auth Implementation

This document describes the authentication and access control implementation for the docs-angular application, completed across sessions 217–219.

Overview

The docs-angular app now uses backend-api (shared platform auth) instead of the legacy backend-docs-api password-based admin login. Admin access is restricted to T0/T1 roles (executives, developers, admins, system). Documentation content remains accessible to any user based on privacy level (public/private) and project selection.

Access Control Summary

Area Who Can Access Guard / Mechanism
Admin (/admin, /admin/config, etc.) Executives, developers, admins, system only docsAdminGuard
Documentation content Any user (based on project selection + privacy) projectSelectedGuard + AccessService
Login (/auth/login) Unauthenticated users (redirect if already logged in) docsLoginPageGuard

Architecture

Frontend (docs-angular)

Backend (backend-docs-api)

Environment Configuration

Environment docsApiUrl backendApiUrl Content source
Dev undefined (MarkdownService) /api Static files
Dev /api (DocsApiService) /api —
Prod https://docs-api.gograb.space/docs-api https://api.gograb.space/api Static + API

Key Files

File Purpose
apps/docs-angular/src/app/guards/docs-admin.guard.ts T0/T1 admin guard
apps/docs-angular/src/app/pages/docs-login/docs-login.component.ts Login wrapper (no guest mode)
apps/docs-angular/src/app/services/dynamic-routes.service.ts Route definitions, guards
apps/docs-angular/src/environments/environment.ts Dev config (docsApiUrl undefined for content)
APIs/backend-docs-api/src/app/admin/admin.controller.ts RolesGuard on admin endpoints

Proxy Configuration (Dev)

/api/admin/docs  → localhost:5011 (docs-admin-proxy)
/api             → localhost:3000 (backend-api)

Content vs Admin Loading

Migration from Legacy Auth

Troubleshooting: 401 on Login

If POST /api/auth/login returns 401 Unauthorized:

  1. Backend running: Ensure backend-api is running on port 3000 (yarn serve:backend-api or equivalent).
  2. Proxy: proxy.conf.json routes /api → localhost:3000. Verify no port mismatch.
  3. Credentials: 401 usually means invalid email/password. Check backend logs for details.
  4. Network tab: Inspect request payload (email, password) and response body for backend error message.

Session Documentation