Skip to content

Commit cdb82d9

Browse files
Merge pull request #2107 from sparlampe/fix-silent-refresh-iframe-multiple-idp
Fix silent refresh iframe with multiple idps
2 parents 5304cc1 + fde2dce commit cdb82d9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+4764
-1392
lines changed

.eslintrc.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@
8282
"no-case-declarations": ["error"],
8383
"no-empty": ["error"],
8484
"@typescript-eslint/no-empty-function": ["error"],
85-
"@typescript-eslint/ban-types": ["error"],
85+
"@typescript-eslint/no-empty-object-type": ["error"],
86+
"@typescript-eslint/no-unsafe-function-type": ["error"],
87+
"@typescript-eslint/no-wrapper-object-types": ["error"],
8688
"no-useless-escape": ["error"],
8789
"no-prototype-builtins": ["error"],
8890
"prefer-spread": ["error"],

.github/workflows/build.yml

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -77,28 +77,28 @@ jobs:
7777
path: angular-auth-oidc-client-artefact
7878

7979
- name: Install AngularCLI globally
80-
run: sudo npm install -g @angular/cli
80+
run: npm install -g @angular/cli
8181

8282
- name: Show ng Version
8383
run: ng version
8484

8585
- name: Create Angular Project
86-
run: sudo ng new angular-auth-oidc-client-test --skip-git
86+
run: ng new angular-auth-oidc-client-test --skip-git
8787

8888
- name: Npm Install & Install Library from local artefact
8989
run: |
90-
sudo cp -R angular-auth-oidc-client-artefact angular-auth-oidc-client-test/
90+
cp -R angular-auth-oidc-client-artefact angular-auth-oidc-client-test/
9191
cd angular-auth-oidc-client-test
92-
sudo npm install --unsafe-perm=true
93-
sudo ng add ./angular-auth-oidc-client-artefact --authority-url-or-tenant-id "my-authority-url" --flow-type "OIDC Code Flow PKCE using refresh tokens" --use-local-package=true --skip-confirmation
92+
npm install --unsafe-perm=true
93+
ng add ./angular-auth-oidc-client-artefact --authority-url-or-tenant-id "my-authority-url" --flow-type "OIDC Code Flow PKCE using refresh tokens" --use-local-package=true --skip-confirmation
9494
9595
- name: Test Angular Application
9696
working-directory: ./angular-auth-oidc-client-test
9797
run: npm test -- --watch=false --browsers=ChromeHeadless
9898

9999
- name: Build Angular Application
100100
working-directory: ./angular-auth-oidc-client-test
101-
run: sudo npm run build
101+
run: npm run build
102102

103103
AngularLatestVersionWithSchematics:
104104
needs: build_job
@@ -117,28 +117,28 @@ jobs:
117117
path: angular-auth-oidc-client-artefact
118118

119119
- name: Install AngularCLI globally
120-
run: sudo npm install -g @angular/cli
120+
run: npm install -g @angular/cli
121121

122122
- name: Show ng Version
123123
run: ng version
124124

125125
- name: Create Angular Project
126-
run: sudo ng new angular-auth-oidc-client-test --skip-git
126+
run: ng new angular-auth-oidc-client-test --skip-git
127127

128128
- name: Npm Install & Install Library from local artefact
129129
run: |
130-
sudo cp -R angular-auth-oidc-client-artefact angular-auth-oidc-client-test/
130+
cp -R angular-auth-oidc-client-artefact angular-auth-oidc-client-test/
131131
cd angular-auth-oidc-client-test
132-
sudo npm install --unsafe-perm=true
133-
sudo ng add ./angular-auth-oidc-client-artefact --authority-url-or-tenant-id "my-authority-url" --flow-type "Default config" --use-local-package=true --skip-confirmation
132+
npm install --unsafe-perm=true
133+
ng add ./angular-auth-oidc-client-artefact --authority-url-or-tenant-id "my-authority-url" --flow-type "Default config" --use-local-package=true --skip-confirmation
134134
135135
- name: Test Angular Application
136136
working-directory: ./angular-auth-oidc-client-test
137137
run: npm test -- --watch=false --browsers=ChromeHeadless
138138

