From f7d85387718530b591f84fff13667932332c881e Mon Sep 17 00:00:00 2001 From: "morteza.khoramdel" Date: Sun, 24 May 2026 09:49:38 +0330 Subject: [PATCH 1/2] Add static basic authentication (login/logout/AuthGuard) for DSOMM routes --- README.md | 21 ++++++++ src/app/app-routing.module.ts | 37 ++++++++----- src/app/app.component.css | 32 ++++++++++- src/app/app.component.html | 30 ++++++++--- src/app/app.component.ts | 35 +++++++++++- src/app/app.module.ts | 2 + src/app/guards/auth.guard.spec.ts | 68 ++++++++++++++++++++++++ src/app/guards/auth.guard.ts | 43 +++++++++++++++ src/app/pages/login/login.component.css | 31 +++++++++++ src/app/pages/login/login.component.html | 35 ++++++++++++ src/app/pages/login/login.component.ts | 56 +++++++++++++++++++ src/app/services/auth.service.spec.ts | 41 ++++++++++++++ src/app/services/auth.service.ts | 48 +++++++++++++++++ src/assets/Markdown Files/README.md | 21 ++++++++ 14 files changed, 475 insertions(+), 25 deletions(-) create mode 100644 src/app/guards/auth.guard.spec.ts create mode 100644 src/app/guards/auth.guard.ts create mode 100644 src/app/pages/login/login.component.css create mode 100644 src/app/pages/login/login.component.html create mode 100644 src/app/pages/login/login.component.ts create mode 100644 src/app/services/auth.service.spec.ts create mode 100644 src/app/services/auth.service.ts diff --git a/README.md b/README.md index 40c908d78..895efa4ff 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,27 @@ You can switch on to show open TODO's for evidence by changing IS_SHOW_EVIDENCE_ This page uses the Browser's localStorage to store the state of the circular headmap. +# Static Demo Authentication + +This Angular frontend includes simple static-user authentication for demo and internal +deployments. All users have the same permissions. + +Default credentials are defined in `src/app/services/auth.service.ts`: + +| Username | Password | +| --- | --- | +| `admin` | `dsomm-admin` | +| `auditor` | `dsomm-audit` | +| `developer` | `dsomm-dev` | +| `viewer` | `dsomm-view` | + +Sign in at `/login`. The app stores the current user in the browser's `sessionStorage`, so the +login lasts only for the current browser session. + +Security warning: this is frontend-only authentication. It is not secure for production because +static credentials are shipped in the browser bundle and can be inspected by users. Use a backend +identity provider or server-side access control for production deployments. + # Changes Changes to the application are displayed at the release page of [DevSecOps-MaturityModel](https://github.com/devsecopsmaturitymodel/DevSecOps-MaturityModel-data/releases). diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index fe90fbf0b..25a12dbfe 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -1,4 +1,4 @@ -import { Component, NgModule } from '@angular/core'; +import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; import { AboutUsComponent } from './pages/about-us/about-us.component'; import { UserdayComponent } from './pages/userday/userday.component'; @@ -11,21 +11,30 @@ import { TeamsComponent } from './pages/teams/teams.component'; import { RoadmapComponent } from './pages/roadmap/roadmap.component'; import { SettingsComponent } from './pages/settings/settings.component'; import { ReportComponent } from './pages/report/report.component'; +import { AuthGuard } from './guards/auth.guard'; +import { LoginComponent } from './pages/login/login.component'; const routes: Routes = [ - { path: '', component: CircularHeatmapComponent }, - { path: 'circular-heatmap', component: CircularHeatmapComponent }, - { path: 'matrix', component: MatrixComponent }, - { path: 'activity-description', component: ActivityDescriptionPageComponent }, - { path: 'mapping', component: MappingComponent }, - { path: 'usage', redirectTo: 'usage/' }, - { path: 'usage/:page', component: UsageComponent }, - { path: 'teams', component: TeamsComponent }, - { path: 'about', component: AboutUsComponent }, - { path: 'userday', component: UserdayComponent }, - { path: 'roadmap', component: RoadmapComponent }, - { path: 'settings', component: SettingsComponent }, - { path: 'report', component: ReportComponent }, + { path: 'login', component: LoginComponent, canActivate: [AuthGuard] }, + { + path: '', + canActivateChild: [AuthGuard], + children: [ + { path: '', component: CircularHeatmapComponent }, + { path: 'circular-heatmap', component: CircularHeatmapComponent }, + { path: 'matrix', component: MatrixComponent }, + { path: 'activity-description', component: ActivityDescriptionPageComponent }, + { path: 'mapping', component: MappingComponent }, + { path: 'usage', redirectTo: 'usage/' }, + { path: 'usage/:page', component: UsageComponent }, + { path: 'teams', component: TeamsComponent }, + { path: 'about', component: AboutUsComponent }, + { path: 'userday', component: UserdayComponent }, + { path: 'roadmap', component: RoadmapComponent }, + { path: 'settings', component: SettingsComponent }, + { path: 'report', component: ReportComponent }, + ], + }, ]; @NgModule({ diff --git a/src/app/app.component.css b/src/app/app.component.css index d9d39268b..2099b4d9d 100644 --- a/src/app/app.component.css +++ b/src/app/app.component.css @@ -75,6 +75,27 @@ transform: scale(1.05); } +.toolbar-spacer { + flex: 1 1 auto; +} + +.auth-actions { + position: relative; + z-index: 1; + display: flex; + align-items: center; + gap: 8px; + margin-left: auto; +} + +.current-user { + font-size: 14px; + max-width: 160px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + .content { padding: 24px; animation: fadeSlide 1s ease; @@ -82,6 +103,12 @@ box-sizing: border-box; overflow-y: auto; } + +.login-content { + flex: 1; + overflow-y: auto; +} + @keyframes fadeSlide { from { opacity: 0; @@ -102,6 +129,9 @@ .tag-subtitle { font-size: 11px; } + .current-user { + display: none; + } .logo, .logo-icon { opacity: 0; @@ -110,4 +140,4 @@ margin: 0; overflow: hidden; } -} \ No newline at end of file +} diff --git a/src/app/app.component.html b/src/app/app.component.html index 3cbe51e5b..f29628482 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,5 +1,5 @@ -