This repository has been archived by the owner on Jan 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable/disable API keys UI given API keys config setting (#4559)
* Add a special type and parsing for the new config option * Add APIKeysEnabled to /info, check it in the middleware * Add test coverage for apiKeyMiddleware * Block API keys endpoints if disabled in the config; add tests * Fix failing test * Add API_KEYS_ENABLED to the Helm chart * Add JSON schema to the Helm chart * Enable/disable API keys UI given API keys config setting * Changes following review * Fix unit tests Co-authored-by: Ivan Kapelyukhin <ikapelyukhin@suse.com>
- Loading branch information
1 parent
cfbfab8
commit 6af9d88
Showing
27 changed files
with
171 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/frontend/packages/core/src/core/apiKey-auth-guard.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { CanActivate } from '@angular/router'; | ||
import { Store } from '@ngrx/store'; | ||
import { Observable } from 'rxjs'; | ||
import { map } from 'rxjs/operators'; | ||
|
||
import { RouterNav } from '../../../store/src/actions/router.actions'; | ||
import { AppState } from '../../../store/src/app-state'; | ||
import { CurrentUserPermissionsService } from './permissions/current-user-permissions.service'; | ||
import { StratosCurrentUserPermissions } from './permissions/stratos-user-permissions.checker'; | ||
|
||
@Injectable() | ||
export class APIKeyAuthGuardService implements CanActivate { | ||
|
||
constructor( | ||
private store: Store<AppState>, | ||
private cups: CurrentUserPermissionsService, | ||
) { } | ||
|
||
canActivate(): Observable<boolean> { | ||
return this.cups.can(StratosCurrentUserPermissions.API_KEYS).pipe( | ||
map(can => { | ||
if (!can) { | ||
this.store.dispatch(new RouterNav({ path: ['/'] })); | ||
} | ||
return can; | ||
}) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.