139139
- name: Build Angular Application
140140
working-directory: ./angular-auth-oidc-client-test
141-
run: sudo npm run build
141+
run: npm run build
142142

143143
AngularLatestVersionWithNgModuleSchematics:
144144
needs: build_job
@@ -157,28 +157,28 @@ jobs:
157157
path: angular-auth-oidc-client-artefact
158158

159159
- name: Install AngularCLI globally
160-
run: sudo npm install -g @angular/cli
160+
run: npm install -g @angular/cli
161161

162162
- name: Show ng Version
163163
run: ng version
164164

165165
- name: Create Angular Project
166-
run: sudo ng new angular-auth-oidc-client-test --skip-git --standalone=false
166+
run: ng new angular-auth-oidc-client-test --skip-git --standalone=false
167167

168168
- name: Npm Install & Install Library from local artefact
169169
run: |
170-
sudo cp -R angular-auth-oidc-client-artefact angular-auth-oidc-client-test/
170+
cp -R angular-auth-oidc-client-artefact angular-auth-oidc-client-test/
171171
cd angular-auth-oidc-client-test
172-
sudo npm install --unsafe-perm=true
173-
sudo ng add ./angular-auth-oidc-client-artefact --authority-url-or-tenant-id "my-authority-url" --flow-type "OIDC Code Flow PKCE using refresh tokens" --use-local-package=true --skip-confirmation
172+
npm install --unsafe-perm=true
173+
ng add ./angular-auth-oidc-client-artefact --authority-url-or-tenant-id "my-authority-url" --flow-type "OIDC Code Flow PKCE using refresh tokens" --use-local-package=true --skip-confirmation
174174
175175
- name: Test Angular Application
176176
working-directory: ./angular-auth-oidc-client-test
177177
run: npm test -- --watch=false --browsers=ChromeHeadless
178178

179179
- name: Build Angular Application
180180
working-directory: ./angular-auth-oidc-client-test
181-
run: sudo npm run build
181+
run: npm run build
182182

183183
Angular16VersionWithRxJs6:
184184
needs: build_job
@@ -197,32 +197,32 @@ jobs:
197197
path: angular-auth-oidc-client-artefact
198198

199199
- name: Install AngularCLI globally
200-
run: sudo npm install -g @angular/cli@16
200+
run: npm install -g @angular/cli@16
201201

202202
- name: Show ng Version
203203
run: ng version
204204

205205
- name: Create Angular Project
206-
run: sudo ng new angular-auth-oidc-client-test --skip-git
206+
run: ng new angular-auth-oidc-client-test --skip-git
207207

208208
- name: npm install RxJs 6
209209
working-directory: ./angular-auth-oidc-client-test
210-
run: sudo npm install [email protected]
210+
run: npm install [email protected]
211211

212212
- name: Npm Install & Install Library from local artefact
213213
run: |
214-
sudo cp -R angular-auth-oidc-client-artefact angular-auth-oidc-client-test/
214+
cp -R angular-auth-oidc-client-artefact angular-auth-oidc-client-test/
215215
cd angular-auth-oidc-client-test
216-
sudo npm install --unsafe-perm=true
217-
sudo ng add ./angular-auth-oidc-client-artefact --authority-url-or-tenant-id "my-authority-url" --flow-type "OIDC Code Flow PKCE using refresh tokens" --use-local-package=true --skip-confirmation
216+
npm install --unsafe-perm=true
217+
ng add ./angular-auth-oidc-client-artefact --authority-url-or-tenant-id "my-authority-url" --flow-type "OIDC Code Flow PKCE using refresh tokens" --use-local-package=true --skip-confirmation
218218
219219
- name: Test Angular Application
220220
working-directory: ./angular-auth-oidc-client-test
221221
run: npm test -- --watch=false --browsers=ChromeHeadless
222222

