feat(console): refresh toggle out of granttype context (#1785)

* refresh toggle

* disable if not code flow, lint

* lint

* fix: change oidc config order

* accept refresh option within flow

Co-authored-by: Livio Amstutz <livio.a@gmail.com>
This commit is contained in:
Max Peintner 2021-05-31 09:04:49 +02:00 committed by GitHub
parent 769fb93506
commit 1f41cc5ca8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 301 additions and 221 deletions

View File

@ -198,11 +198,21 @@
</div> </div>
<div class="content"> <div class="content">
<div class="grid">
<cnsl-form-field class="formfield" appearance="outline"> <cnsl-form-field class="formfield" appearance="outline">
<cnsl-label>{{ 'APP.OIDC.CLIENTID' | translate }}</cnsl-label> <cnsl-label>{{ 'APP.OIDC.CLIENTID' | translate }}</cnsl-label>
<input cnslInput formControlName="clientId" /> <input cnslInput formControlName="clientId" />
</cnsl-form-field> </cnsl-form-field>
<cnsl-form-field appearance="outline" class="formfield">
<cnsl-label>{{ 'APP.TYPE' | translate }}</cnsl-label>
<mat-select formControlName="appType">
<mat-option *ngFor="let type of oidcAppTypes" [value]="type">
{{ 'APP.OIDC.APPTYPE.'+type | translate }}
</mat-option>
</mat-select>
</cnsl-form-field>
<cnsl-form-field class="formfield" appearance="outline"> <cnsl-form-field class="formfield" appearance="outline">
<cnsl-label>{{ 'APP.OIDC.RESPONSETYPE' | translate }}</cnsl-label> <cnsl-label>{{ 'APP.OIDC.RESPONSETYPE' | translate }}</cnsl-label>
<mat-select formControlName="responseTypesList" multiple> <mat-select formControlName="responseTypesList" multiple>
@ -212,24 +222,6 @@
</mat-select> </mat-select>
</cnsl-form-field> </cnsl-form-field>
<cnsl-form-field class="formfield" appearance="outline">
<cnsl-label>{{ 'APP.OIDC.GRANTTYPE' | translate }}</cnsl-label>
<mat-select formControlName="grantTypesList" multiple>
<mat-option *ngFor="let grant of oidcGrantTypes" [value]="grant">
{{ 'APP.OIDC.GRANT.'+grant | translate }}
</mat-option>
</mat-select>
</cnsl-form-field>
<cnsl-form-field appearance="outline" class="formfield">
<cnsl-label>{{ 'APP.TYPE' | translate }}</cnsl-label>
<mat-select formControlName="appType">
<mat-option *ngFor="let type of oidcAppTypes" [value]="type">
{{ 'APP.OIDC.APPTYPE.'+type | translate }}
</mat-option>
</mat-select>
</cnsl-form-field>
<cnsl-form-field appearance="outline" class="formfield"> <cnsl-form-field appearance="outline" class="formfield">
<cnsl-label>{{ 'APP.AUTHMETHOD' | translate }}</cnsl-label> <cnsl-label>{{ 'APP.AUTHMETHOD' | translate }}</cnsl-label>
<mat-select formControlName="authMethodType"> <mat-select formControlName="authMethodType">
@ -239,6 +231,21 @@
</mat-select> </mat-select>
</cnsl-form-field> </cnsl-form-field>
<cnsl-form-field class="formfield" appearance="outline">
<cnsl-label>{{ 'APP.OIDC.GRANTTYPE' | translate }}</cnsl-label>
<mat-select formControlName="grantTypesList" multiple>
<mat-option *ngFor="let grant of oidcGrantTypes" [value]="grant">
{{ 'APP.OIDC.GRANT.'+grant | translate }}
</mat-option>
</mat-select>
</cnsl-form-field>
<mat-checkbox color="primary" class="rt"
(change)="toggleRefreshToken($event)" [disabled]="!this.grantTypesList?.value.includes(OIDCGrantType.OIDC_GRANT_TYPE_AUTHORIZATION_CODE)" [checked]="this.grantTypesList?.value.includes(OIDCGrantType.OIDC_GRANT_TYPE_REFRESH_TOKEN)">
{{ 'APP.OIDC.REFRESHTOKEN' | translate }}
</mat-checkbox>
</div>
<div class="divider"></div> <div class="divider"></div>
<p class="full-width section-title">{{'APP.OIDC.TOKENSECTIONTITLE' | translate}}</p> <p class="full-width section-title">{{'APP.OIDC.TOKENSECTIONTITLE' | translate}}</p>
@ -311,4 +318,4 @@
<app-changes *ngIf="app" [changeType]="ChangeType.APP" [id]="app.id" [secId]="projectId"></app-changes> <app-changes *ngIf="app" [changeType]="ChangeType.APP" [id]="app.id" [secId]="projectId"></app-changes>
</div> </div>
</app-meta-layout> </app-meta-layout>

View File

@ -142,6 +142,17 @@
flex-wrap: wrap; flex-wrap: wrap;
margin: 0 -.5rem; margin: 0 -.5rem;
.grid {
width: 100%;
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
.rt {
margin-top: 2.3rem;
margin-left: .5rem;
}
}
&.nowrap { &.nowrap {
flex-wrap: nowrap; flex-wrap: nowrap;
} }

View File

@ -3,6 +3,7 @@ import { Location } from '@angular/common';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { Component, OnDestroy, OnInit } from '@angular/core'; import { Component, OnDestroy, OnInit } from '@angular/core';
import { AbstractControl, FormBuilder, FormGroup, Validators } from '@angular/forms'; import { AbstractControl, FormBuilder, FormGroup, Validators } from '@angular/forms';
import { MatCheckboxChange } from '@angular/material/checkbox';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
import { MatSnackBar } from '@angular/material/snack-bar'; import { MatSnackBar } from '@angular/material/snack-bar';
import { ActivatedRoute, Params, Router } from '@angular/router'; import { ActivatedRoute, Params, Router } from '@angular/router';
@ -112,6 +113,7 @@ export class AppDetailComponent implements OnInit, OnDestroy {
public OIDCAuthMethodType: any = OIDCAuthMethodType; public OIDCAuthMethodType: any = OIDCAuthMethodType;
public APIAuthMethodType: any = APIAuthMethodType; public APIAuthMethodType: any = APIAuthMethodType;
public OIDCTokenType: any = OIDCTokenType; public OIDCTokenType: any = OIDCTokenType;
public OIDCGrantType: any = OIDCGrantType;
public ChangeType: any = ChangeType; public ChangeType: any = ChangeType;
@ -439,6 +441,24 @@ export class AppDetailComponent implements OnInit, OnDestroy {
} }
} }
public toggleRefreshToken(event: MatCheckboxChange): void {
const c = this.grantTypesList?.value;
if (event.checked) {
if (!c.includes(OIDCGrantType.OIDC_GRANT_TYPE_REFRESH_TOKEN)) {
this.grantTypesList?.setValue([OIDCGrantType.OIDC_GRANT_TYPE_REFRESH_TOKEN, ...c]);
}
} else {
const index = (this.grantTypesList?.value as OIDCGrantType[])
.findIndex(gt => gt === OIDCGrantType.OIDC_GRANT_TYPE_REFRESH_TOKEN);
if (index > -1) {
const copy = Object.assign([], this.grantTypesList?.value);
copy.splice(index, 1);
this.grantTypesList?.setValue(copy);
}
}
}
public saveOIDCApp(): void { public saveOIDCApp(): void {
this.requestRedirectValuesSubject$.next(); this.requestRedirectValuesSubject$.next();

View File

@ -1,237 +1,277 @@
import { RadioItemAuthType } from 'src/app/modules/app-radio/app-auth-method-radio/app-auth-method-radio.component'; import { RadioItemAuthType } from 'src/app/modules/app-radio/app-auth-method-radio/app-auth-method-radio.component';
import { import {
APIAuthMethodType, APIAuthMethodType,
APIConfig, APIConfig,
OIDCAuthMethodType, OIDCAuthMethodType,
OIDCConfig, OIDCConfig,
OIDCGrantType, OIDCGrantType,
OIDCResponseType, OIDCResponseType,
} from 'src/app/proto/generated/zitadel/app_pb'; } from 'src/app/proto/generated/zitadel/app_pb';
export const CODE_METHOD: RadioItemAuthType = { export const CODE_METHOD: RadioItemAuthType = {
key: 'CODE', key: 'CODE',
titleI18nKey: 'APP.AUTHMETHODS.CODE.TITLE', titleI18nKey: 'APP.AUTHMETHODS.CODE.TITLE',
descI18nKey: 'APP.AUTHMETHODS.CODE.DESCRIPTION', descI18nKey: 'APP.AUTHMETHODS.CODE.DESCRIPTION',
disabled: false, disabled: false,
prefix: 'CODE', prefix: 'CODE',
background: 'rgb(89 115 128)', background: 'rgb(89 115 128)',
responseType: OIDCResponseType.OIDC_RESPONSE_TYPE_CODE, responseType: OIDCResponseType.OIDC_RESPONSE_TYPE_CODE,
grantType: OIDCGrantType.OIDC_GRANT_TYPE_AUTHORIZATION_CODE, grantType: OIDCGrantType.OIDC_GRANT_TYPE_AUTHORIZATION_CODE,
authMethod: OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_BASIC, authMethod: OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_BASIC,
recommended: false, recommended: false,
}; };
export const PKCE_METHOD: RadioItemAuthType = { export const PKCE_METHOD: RadioItemAuthType = {
key: 'PKCE', key: 'PKCE',
titleI18nKey: 'APP.AUTHMETHODS.PKCE.TITLE', titleI18nKey: 'APP.AUTHMETHODS.PKCE.TITLE',
descI18nKey: 'APP.AUTHMETHODS.PKCE.DESCRIPTION', descI18nKey: 'APP.AUTHMETHODS.PKCE.DESCRIPTION',
disabled: false, disabled: false,
prefix: 'PKCE', prefix: 'PKCE',
background: 'rgb(80 110 92)', background: 'rgb(80 110 92)',
responseType: OIDCResponseType.OIDC_RESPONSE_TYPE_CODE, responseType: OIDCResponseType.OIDC_RESPONSE_TYPE_CODE,
grantType: OIDCGrantType.OIDC_GRANT_TYPE_AUTHORIZATION_CODE, grantType: OIDCGrantType.OIDC_GRANT_TYPE_AUTHORIZATION_CODE,
authMethod: OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_NONE, authMethod: OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_NONE,
recommended: true, recommended: true,
}; };
export const POST_METHOD: RadioItemAuthType = { export const POST_METHOD: RadioItemAuthType = {
key: 'POST', key: 'POST',
titleI18nKey: 'APP.AUTHMETHODS.POST.TITLE', titleI18nKey: 'APP.AUTHMETHODS.POST.TITLE',
descI18nKey: 'APP.AUTHMETHODS.POST.DESCRIPTION', descI18nKey: 'APP.AUTHMETHODS.POST.DESCRIPTION',
disabled: false, disabled: false,
prefix: 'POST', prefix: 'POST',
background: 'rgb(144 75 75)', background: 'rgb(144 75 75)',
responseType: OIDCResponseType.OIDC_RESPONSE_TYPE_CODE, responseType: OIDCResponseType.OIDC_RESPONSE_TYPE_CODE,
grantType: OIDCGrantType.OIDC_GRANT_TYPE_AUTHORIZATION_CODE, grantType: OIDCGrantType.OIDC_GRANT_TYPE_AUTHORIZATION_CODE,
authMethod: OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_POST, authMethod: OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_POST,
notRecommended: true, notRecommended: true,
}; };
export const PK_JWT_METHOD: RadioItemAuthType = { export const PK_JWT_METHOD: RadioItemAuthType = {
key: 'PK_JWT', key: 'PK_JWT',
titleI18nKey: 'APP.AUTHMETHODS.PK_JWT.TITLE', titleI18nKey: 'APP.AUTHMETHODS.PK_JWT.TITLE',
descI18nKey: 'APP.AUTHMETHODS.PK_JWT.DESCRIPTION', descI18nKey: 'APP.AUTHMETHODS.PK_JWT.DESCRIPTION',
disabled: false, disabled: false,
prefix: 'JWT', prefix: 'JWT',
background: 'rgb(89, 93, 128)', background: 'rgb(89, 93, 128)',
responseType: OIDCResponseType.OIDC_RESPONSE_TYPE_CODE, responseType: OIDCResponseType.OIDC_RESPONSE_TYPE_CODE,
grantType: OIDCGrantType.OIDC_GRANT_TYPE_AUTHORIZATION_CODE, grantType: OIDCGrantType.OIDC_GRANT_TYPE_AUTHORIZATION_CODE,
authMethod: OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT, authMethod: OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT,
apiAuthMethod: APIAuthMethodType.API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT, apiAuthMethod: APIAuthMethodType.API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT,
// recommended: true, // recommended: true,
}; };
export const BASIC_AUTH_METHOD: RadioItemAuthType = { export const BASIC_AUTH_METHOD: RadioItemAuthType = {
key: 'BASIC', key: 'BASIC',
titleI18nKey: 'APP.AUTHMETHODS.BASIC.TITLE', titleI18nKey: 'APP.AUTHMETHODS.BASIC.TITLE',
descI18nKey: 'APP.AUTHMETHODS.BASIC.DESCRIPTION', descI18nKey: 'APP.AUTHMETHODS.BASIC.DESCRIPTION',
disabled: false, disabled: false,
prefix: 'BASIC', prefix: 'BASIC',
background: 'rgb(144 75 75)', background: 'rgb(144 75 75)',
responseType: OIDCResponseType.OIDC_RESPONSE_TYPE_CODE, responseType: OIDCResponseType.OIDC_RESPONSE_TYPE_CODE,
grantType: OIDCGrantType.OIDC_GRANT_TYPE_AUTHORIZATION_CODE, grantType: OIDCGrantType.OIDC_GRANT_TYPE_AUTHORIZATION_CODE,
authMethod: OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_POST, authMethod: OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_POST,
apiAuthMethod: APIAuthMethodType.API_AUTH_METHOD_TYPE_BASIC, apiAuthMethod: APIAuthMethodType.API_AUTH_METHOD_TYPE_BASIC,
}; };
export const IMPLICIT_METHOD: RadioItemAuthType = { export const IMPLICIT_METHOD: RadioItemAuthType = {
key: 'IMPLICIT', key: 'IMPLICIT',
titleI18nKey: 'APP.AUTHMETHODS.IMPLICIT.TITLE', titleI18nKey: 'APP.AUTHMETHODS.IMPLICIT.TITLE',
descI18nKey: 'APP.AUTHMETHODS.IMPLICIT.DESCRIPTION', descI18nKey: 'APP.AUTHMETHODS.IMPLICIT.DESCRIPTION',
disabled: false, disabled: false,
prefix: 'IMP', prefix: 'IMP',
background: 'rgb(144 75 75)', background: 'rgb(144 75 75)',
responseType: OIDCResponseType.OIDC_RESPONSE_TYPE_ID_TOKEN, responseType: OIDCResponseType.OIDC_RESPONSE_TYPE_ID_TOKEN,
grantType: OIDCGrantType.OIDC_GRANT_TYPE_IMPLICIT, grantType: OIDCGrantType.OIDC_GRANT_TYPE_IMPLICIT,
authMethod: OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_NONE, authMethod: OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_NONE,
notRecommended: true, notRecommended: true,
}; };
export const CUSTOM_METHOD: RadioItemAuthType = { export const CUSTOM_METHOD: RadioItemAuthType = {
key: 'CUSTOM', key: 'CUSTOM',
titleI18nKey: 'APP.AUTHMETHODS.CUSTOM.TITLE', titleI18nKey: 'APP.AUTHMETHODS.CUSTOM.TITLE',
descI18nKey: 'APP.AUTHMETHODS.CUSTOM.DESCRIPTION', descI18nKey: 'APP.AUTHMETHODS.CUSTOM.DESCRIPTION',
disabled: false, disabled: false,
prefix: 'CUSTOM', prefix: 'CUSTOM',
background: '#333', background: '#333',
}; };
export function getPartialConfigFromAuthMethod(authMethod: string): { export function getPartialConfigFromAuthMethod(authMethod: string): {
oidc?: Partial<OIDCConfig.AsObject>; oidc?: Partial<OIDCConfig.AsObject>;
api?: Partial<APIConfig.AsObject>; api?: Partial<APIConfig.AsObject>;
} | undefined { } | undefined {
let config: { let config: {
oidc?: Partial<OIDCConfig.AsObject>, oidc?: Partial<OIDCConfig.AsObject>,
api?: Partial<APIConfig.AsObject>, api?: Partial<APIConfig.AsObject>,
}; };
switch (authMethod) { switch (authMethod) {
case CODE_METHOD.key: case CODE_METHOD.key:
config = { config = {
oidc: { oidc: {
responseTypesList: [OIDCResponseType.OIDC_RESPONSE_TYPE_CODE], responseTypesList: [OIDCResponseType.OIDC_RESPONSE_TYPE_CODE],
grantTypesList: [OIDCGrantType.OIDC_GRANT_TYPE_AUTHORIZATION_CODE], grantTypesList: [OIDCGrantType.OIDC_GRANT_TYPE_AUTHORIZATION_CODE],
authMethodType: OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_BASIC, authMethodType: OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_BASIC,
}, },
}; };
return config; return config;
case PKCE_METHOD.key: case PKCE_METHOD.key:
config = { config = {
oidc: { oidc: {
responseTypesList: [OIDCResponseType.OIDC_RESPONSE_TYPE_CODE], responseTypesList: [OIDCResponseType.OIDC_RESPONSE_TYPE_CODE],
grantTypesList: [OIDCGrantType.OIDC_GRANT_TYPE_AUTHORIZATION_CODE], grantTypesList: [OIDCGrantType.OIDC_GRANT_TYPE_AUTHORIZATION_CODE],
authMethodType: OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_NONE, authMethodType: OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_NONE,
}, },
}; };
return config; return config;
case POST_METHOD.key: case POST_METHOD.key:
config = { config = {
oidc: { oidc: {
responseTypesList: [OIDCResponseType.OIDC_RESPONSE_TYPE_CODE], responseTypesList: [OIDCResponseType.OIDC_RESPONSE_TYPE_CODE],
grantTypesList: [OIDCGrantType.OIDC_GRANT_TYPE_AUTHORIZATION_CODE], grantTypesList: [OIDCGrantType.OIDC_GRANT_TYPE_AUTHORIZATION_CODE],
authMethodType: OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_POST, authMethodType: OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_POST,
}, },
}; };
return config; return config;
case PK_JWT_METHOD.key: case PK_JWT_METHOD.key:
config = { config = {
oidc: { oidc: {
responseTypesList: [OIDCResponseType.OIDC_RESPONSE_TYPE_CODE], responseTypesList: [OIDCResponseType.OIDC_RESPONSE_TYPE_CODE],
grantTypesList: [OIDCGrantType.OIDC_GRANT_TYPE_AUTHORIZATION_CODE], grantTypesList: [OIDCGrantType.OIDC_GRANT_TYPE_AUTHORIZATION_CODE],
authMethodType: OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT, authMethodType: OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT,
}, },
api: { api: {
authMethodType: APIAuthMethodType.API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT, authMethodType: APIAuthMethodType.API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT,
}, },
}; };
return config; return config;
case BASIC_AUTH_METHOD.key: case BASIC_AUTH_METHOD.key:
config = { config = {
oidc: { oidc: {
authMethodType: OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_BASIC, authMethodType: OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_BASIC,
}, },
api: { api: {
authMethodType: APIAuthMethodType.API_AUTH_METHOD_TYPE_BASIC, authMethodType: APIAuthMethodType.API_AUTH_METHOD_TYPE_BASIC,
}, },
}; };
return config; return config;
case IMPLICIT_METHOD.key: case IMPLICIT_METHOD.key:
config = { config = {
oidc: { oidc: {
responseTypesList: [OIDCResponseType.OIDC_RESPONSE_TYPE_ID_TOKEN_TOKEN], responseTypesList: [OIDCResponseType.OIDC_RESPONSE_TYPE_ID_TOKEN_TOKEN],
grantTypesList: [OIDCGrantType.OIDC_GRANT_TYPE_IMPLICIT], grantTypesList: [OIDCGrantType.OIDC_GRANT_TYPE_IMPLICIT],
authMethodType: OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_NONE, authMethodType: OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_NONE,
}, },
api: { api: {
authMethodType: APIAuthMethodType.API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT, authMethodType: APIAuthMethodType.API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT,
}, },
}; };
return config; return config;
default: default:
return undefined; return undefined;
} }
} }
export function getAuthMethodFromPartialConfig( export function getAuthMethodFromPartialConfig(
config: { config: {
oidc?: Partial<OIDCConfig.AsObject>, oidc?: Partial<OIDCConfig.AsObject>,
api?: Partial<APIConfig.AsObject>, api?: Partial<APIConfig.AsObject>,
}, },
): string { ): string {
if (config?.oidc) { if (config?.oidc) {
const toCheck = [config.oidc.responseTypesList, config.oidc.grantTypesList, config.oidc.authMethodType]; const toCheck = [config.oidc.responseTypesList, config.oidc.grantTypesList?.sort(), config.oidc.authMethodType];
const code = JSON.stringify( const code = JSON.stringify(
[ [
[OIDCResponseType.OIDC_RESPONSE_TYPE_CODE], [OIDCResponseType.OIDC_RESPONSE_TYPE_CODE],
[OIDCGrantType.OIDC_GRANT_TYPE_AUTHORIZATION_CODE], [OIDCGrantType.OIDC_GRANT_TYPE_AUTHORIZATION_CODE],
OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_BASIC, OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_BASIC,
], ],
); );
const pkce = JSON.stringify( const codeWithRefresh = JSON.stringify(
[ [
[OIDCResponseType.OIDC_RESPONSE_TYPE_CODE], [OIDCResponseType.OIDC_RESPONSE_TYPE_CODE],
[OIDCGrantType.OIDC_GRANT_TYPE_AUTHORIZATION_CODE], [OIDCGrantType.OIDC_GRANT_TYPE_AUTHORIZATION_CODE, OIDCGrantType.OIDC_GRANT_TYPE_REFRESH_TOKEN].sort(),
OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_NONE, OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_BASIC,
], ],
); );
const post = JSON.stringify( const pkce = JSON.stringify(
[ [
[OIDCResponseType.OIDC_RESPONSE_TYPE_CODE], [OIDCResponseType.OIDC_RESPONSE_TYPE_CODE],
[OIDCGrantType.OIDC_GRANT_TYPE_AUTHORIZATION_CODE], [OIDCGrantType.OIDC_GRANT_TYPE_AUTHORIZATION_CODE],
OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_POST, OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_NONE,
], ],
); );
const pkjwt = JSON.stringify( const pkceWithRefresh = JSON.stringify(
[ [
[OIDCResponseType.OIDC_RESPONSE_TYPE_CODE], [OIDCResponseType.OIDC_RESPONSE_TYPE_CODE],
[OIDCGrantType.OIDC_GRANT_TYPE_AUTHORIZATION_CODE], [OIDCGrantType.OIDC_GRANT_TYPE_AUTHORIZATION_CODE, OIDCGrantType.OIDC_GRANT_TYPE_REFRESH_TOKEN].sort(),
OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT, OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_NONE,
], ],
); );
const implicit = JSON.stringify( const post = JSON.stringify(
[ [
[OIDCResponseType.OIDC_RESPONSE_TYPE_ID_TOKEN_TOKEN], [OIDCResponseType.OIDC_RESPONSE_TYPE_CODE],
[OIDCGrantType.OIDC_GRANT_TYPE_IMPLICIT], [OIDCGrantType.OIDC_GRANT_TYPE_AUTHORIZATION_CODE],
OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_NONE, OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_POST,
], ],
); );
switch (JSON.stringify(toCheck)) { const postWithRefresh = JSON.stringify(
case code: return CODE_METHOD.key; [
case pkce: return PKCE_METHOD.key; [OIDCResponseType.OIDC_RESPONSE_TYPE_CODE],
case post: return POST_METHOD.key; [OIDCGrantType.OIDC_GRANT_TYPE_AUTHORIZATION_CODE, OIDCGrantType.OIDC_GRANT_TYPE_REFRESH_TOKEN].sort(),
case pkjwt: return PK_JWT_METHOD.key; OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_POST,
case implicit: return IMPLICIT_METHOD.key; ],
default: );
return CUSTOM_METHOD.key;
} const pkjwt = JSON.stringify(
} else if (config.api && config.api.authMethodType !== undefined) { [
switch (config.api.authMethodType.toString()) { [OIDCResponseType.OIDC_RESPONSE_TYPE_CODE],
case APIAuthMethodType.API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT.toString(): return PK_JWT_METHOD.key; [OIDCGrantType.OIDC_GRANT_TYPE_AUTHORIZATION_CODE],
case APIAuthMethodType.API_AUTH_METHOD_TYPE_BASIC.toString(): return BASIC_AUTH_METHOD.key; OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT,
default: ],
return CUSTOM_METHOD.key; );
}
} else { const pkjwtWithRefresh = JSON.stringify(
[
[OIDCResponseType.OIDC_RESPONSE_TYPE_CODE],
[OIDCGrantType.OIDC_GRANT_TYPE_AUTHORIZATION_CODE, OIDCGrantType.OIDC_GRANT_TYPE_REFRESH_TOKEN].sort(),
OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT,
],
);
const implicit = JSON.stringify(
[
[OIDCResponseType.OIDC_RESPONSE_TYPE_ID_TOKEN_TOKEN],
[OIDCGrantType.OIDC_GRANT_TYPE_IMPLICIT],
OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_NONE,
],
);
switch (JSON.stringify(toCheck)) {
case code: return CODE_METHOD.key;
case codeWithRefresh: return CODE_METHOD.key;
case pkce: return PKCE_METHOD.key;
case pkceWithRefresh: return PKCE_METHOD.key;
case post: return POST_METHOD.key;
case postWithRefresh: return POST_METHOD.key;
case pkjwt: return PK_JWT_METHOD.key;
case pkjwtWithRefresh: return PK_JWT_METHOD.key;
case implicit: return IMPLICIT_METHOD.key;
default:
return CUSTOM_METHOD.key; return CUSTOM_METHOD.key;
} }
} else if (config.api && config.api.authMethodType !== undefined) {
switch (config.api.authMethodType.toString()) {
case APIAuthMethodType.API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT.toString(): return PK_JWT_METHOD.key;
case APIAuthMethodType.API_AUTH_METHOD_TYPE_BASIC.toString(): return BASIC_AUTH_METHOD.key;
default:
return CUSTOM_METHOD.key;
}
} else {
return CUSTOM_METHOD.key;
}
} }

View File

@ -1106,6 +1106,7 @@
"1": "ID-Token", "1": "ID-Token",
"2": "Token-ID-Token" "2": "Token-ID-Token"
}, },
"REFRESHTOKEN":"Refresh Token",
"GRANTTYPE": "Berechtigungstypen", "GRANTTYPE": "Berechtigungstypen",
"GRANT": { "GRANT": {
"0": "Authorisation Code", "0": "Authorisation Code",

View File

@ -1107,6 +1107,7 @@
"1": "ID Token", "1": "ID Token",
"2": "Token-ID Token" "2": "Token-ID Token"
}, },
"REFRESHTOKEN":"Refresh Token",
"GRANTTYPE": "Grant Types", "GRANTTYPE": "Grant Types",
"GRANT": { "GRANT": {
"0": "Authorization Code", "0": "Authorization Code",