diff --git a/docker/local-prod/docker-compose.yml b/docker/local-prod/docker-compose.yml index 5bb2c5e1a7..57649023c7 100644 --- a/docker/local-prod/docker-compose.yml +++ b/docker/local-prod/docker-compose.yml @@ -38,6 +38,7 @@ services: angular: container_name: angular image: node:20 + user: "${UID:-1000}:${GID:-1000}" volumes: - ../../../okr:/opt - /etc/passwd:/etc/passwd:ro diff --git a/frontend/src/app/app-routing.module.ts b/frontend/src/app/app-routing.module.ts index da3f357c23..b62a90a4f7 100644 --- a/frontend/src/app/app-routing.module.ts +++ b/frontend/src/app/app-routing.module.ts @@ -3,7 +3,6 @@ import { ActivatedRouteSnapshot, ResolveFn, RouterModule, Routes } from '@angula import { OverviewComponent } from './overview/overview.component'; import { EMPTY, of } from 'rxjs'; import { SidepanelComponent } from './shared/custom/sidepanel/sidepanel.component'; -import { authGuard } from './shared/guards/auth.guard'; import { AutoLoginPartialRoutesGuard } from 'angular-auth-oidc-client'; import { CallbackComponent } from './callback/callback.component'; diff --git a/frontend/src/app/app.component.ts b/frontend/src/app/app.component.ts index cdd2114055..6f601629c9 100644 --- a/frontend/src/app/app.component.ts +++ b/frontend/src/app/app.component.ts @@ -1,4 +1,4 @@ -import { ChangeDetectionStrategy, Component, OnDestroy, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; import { OidcSecurityService } from 'angular-auth-oidc-client'; @Component({ @@ -10,8 +10,6 @@ import { OidcSecurityService } from 'angular-auth-oidc-client'; export class AppComponent implements OnInit { constructor(private oidcSecurityService: OidcSecurityService) {} ngOnInit(): void { - this.oidcSecurityService - .checkAuth() - .subscribe(({ isAuthenticated, userData, accessToken, idToken, configId }) => {}); + this.oidcSecurityService.checkAuth().subscribe(); } } diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts index 4053ce859e..098c43c70c 100644 --- a/frontend/src/app/app.module.ts +++ b/frontend/src/app/app.module.ts @@ -203,8 +203,8 @@ export const MY_FORMATS = { }, { provide: MAT_DATE_FORMATS, useValue: MY_FORMATS }, { provide: HTTP_INTERCEPTORS, useClass: OauthInterceptor, multi: true }, - { provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true }, - // { provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, multi: true }, + // { provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true }, + { provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, multi: true }, { provide: AbstractSecurityStorage, useClass: DefaultLocalStorageService, diff --git a/frontend/src/app/application-top-bar/application-top-bar.component.ts b/frontend/src/app/application-top-bar/application-top-bar.component.ts index 4785a36baa..7621289932 100644 --- a/frontend/src/app/application-top-bar/application-top-bar.component.ts +++ b/frontend/src/app/application-top-bar/application-top-bar.component.ts @@ -48,10 +48,7 @@ export class ApplicationTopBarComponent implements OnInit, OnDestroy { } username() { - return this.oauthService.getUserData().pipe( - map((user) => user?.name || 'No username available'), - switchMap((username) => (username ? of(username) : of('no username received'))), - ); + return this.oauthService.getUserData().pipe(map((user) => user?.name || '')); } openTeamManagement() { diff --git a/frontend/src/app/callback/callback.component.cy.ts b/frontend/src/app/callback/callback.component.cy.ts deleted file mode 100644 index 3d4527e6fc..0000000000 --- a/frontend/src/app/callback/callback.component.cy.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { CallbackComponent } from './callback.component'; - -describe('CallbackComponent', () => { - // it('should mount', () => { - // cy.mount(CallbackComponent); - // }); -}); diff --git a/frontend/src/app/shared/dialog/key-result-form/key-result-form.component.ts b/frontend/src/app/shared/dialog/key-result-form/key-result-form.component.ts index 62cd8bba32..da971d3b9c 100644 --- a/frontend/src/app/shared/dialog/key-result-form/key-result-form.component.ts +++ b/frontend/src/app/shared/dialog/key-result-form/key-result-form.component.ts @@ -62,11 +62,12 @@ export class KeyResultFormComponent implements OnInit { ]); this.users$.subscribe((users) => { - const loggedInUser = this.getUserName(); - users.forEach((user) => { - if (user.firstname + ' ' + user.lastname === loggedInUser) { - this.keyResultForm.controls['owner'].setValue(user); - } + this.getUserName().subscribe((userName) => { + users.forEach((user) => { + if (user.firstname + ' ' + user.lastname === userName) { + this.keyResultForm.controls['owner'].setValue(user); + } + }); }); }); } @@ -131,7 +132,6 @@ export class KeyResultFormComponent implements OnInit { updateFormValidity() {} getUserName() { - // return this.oauthService.getUserData()['name']; - return ''; + return this.oauthService.getUserData().pipe(map((user) => user?.name || '')); } } diff --git a/frontend/src/app/shared/guards/auth.guard.ts b/frontend/src/app/shared/guards/auth.guard.ts index 3e85dd5066..bc78fc7b84 100644 --- a/frontend/src/app/shared/guards/auth.guard.ts +++ b/frontend/src/app/shared/guards/auth.guard.ts @@ -3,20 +3,17 @@ import { inject } from '@angular/core'; import { OidcSecurityService } from 'angular-auth-oidc-client'; import { map, take } from 'rxjs'; +//Not used, can be deleted export const authGuard: CanActivateFn = (route, state) => { const oidcSecurityService = inject(OidcSecurityService); - const router = inject(Router); return oidcSecurityService.isAuthenticated$.pipe( take(1), map(({ isAuthenticated }) => { // allow navigation if authenticated - if (isAuthenticated) { - return true; - } + return isAuthenticated; // redirect if not authenticated - return router.parseUrl('/unauthorized'); }), ); }; diff --git a/frontend/src/environments/environment.prod.ts b/frontend/src/environments/environment.prod.ts index 5bab405857..c1698b7b49 100644 --- a/frontend/src/environments/environment.prod.ts +++ b/frontend/src/environments/environment.prod.ts @@ -6,7 +6,6 @@ export const environment = { oauth: { decreaseExpirationBySec: 30, clearHashAfterLogin: true, - secureRoutes: ['**', 'http://localhost:4200/', 'http://localhost:8080/', 'localhost:8080/'], authority: 'https://sso.puzzle.ch/auth/realms/pitc', strictDiscoveryDocumentValidation: false, customQueryParams: { response_modes_supported: ['query'] }, diff --git a/frontend/src/environments/environment.ts b/frontend/src/environments/environment.ts index 28dbbbe440..cd9e37f1dd 100644 --- a/frontend/src/environments/environment.ts +++ b/frontend/src/environments/environment.ts @@ -8,7 +8,6 @@ export const environment = { production: false, staging: false, oauth: { - secureRoutes: ['http://localhost:4200/', 'http://localhost:8080/'], postLoginRoute: '/dashboard', // decreaseExpirationBySec: 30, // clearHashAfterLogin: true,