@@ -4,33 +4,37 @@ import './index.css';
4
4
import App from './App' ;
5
5
import reportWebVitals from './reportWebVitals' ;
6
6
import history from "./utils/history" ;
7
- import { getConfig } from "./config" ;
8
- import { OidcProvider , useOidc } from '@axa-fr/react-oidc' ;
7
+ import { getConfig } from "./config" ;
8
+ import { OidcProvider } from '@axa-fr/react-oidc' ;
9
9
import { BrowserRouter } from "react-router-dom" ;
10
10
import Loading from "./components/Loading" ;
11
11
import LoginError from "./components/LoginError" ;
12
+ import { AuthorityConfiguration } from "@axa-fr/react-oidc/dist/vanilla/oidc" ;
12
13
13
14
const config = getConfig ( ) ;
14
15
15
- const authority = 'https://' + config . domain
16
+ // Unfortunately Auth0 https://<DOMAIN>/.well-known/openid-configuration doesn't contain end_session_endpoint that
17
+ // is required for doing logout. Therefore, we need to hardcode the config for auth
18
+ const auth0AuthorityConfig : AuthorityConfiguration = {
19
+ authorization_endpoint : config . authority + "/authorize" ,
20
+ token_endpoint : config . authority + "/oauth/token" ,
21
+ revocation_endpoint : config . authority + "/oauth/revoke" ,
22
+ end_session_endpoint : config . authority + "/v2/logout" ,
23
+ userinfo_endpoint : config . authority + "/userinfo"
24
+ } as AuthorityConfiguration
25
+
16
26
const providerConfig = {
17
- authority : authority ,
27
+ authority : config . authority ,
18
28
client_id : config . clientId ,
19
- redirect_uri : window . location . origin + ' #callback',
29
+ redirect_uri : window . location . origin + '/ #callback',
20
30
refresh_time_before_tokens_expiration_in_second : 30 ,
21
- silent_redirect_uri : window . location . origin + '#silent-callback' ,
22
- scope : 'openid profile email api offline_access email_verified' ,
31
+ silent_redirect_uri : window . location . origin + '/ #silent-callback' ,
32
+ scope : config . scopesSupported ,
23
33
// disabling service worker
24
34
// service_worker_relative_url:'/OidcServiceWorker.js',
25
35
service_worker_only : false ,
26
- authority_configuration : {
27
- authorization_endpoint : authority + "/authorize" ,
28
- token_endpoint : authority + "/oauth/token" ,
29
- revocation_endpoint : authority + "/oauth/revoke" ,
30
- end_session_endpoint : authority + "/v2/logout" ,
31
- userinfo_endpoint : authority + "/userinfo"
32
- } ,
33
- ...( config . audience ? { extras :{ audience : config . audience } } : null )
36
+ authority_configuration : config . auth0Auth ? auth0AuthorityConfig : undefined ,
37
+ ...( config . audience ? { extras : { audience : config . audience } } : null )
34
38
} ;
35
39
36
40
const root = ReactDOM . createRoot (
@@ -40,23 +44,21 @@ const root = ReactDOM.createRoot(
40
44
const loadingComponent = ( ) => < Loading padding = "3em" width = "50px" height = "50px" />
41
45
42
46
root . render (
43
-
44
- < OidcProvider
45
- configuration = { providerConfig }
46
- callbackSuccessComponent = { loadingComponent }
47
- authenticatingErrorComponent = { LoginError }
48
- authenticatingComponent = { loadingComponent }
49
- sessionLostComponent = { loadingComponent }
50
- loadingComponent = { loadingComponent }
51
- onSessionLost = { ( ) => {
52
- history . push ( "/peers" )
53
- } }
54
- >
55
- < BrowserRouter >
56
- < App />
57
- </ BrowserRouter >
58
- </ OidcProvider >
59
-
47
+ < OidcProvider
48
+ configuration = { providerConfig }
49
+ callbackSuccessComponent = { loadingComponent }
50
+ authenticatingErrorComponent = { LoginError }
51
+ authenticatingComponent = { loadingComponent }
52
+ sessionLostComponent = { loadingComponent }
53
+ loadingComponent = { loadingComponent }
54
+ onSessionLost = { ( ) => {
55
+ history . push ( "/peers" )
56
+ } }
57
+ >
58
+ < BrowserRouter >
59
+ < App />
60
+ </ BrowserRouter >
61
+ </ OidcProvider >
60
62
) ;
61
63
62
64
// If you want to start measuring performance in your app, pass a function
0 commit comments