Skip to content

Commit d29bb93

Browse files
mattjokeHejdaJakub
authored andcommitted
feat: remove access for service-accounts
* service accounts are now not able to log in * a new dialog has been added, that can redirect users to /login or /service-access * the dialog logic is evaluated when principal is loading
1 parent 1deaa02 commit d29bb93

File tree

14 files changed

+79
-0
lines changed

14 files changed

+79
-0
lines changed

apps/admin-gui/src/assets/i18n/en.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3104,6 +3104,11 @@
31043104
"USER_DONT_EXIST": {
31053105
"TITLE": "The requested user (by Id or external identity) doesn't exist."
31063106
},
3107+
"USER_NOT_ALLOWED": {
3108+
"TITLE": "Access not allowed",
3109+
"MESSAGE": "Service accounts are not allowed to access this application.",
3110+
"REDIRECT": "Redirect to login page"
3111+
},
31073112
"TABLE_OPTIONS": {
31083113
"EXPORT_TO_FILE": "Export to file",
31093114
"ALL_DATA": "All data",

apps/consolidator/src/assets/i18n/en.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@
7676
"REMOVE": "Remove",
7777
"SUCCESS": "User account successfully removed"
7878
}
79+
},
80+
"USER_NOT_ALLOWED": {
81+
"TITLE": "Access not allowed",
82+
"MESSAGE": "Service accounts are not allowed to access this application.",
83+
"REDIRECT": "Redirect to login page"
7984
}
8085
},
8186
"CONSOLIDATOR": {

apps/linker/src/assets/i18n/en.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@
3535
"FOCUS_ON_MFA_DIALOG": {
3636
"MODAL": "Modal window is opened.",
3737
"MODAL_WARNING": "Please check your browser settings if no modal window is open."
38+
},
39+
"USER_NOT_ALLOWED": {
40+
"TITLE": "Access not allowed",
41+
"MESSAGE": "Service accounts are not allowed to access this application.",
42+
"REDIRECT": "Redirect to login page"
3843
}
3944
}
4045
},

