Skip to content

Commit 4f887eb

Browse files
committed
add POST_LOGOUT_URI
1 parent dc09cc4 commit 4f887eb

5 files changed

Lines changed: 16 additions & 7 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
VITE_ISSUER_URL=https://your-tenant.us.secureauth.com/your-workspace
22
VITE_CLIENT_ID=your-client-id
33
VITE_REDIRECT_URI=http://localhost:3000/callback
4+
VITE_POST_LOGOUT_URI=http://localhost:3000
45
VITE_SCOPES=openid profile email

samples/react/login-pkce/src/App.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const oidcConfig = {
99
authority: import.meta.env.VITE_ISSUER_URL,
1010
client_id: import.meta.env.VITE_CLIENT_ID,
1111
redirect_uri: import.meta.env.VITE_REDIRECT_URI,
12+
post_logout_redirect_uri: import.meta.env.VITE_POST_LOGOUT_URI,
1213
scope: import.meta.env.VITE_SCOPES,
1314
};
1415
// @snippet:step2:end
@@ -29,7 +30,10 @@ function AuthButtons() {
2930
if (auth.isAuthenticated) {
3031
return (
3132
<div>
32-
<p>Welcome, {auth.user?.profile.name}</p>
33+
<p>
34+
Welcome, {auth.user?.profile.given_name}{" "}
35+
{auth.user?.profile.family_name} ({auth.user?.profile.email})
36+
</p>
3337
<button onClick={() => auth.signoutRedirect()}>Sign out</button>
3438
</div>
3539
);

samples/react/manifest.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ scenarios:
1818
value: "{{ISSUER_URL}}"
1919
- label: "Redirect URI"
2020
value: "{{REDIRECT_URI}}"
21+
- label: "Post-Logout Redirect URI"
22+
value: "{{POST_LOGOUT_URI}}"
2123
- label: "Scopes"
2224
value: "{{SCOPES}}"
2325
- label: "Grant"

snippet-manifest.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ scenarios:
1919
value: '{{ISSUER_URL}}'
2020
- label: Redirect URI
2121
value: '{{REDIRECT_URI}}'
22+
- label: Post-Logout Redirect URI
23+
value: '{{POST_LOGOUT_URI}}'
2224
- label: Scopes
23-
value: openid profile email
25+
value: '{{SCOPES}}'
2426
- label: Grant
2527
value: Authorization Code + PKCE
2628
frameworks:

snippets.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,26 @@
1313
{
1414
"step": 2,
1515
"description": "Configure the OIDC client with your SecureAuth app settings",
16-
"code": "const oidcConfig = {\n authority: \"{{ISSUER_URL}}\",\n client_id: \"{{CLIENT_ID}}\",\n redirect_uri: \"{{REDIRECT_URI}}\",\n scope: \"{{SCOPES}}\",\n};",
16+
"code": "const oidcConfig = {\n authority: \"{{ISSUER_URL}}\",\n client_id: \"{{CLIENT_ID}}\",\n redirect_uri: \"{{REDIRECT_URI}}\",\n post_logout_redirect_uri: \"{{POST_LOGOUT_URI}}\",\n scope: \"{{SCOPES}}\",\n};",
1717
"file": "src/App.tsx",
1818
"lang": "tsx",
19-
"lines": "7-13"
19+
"lines": "7-14"
2020
},
2121
{
2222
"step": 3,
2323
"description": "Add login and logout buttons that redirect to SecureAuth",
24-
"code": "function AuthButtons() {\n const auth = useAuth();\n\n if (auth.isLoading) {\n return <div>Loading...</div>;\n }\n\n if (auth.error) {\n return <div>Error: {auth.error.message}</div>;\n }\n\n if (auth.isAuthenticated) {\n return (\n <div>\n <p>Welcome, {auth.user?.profile.name}</p>\n <button onClick={() => auth.removeUser()}>Sign out</button>\n </div>\n );\n }\n\n return <button onClick={() => auth.signinRedirect()}>Sign in</button>;\n}",
24+
"code": "function AuthButtons() {\n const auth = useAuth();\n\n if (auth.isLoading) {\n return <div>Loading...</div>;\n }\n\n if (auth.error) {\n return <div>Error: {auth.error.message}</div>;\n }\n\n if (auth.isAuthenticated) {\n return (\n <div>\n <p>\n Welcome, {auth.user?.profile.given_name}{\" \"}\n {auth.user?.profile.family_name} ({auth.user?.profile.email})\n </p>\n <button onClick={() => auth.signoutRedirect()}>Sign out</button>\n </div>\n );\n }\n\n return <button onClick={() => auth.signinRedirect()}>Sign in</button>;\n}",
2525
"file": "src/App.tsx",
2626
"lang": "tsx",
27-
"lines": "17-39"
27+
"lines": "18-43"
2828
},
2929
{
3030
"step": 4,
3131
"description": "Wrap your app with the AuthProvider to enable authentication",
3232
"code": "export default function App() {\n return (\n <AuthProvider {...oidcConfig}>\n <h1>SecureAuth React PKCE Demo</h1>\n <AuthButtons />\n </AuthProvider>\n );\n}",
3333
"file": "src/App.tsx",
3434
"lang": "tsx",
35-
"lines": "43-51"
35+
"lines": "47-55"
3636
}
3737
],
3838
"framework": "react",

0 commit comments

Comments
 (0)