223223
- name: Build Angular Application
224224
working-directory: ./angular-auth-oidc-client-test
225-
run: sudo npm run build
225+
run: npm run build
226226

227227
LibWithAngularV16:
228228
needs: build_job
@@ -241,25 +241,25 @@ jobs:
241241
path: angular-auth-oidc-client-artefact
242242

243243
- name: Install AngularCLI globally
244-
run: sudo npm install -g @angular/cli@16
244+
run: npm install -g @angular/cli@16
245245

246246
- name: Show ng Version
247247
run: ng version
248248

249249
- name: Create Angular Project
250-
run: sudo ng new angular-auth-oidc-client-test --skip-git
250+
run: ng new angular-auth-oidc-client-test --skip-git
251251

252252
- name: Npm Install & Install Library from local artefact
253253
run: |
254-
sudo cp -R angular-auth-oidc-client-artefact angular-auth-oidc-client-test/
254+
cp -R angular-auth-oidc-client-artefact angular-auth-oidc-client-test/
255255
cd angular-auth-oidc-client-test
256-
sudo npm install --unsafe-perm=true
257-
sudo ng add ./angular-auth-oidc-client-artefact --authority-url-or-tenant-id "my-authority-url" --flow-type "OIDC Code Flow PKCE using refresh tokens" --use-local-package=true --skip-confirmation
256+
npm install --unsafe-perm=true
257+
ng add ./angular-auth-oidc-client-artefact --authority-url-or-tenant-id "my-authority-url" --flow-type "OIDC Code Flow PKCE using refresh tokens" --use-local-package=true --skip-confirmation
258258
259259
- name: Test Angular Application
260260
working-directory: ./angular-auth-oidc-client-test
261261
run: npm test -- --watch=false --browsers=ChromeHeadless
262262

263263
- name: Build Angular Application
264264
working-directory: ./angular-auth-oidc-client-test
265-
run: sudo npm run build
265+
run: npm run build