apps/password-reset/src/assets/i18n/cs.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@
3838
"USER_DONT_EXIST": {
3939
"TITLE": "Požadovaný uživatel (dle ID nebo externí identity) neexistuje."
4040
},
41+
"USER_NOT_ALLOWED": {
42+
"TITLE": "Přístup není povolen",
43+
"MESSAGE": "Servisní účty (Service account) nemají povolen přístup k této aplikaci.",
44+
"REDIRECT": "Přesměrovaní na přihlášení"
45+
},
4146
"SESSION_EXPIRATION": {
4247
"TITLE": "Platnost přihlášení vypršela",
4348
"DESCRIPTION": "Byli jste automaticky odhlášeni. Pro pokračování se znovu přihlaste.",

apps/password-reset/src/assets/i18n/en.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@
3838
"USER_DONT_EXIST": {
3939
"TITLE": "Requested user (by ID or external identity) doesn't exist."
4040
},
41+
"USER_NOT_ALLOWED": {
42+
"TITLE": "Access not allowed",
43+
"MESSAGE": "Service accounts are not allowed to access this application.",
44+
"REDIRECT": "Redirect to login page"
45+
},
4146
"SESSION_EXPIRATION": {
4247
"TITLE": "Session expiration",
4348
"DESCRIPTION": "Your session has expired. Please sign in to continue.",

apps/publications/src/assets/i18n/en.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,11 @@
356356
"USER_DONT_EXIST": {
357357
"TITLE": "Requested user (by ID or external identity) doesn't exist."
358358
},
359+
"USER_NOT_ALLOWED": {
360+
"TITLE": "Access not allowed",
361+
"MESSAGE": "Service accounts are not allowed to access this application.",
362+
"REDIRECT": "Redirect to login page"
363+
},
359364
"TABLE_OPTIONS": {
360365
"EXPORT_TO_FILE": "Export to file",
361366
"ALL_DATA": "All data",

apps/user-profile/src/assets/i18n/cs.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,11 @@
309309
"USER_DONT_EXIST": {
310310
"TITLE": "Požadovaný uživatel (dle ID nebo externí identity) neexistuje."
311311
},
312+
"USER_NOT_ALLOWED": {
313+
"TITLE": "Přístup není povolen",
314+
"MESSAGE": "Servisní účty (Service account) nemají povolen přístup k této aplikaci.",
315+
"REDIRECT": "Přesměrovaní na přihlášení"
316+
},
312317
"TABLE_OPTIONS": {
313318
"EXPORT_TO_FILE": "Exportovat do souboru",
314319
"ALL_DATA": "Všechna data",

apps/user-profile/src/assets/i18n/en.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,11 @@
353353
"USER_DONT_EXIST": {
354354
"TITLE": "Requested user (by ID or external identity) doesn't exist."
355355
},
356+
"USER_NOT_ALLOWED": {
357+
"TITLE": "Access not allowed",
358+
"MESSAGE": "Service accounts are not allowed to access this application.",
359+
"REDIRECT": "Redirect to login page"
360+
},
356361
"TABLE_OPTIONS": {
357362
"EXPORT_TO_FILE": "Export to file",
358363
"ALL_DATA": "All data",

libs/general/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ export * from './lib/general.module';
22
export * from './lib/server-down-dialog/server-down-dialog.component';
33
export * from './lib/user-dont-exist-dialog/user-dont-exist-dialog.component';
44
export * from './lib/prevent-proxy-overload-dialog/prevent-proxy-overload-dialog.component';
5+
export * from './lib/user-not-allowed-access/user-not-allowed-access.component';

libs/general/src/lib/general.module.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,20 @@ import { MatButtonModule } from '@angular/material/button';
66
import { UserDontExistDialogComponent } from './user-dont-exist-dialog/user-dont-exist-dialog.component';
77
import { TranslateModule } from '@ngx-translate/core';
88
import { PreventProxyOverloadDialogComponent } from './prevent-proxy-overload-dialog/prevent-proxy-overload-dialog.component';
9+
import { UserNotAllowedAccessComponent } from './user-not-allowed-access/user-not-allowed-access.component';
910

1011
@NgModule({
1112
imports: [CommonModule, MatDialogModule, MatButtonModule, TranslateModule],
1213
exports: [
1314
ServerDownDialogComponent,
1415
UserDontExistDialogComponent,
16+
UserNotAllowedAccessComponent,
1517
PreventProxyOverloadDialogComponent,
1618
],
1719
declarations: [
1820
ServerDownDialogComponent,
1921
UserDontExistDialogComponent,
22+
UserNotAllowedAccessComponent,
2023
PreventProxyOverloadDialogComponent,
2124
],
2225
})
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<h1 mat-dialog-title>
2+
{{'SHARED_LIB.PERUN.COMPONENTS.USER_NOT_ALLOWED.TITLE' | translate}}
3+
</h1>
4+
<div mat-dialog-content class="dialog-container">
5+
{{'SHARED_LIB.PERUN.COMPONENTS.USER_NOT_ALLOWED.MESSAGE' | translate}}
6+
</div>
7+
<div mat-dialog-actions>
8+
<button mat-flat-button class="ms-auto" color="accent" (click)="redirect()">
9+
{{'SHARED_LIB.PERUN.COMPONENTS.USER_NOT_ALLOWED.REDIRECT' | translate}}
10+
</button>
11+
</div>

libs/general/src/lib/user-not-allowed-access/user-not-allowed-access.component.scss

Whitespace-only changes.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { Component } from '@angular/core';
2+
import { MatDialogRef } from '@angular/material/dialog';
3+
4+
@Component({
5+
selector: 'perun-web-apps-user-dont-exist-dialog',
6+
templateUrl: './user-not-allowed-access.component.html',
7+
styleUrls: ['./user-not-allowed-access.component.scss'],
8+
})
9+
export class UserNotAllowedAccessComponent {
10+
constructor(public dialogRef: MatDialogRef<UserNotAllowedAccessComponent>) {}
11+
12+
redirect(): void {
13+
this.dialogRef.close();
14+
}
15+
}

libs/perun/services/src/lib/init-auth.service.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { OAuthInfoEvent, OAuthService } from 'angular-oauth2-oidc';
1212
import { filter } from 'rxjs/operators';
1313
import { firstValueFrom, timer } from 'rxjs';
1414
import { MfaHandlerService } from './mfa-handler.service';
15+
import { UserNotAllowedAccessComponent } from '@perun-web-apps/general';
1516

1617
@Injectable({
1718
providedIn: 'root',
@@ -109,6 +110,14 @@ export class InitAuthService {
109110
if (perunPrincipal.user === null) {
110111
const config = getDefaultDialogConfig();
111112
this.dialog.open(UserDontExistDialogComponent, config);
113+
} else if (perunPrincipal.user.serviceUser) {
114+
const config = getDefaultDialogConfig();
115+
this.dialog
116+
.open(UserNotAllowedAccessComponent, config)
117+
.afterClosed()
118+
.subscribe(() => {
119+
this.authService.logout();
120+
});
112121
} else {
113122
this.storeService.setPerunPrincipal(perunPrincipal);
114123
this.authResolver.init(perunPrincipal);

0 commit comments

Comments
 (0)