feat(auth): Add external authentication (OAuth/OIDC & LDAP) with admin management, UI, and encryption support

This commit is contained in:
2025-12-03 22:09:35 +00:00
parent 44e92d48f2
commit d3fd40ce2f
27 changed files with 4512 additions and 61 deletions

View File

@@ -0,0 +1,27 @@
import { inject } from '@angular/core';
import { Router, type CanActivateFn } from '@angular/router';
import { AuthService } from '../services/auth.service';
export const adminGuard: CanActivateFn = async () => {
const authService = inject(AuthService);
const router = inject(Router);
// First check if authenticated
if (!authService.isAuthenticated()) {
// Try to refresh the token
const refreshed = await authService.refreshAccessToken();
if (!refreshed) {
router.navigate(['/login']);
return false;
}
}
// Then check if admin
if (!authService.isAdmin()) {
// Not an admin, redirect to dashboard
router.navigate(['/dashboard']);
return false;
}
return true;
};