feat: integrate angular-oauth2-oidc for authentication

- Added angular-oauth2-oidc package to package.json.
- Configured OAuth client in app.config.ts with resource server settings.
- Implemented login component with basic HTTP request to fetch products.
- Set up routing for the login component.
- Updated app component to initialize OAuth service and handle login.
- Modified default app settings to open and collapse sidenav by default.
- Removed placeholder content from app.html to streamline the initial view.
This commit is contained in:
Marek Lesko
2025-07-29 15:58:56 +00:00
parent 50f0bb7f57
commit 9217e805e9
15 changed files with 148 additions and 395 deletions

View File

@@ -1,12 +1,33 @@
import { Component } from '@angular/core';
import { RouterOutlet } from '@angular/router';
import { HTTP_INTERCEPTORS } from '@angular/common/http';
import { Component, OnInit } from '@angular/core';
import { Router, RouterOutlet } from '@angular/router';
import { DefaultOAuthInterceptor, OAuthService } from 'angular-oauth2-oidc';
@Component({
selector: 'app-root',
imports: [RouterOutlet],
providers: [OAuthService, {
provide: HTTP_INTERCEPTORS,
useClass: DefaultOAuthInterceptor,
multi: true,
}],
templateUrl: './app.html',
styleUrl: './app.scss'
})
export class App {
export class App implements OnInit {
protected title = 'Web';
constructor(private readonly as: OAuthService, private readonly router: Router) {
this.as.configure({
issuer: 'https://identity.lesko.me',
redirectUri: 'http://localhost:4200/login',
clientId: '21131567-fea1-42a2-8907-21abd874eff8',
scope: 'openid profile email',
responseType: 'code',
showDebugInformation: true,
timeoutFactor: 0.01,
});
}
ngOnInit(): void {
this.as.loadDiscoveryDocumentAndLogin();
}
}