diff options
| author | 2023-03-21 17:19:01 +0100 | |
|---|---|---|
| committer | 2023-03-21 17:19:01 +0100 | |
| commit | cee8ea7ecb4a341d46e6728af8a43a4b0af2ca49 (patch) | |
| tree | fbe79cecb6ef951bb03ca3adaa25232e776bef81 /src/App/App.tsx | |
| parent | Working with v7 (without account theme) (diff) | |
Update setup
Diffstat (limited to 'src/App/App.tsx')
| -rw-r--r-- | src/App/App.tsx | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/src/App/App.tsx b/src/App/App.tsx index 68f1393..dccb8af 100644 --- a/src/App/App.tsx +++ b/src/App/App.tsx @@ -5,9 +5,12 @@ import { createOidcClientProvider, useOidcClient } from "./oidc"; import { addFooToQueryParams, addBarToQueryParams } from "../keycloak-theme/login/valuesTransferredOverUrl"; import jwt_decode from "jwt-decode"; +const keycloakUrl = "https://auth.code.gouv.fr" +const keycloakRealm = "keycloakify"; + const { OidcClientProvider } = createOidcClientProvider({ - url: "https://auth.code.gouv.fr/auth", - realm: "keycloakify", + url: `${keycloakUrl}/auth`, + realm: keycloakRealm, clientId: "starter", //This function will be called just before redirecting, //it should return the current langue. @@ -38,18 +41,20 @@ function ContextualizedApp() { return ( <div className="App"> <header className="App-header"> - { - oidcClient.isUserLoggedIn ? - <> - <h1>You are authenticated !</h1> - <pre style={{ textAlign: "left" }}>{JSON.stringify(jwt_decode(oidcClient.getAccessToken()), null, 2)}</pre> - <button onClick={() => oidcClient.logout({ redirectTo: "home" })}>Logout</button> - </> - : - <> - <button onClick={() => oidcClient.login({ doesCurrentHrefRequiresAuth: false })}>Login</button> - </> - } + { + oidcClient.isUserLoggedIn ? + <> + <h1>You are authenticated !</h1> + {/* On older Keycloak version its /auth/realms instead of /realms */} + <a href={`${keycloakUrl}/realms/${keycloakRealm}/account`} target="_blank">Link to your Keycloak account</a> + <pre style={{ textAlign: "left" }}>{JSON.stringify(jwt_decode(oidcClient.getAccessToken()), null, 2)}</pre> + <button onClick={() => oidcClient.logout({ redirectTo: "home" })}>Logout</button> + </> + : + <> + <button onClick={() => oidcClient.login({ doesCurrentHrefRequiresAuth: false })}>Login</button> + </> + } <img src={logo} className="App-logo" alt="logo" /> <img src={myimg} alt="test_image" /> <p style={{ "fontFamily": '"Work Sans"' }}>Hello world</p> |