Added Auth Silent Refresh with ImplicitFlow

This commit is contained in:
Lorenz Hilpert
2020-02-13 19:38:10 +01:00
parent 6b61126d66
commit 9c33b2887b
5 changed files with 84 additions and 20 deletions

View File

@@ -27,8 +27,13 @@
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": ["libs/ui/tsconfig.lib.json", "libs/ui/tsconfig.spec.json"],
"exclude": ["**/node_modules/**"]
"tsConfig": [
"libs/ui/tsconfig.lib.json",
"libs/ui/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
@@ -48,8 +53,15 @@
"main": "apps/sales/src/main.ts",
"polyfills": "apps/sales/src/polyfills.ts",
"tsConfig": "apps/sales/tsconfig.app.json",
"assets": ["apps/sales/src/favicon.ico", "apps/sales/src/assets", "apps/sales/src/manifest.webmanifest"],
"styles": ["apps/sales/src/styles.scss"],
"assets": [
"apps/sales/src/favicon.ico",
"apps/sales/src/assets",
"apps/sales/src/manifest.webmanifest",
"apps/sales/src/silent-refresh.html"
],
"styles": [
"apps/sales/src/styles.scss"
],
"scripts": []
},
"configurations": {
@@ -132,16 +144,27 @@
"polyfills": "apps/sales/src/polyfills.ts",
"tsConfig": "apps/sales/tsconfig.spec.json",
"karmaConfig": "apps/sales/karma.conf.js",
"styles": ["apps/sales/src/styles.scss"],
"styles": [
"apps/sales/src/styles.scss"
],
"scripts": [],
"assets": ["apps/sales/src/favicon.ico", "apps/sales/src/assets", "apps/sales/src/manifest.webmanifest"]
"assets": [
"apps/sales/src/favicon.ico",
"apps/sales/src/assets",
"apps/sales/src/manifest.webmanifest"
]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": ["apps/sales/tsconfig.app.json", "apps/sales/tsconfig.spec.json"],
"exclude": ["**/node_modules/**"]
"tsConfig": [
"apps/sales/tsconfig.app.json",
"apps/sales/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
@@ -170,7 +193,9 @@
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": "apps/sales-e2e/tsconfig.e2e.json",
"exclude": ["**/node_modules/**"]
"exclude": [
"**/node_modules/**"
]
}
}
}
@@ -199,8 +224,13 @@
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": ["libs/swagger/tsconfig.lib.json", "libs/swagger/tsconfig.spec.json"],
"exclude": ["**/node_modules/**"]
"tsConfig": [
"libs/swagger/tsconfig.lib.json",
"libs/swagger/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
@@ -229,8 +259,13 @@
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": ["libs/mock/tsconfig.lib.json", "libs/mock/tsconfig.spec.json"],
"exclude": ["**/node_modules/**"]
"tsConfig": [
"libs/mock/tsconfig.lib.json",
"libs/mock/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
@@ -259,8 +294,13 @@
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": ["libs/shared/tsconfig.lib.json", "libs/shared/tsconfig.spec.json"],
"exclude": ["**/node_modules/**"]
"tsConfig": [
"libs/shared/tsconfig.lib.json",
"libs/shared/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
@@ -289,12 +329,17 @@
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": ["libs/sso/tsconfig.lib.json", "libs/sso/tsconfig.spec.json"],
"exclude": ["**/node_modules/**"]
"tsConfig": [
"libs/sso/tsconfig.lib.json",
"libs/sso/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
}
},
"defaultProject": "sales"
}
}

View File

@@ -0,0 +1,9 @@
<html>
<body>
<script>
parent.postMessage(location.hash, location.origin);
</script>
</body>
</html>

View File

@@ -14,9 +14,12 @@ export const authConfig: AuthConfig = {
oidc: true,
// URL of the SPA to redirect the user after silent refresh
silentRefreshRedirectUri: window.location.origin + '/silent-refresh.html',
// set the scope for the permissions the client should request
// The first three are defined by OIDC. The 4th is a usecase-specific one
scope:
// tslint:disable-next-line: max-line-length
'openid profile cmf_user isa-isa-webapi isa-checkout-webapi isa-cat-webapi isa-ava-webapi isa-crm-webapi isa-review-webapi isa-kpi-webapi isa-oms-webapi isa-nbo-webapi isa-print-webapi eis-service'
'openid profile cmf_user isa-isa-webapi isa-checkout-webapi isa-cat-webapi isa-ava-webapi isa-crm-webapi isa-review-webapi isa-kpi-webapi isa-oms-webapi isa-nbo-webapi isa-print-webapi eis-service isa-inv-webapi'
};

View File

@@ -14,9 +14,12 @@ export const authConfig: AuthConfig = {
oidc: true,
// URL of the SPA to redirect the user after silent refresh
silentRefreshRedirectUri: window.location.origin + '/silent-refresh.html',
// set the scope for the permissions the client should request
// The first three are defined by OIDC. The 4th is a usecase-specific one
scope:
// tslint:disable-next-line: max-line-length
'openid profile cmf_user isa-isa-webapi isa-checkout-webapi isa-cat-webapi isa-ava-webapi isa-crm-webapi isa-review-webapi isa-kpi-webapi isa-oms-webapi isa-nbo-webapi isa-print-webapi eis-service'
'openid profile cmf_user isa-isa-webapi isa-checkout-webapi isa-cat-webapi isa-ava-webapi isa-crm-webapi isa-review-webapi isa-kpi-webapi isa-oms-webapi isa-nbo-webapi isa-print-webapi eis-service isa-inv-webapi'
};

View File

@@ -13,6 +13,10 @@ export class SsoService {
this.oauthService.configure(this.externalService.getConfigurations());
this.oauthService.tokenValidationHandler = new JwksValidationHandler();
if (!!this.oauthService.silentRefreshRedirectUri) {
this.oauthService.setupAutomaticSilentRefresh();
}
return this.oauthService.loadDiscoveryDocumentAndTryLogin().then(_ => {
const hasIdToken = !!this.getIdToken();
const hasAccessToken = !!this.getToken();