Skip to content

Commit 5920c62

Browse files
committed
Update oidc-spa
1 parent 80584c0 commit 5920c62

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"dependencies": {
2424
"@codegouvfr/react-dsfr": "^1.16.4",
2525
"keycloakify": "^11.8.7",
26-
"oidc-spa": "^5.6.1",
26+
"oidc-spa": "^6.9.8",
2727
"react": "^18.2.0",
2828
"react-dom": "^18.2.0"
2929
},

src/account/oidc.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
import { createReactOidc } from "oidc-spa/react";
22
import { createMockReactOidc } from "oidc-spa/mock/react";
33

4-
const publicUrl = undefined;
5-
const isAuthGloballyRequired = true;
6-
74
export const { OidcProvider, useOidc, getOidc } = import.meta.env.DEV
85
? createMockReactOidc({
96
isUserInitiallyLoggedIn: true,
10-
publicUrl,
11-
isAuthGloballyRequired
7+
homeUrl: import.meta.env.BASE_URL,
8+
autoLogin: true
129
})
13-
: createReactOidc({
14-
issuerUri: (() => {
10+
: createReactOidc(async () => {
11+
const { kcHttpRelativePath, realm } = (() => {
1512
const [
1613
// "" or "/auth"
1714
kcHttpRelativePath,
@@ -21,10 +18,16 @@ export const { OidcProvider, useOidc, getOidc } = import.meta.env.DEV
2118

2219
const realm = startsWithRealm.split("/")[0];
2320

24-
return `${window.location.origin}${kcHttpRelativePath}/realms/${realm}`;
21+
return {
22+
realm,
23+
kcHttpRelativePath: kcHttpRelativePath || undefined
24+
};
25+
})();
2526

26-
})(),
27-
clientId: "account-console",
28-
publicUrl,
29-
isAuthGloballyRequired
27+
return {
28+
issuerUri: `${window.location.origin}${kcHttpRelativePath ?? ""}/realms/${realm}`,
29+
clientId: "account-console",
30+
homeUrl: `${kcHttpRelativePath ?? ""}/realms/${realm}/account/`,
31+
autoLogin: true
32+
};
3033
});

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4875,10 +4875,10 @@ ohash@^1.1.3:
48754875
resolved "https://registry.yarnpkg.com/ohash/-/ohash-1.1.3.tgz#f12c3c50bfe7271ce3fd1097d42568122ccdcf07"
48764876
integrity sha512-zuHHiGTYTA1sYJ/wZN+t5HKZaH23i4yI1HMwbuXm24Nid7Dv0KcuRlKoNKS9UNfAVSBlnGLcuQrnOKWOZoEGaw==
48774877

4878-
oidc-spa@^5.6.1:
4879-
version "5.6.1"
4880-
resolved "https://registry.yarnpkg.com/oidc-spa/-/oidc-spa-5.6.1.tgz#bd4953bad6671d10088f86540cbc8e2f6c85701f"
4881-
integrity sha512-ZC9AA+rnsy9xX76znf3qppbtUliedl1B2WLWSkD3xx2svOWdPlm7sy7yHzbU8pBsBas0HEcccJrJpeBD6MGdKw==
4878+
oidc-spa@^6.9.8:
4879+
version "6.9.8"
4880+
resolved "https://registry.yarnpkg.com/oidc-spa/-/oidc-spa-6.9.8.tgz#30e2f8856d9636e71172ddc7748d63be1c911815"
4881+
integrity sha512-M3KpguANFiP8uBI+XORawKJi4F3GWlDBwmhhHoGBcvgxUtZ6BrrwtukkuURoNoaqCAVOnUuTdaSeZPfVLD8MjQ==
48824882

48834883
48844884
version "2.4.1"

0 commit comments

Comments
 (0)