angular.json

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2041,6 +2041,119 @@
20412041
}
20422042
}
20432043
}
2044+
},
2045+
"integration-tests": {
2046+
"projectType": "application",
2047+
"schematics": {
2048+
"@schematics/angular:class": {
2049+
"skipTests": true
2050+
},
2051+
"@schematics/angular:component": {
2052+
"skipTests": true
2053+
},
2054+
"@schematics/angular:directive": {
2055+
"skipTests": true
2056+
},
2057+
"@schematics/angular:guard": {
2058+
"skipTests": true
2059+
},
2060+
"@schematics/angular:interceptor": {
2061+
"skipTests": true
2062+
},
2063+
"@schematics/angular:pipe": {
2064+
"skipTests": true
2065+
},
2066+
"@schematics/angular:resolver": {
2067+
"skipTests": true
2068+
},
2069+
"@schematics/angular:service": {
2070+
"skipTests": true
2071+
}
2072+
},
2073+
"root": "projects/integration-tests",
2074+
"sourceRoot": "projects/integration-tests/src",
2075+
"prefix": "app",
2076+
"architect": {
2077+
"build": {
2078+
"builder": "@angular-devkit/build-angular:application",
2079+
"options": {
2080+
"outputPath": "dist/integration-tests",
2081+
"index": "projects/integration-tests/src/index.html",
2082+
"browser": "projects/integration-tests/src/main.ts",
2083+
"polyfills": [
2084+
"zone.js"
2085+
],
2086+
"tsConfig": "projects/integration-tests/tsconfig.app.json",
2087+
"assets": [
2088+
{
2089+
"glob": "**/*",
2090+
"input": "projects/integration-tests/public"
2091+
}
2092+
],
2093+
"styles": [
2094+
"projects/integration-tests/src/styles.css"
2095+
],
2096+
"scripts": []
2097+
},
2098+
"configurations": {
2099+
"production": {
2100+
"budgets": [
2101+
{
2102+
"type": "initial",
2103+
"maximumWarning": "500kB",
2104+
"maximumError": "1MB"
2105+
},
2106+
{
2107+
"type": "anyComponentStyle",
2108+
"maximumWarning": "4kB",
2109+
"maximumError": "8kB"
2110+
}
2111+
],
2112+
"outputHashing": "all"
2113+
},
2114+
"development": {
2115+
"optimization": false,
2116+
"extractLicenses": false,
2117+
"sourceMap": true
2118+
}
2119+
},
2120+
"defaultConfiguration": "production"
2121+
},
2122+
"serve": {
2123+
"builder": "@angular-devkit/build-angular:dev-server",
2124+
"configurations": {
2125+
"production": {
2126+
"buildTarget": "integration-tests:build:production"
2127+
},
2128+
"development": {
2129+
"buildTarget": "integration-tests:build:development"
2130+
}
2131+
},
2132+
"defaultConfiguration": "development"
2133+
},
2134+
"extract-i18n": {
2135+
"builder": "@angular-devkit/build-angular:extract-i18n"
2136+
},
2137+
"test": {
2138+
"builder": "@angular-devkit/build-angular:karma",
2139+
"options": {
2140+
"polyfills": [
2141+
"zone.js",
2142+
"zone.js/testing"
2143+
],
2144+
"tsConfig": "projects/integration-tests/tsconfig.spec.json",
2145+
"assets": [
2146+
{
2147+
"glob": "**/*",
2148+
"input": "projects/integration-tests/src/assets",
2149+
"output": "/assets"
2150+
}
2151+
],
2152+
"styles": [],
2153+
"scripts": []
2154+
}
2155+
}
2156+
}
20442157
}
20452158
},
20462159
"cli": {

docs/site/angular-auth-oidc-client/docs/documentation/silent-renew.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,21 @@ Both the access token and the id_token are used to start this process.
9797
window.onload = function () {
9898
/* The parent window hosts the Angular application */
9999
const parent = window.parent;
100+
100101
/* Send the id_token information to the oidc message handler */
101-
const event = new CustomEvent('oidc-silent-renew-message', { detail: window.location });
102+
const event = new CustomEvent('oidc-silent-renew-message', {
103+
detail: {
104+
url: window.location,
105+
srcFrameId: window.frameElement?.id
106+
}
107+
});
102108
parent.dispatchEvent(event);
103109
};
104110
</script>
105111
```
106112
113+
**Note:** When using multiple authentication configurations, each iframe is created with a unique identifier that includes the configId. The silent-renew.html script includes the iframe's id in the event as `srcFrameId`, allowing the library to extract the configId and correctly route the authentication response to the appropriate configuration.
114+
107115
If you are working with the [Angular CLI](https://angular.io/cli) make sure you add the `silent-renew.html` file to the assets configuration in your `angular.json`. This has already been done for you if you used the `ng add` schematics to install and setup the library.
108116
109117
```json
@@ -119,8 +127,14 @@ If you are working with the [Angular CLI](https://angular.io/cli) make sure you
119127
window.onload = function () {
120128
/* The parent window hosts the Angular application */
121129
const parent = window.parent;
130+
122131
/* Send the id_token information to the oidc message handler */
123-
const event = new CustomEvent('oidc-silent-renew-message', { detail: window.location.hash.substr(1) });
132+
const event = new CustomEvent('oidc-silent-renew-message', {
133+
detail: {
134+
url: window.location.hash.substr(1),
135+
srcFrameId: window.frameElement?.id
136+
}
137+
});
124138
parent.dispatchEvent(event);
125139
};
126140
</script>

0 commit comments

Comments
 (0)