mirror of
https://github.com/ditkrg/AuthorizationServerDemos.git
synced 2026-01-22 22:47:02 +00:00
redirect back to the client after logout :D
This commit is contained in:
parent
72cbb12243
commit
0254816657
@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net5.0</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
<PackageReference Include="TwoStepsAuthenticator" Version="1.4.1" />
|
<PackageReference Include="TwoStepsAuthenticator" Version="1.4.1" />
|
||||||
|
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="5.0.1" />
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="3.1.11" />
|
||||||
<PackageReference Include="Westwind.AspNetCore.LiveReload" Version="0.3.1" />
|
<PackageReference Include="Westwind.AspNetCore.LiveReload" Version="0.3.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@ -82,9 +82,8 @@ namespace OidcSamples.AuthorizationServer
|
|||||||
RequirePkce = true,
|
RequirePkce = true,
|
||||||
PostLogoutRedirectUris =
|
PostLogoutRedirectUris =
|
||||||
{
|
{
|
||||||
"http://localhost:3000/signout-callback-oidc"
|
"http://localhost:3000"
|
||||||
},
|
},
|
||||||
|
|
||||||
RequireConsent = false,
|
RequireConsent = false,
|
||||||
},
|
},
|
||||||
new Client
|
new Client
|
||||||
@ -113,9 +112,8 @@ namespace OidcSamples.AuthorizationServer
|
|||||||
RequirePkce = true,
|
RequirePkce = true,
|
||||||
PostLogoutRedirectUris =
|
PostLogoutRedirectUris =
|
||||||
{
|
{
|
||||||
"http://localhost:4000/signout-callback-oidc"
|
"http://localhost:4000"
|
||||||
},
|
},
|
||||||
|
|
||||||
RequireConsent = false,
|
RequireConsent = false,
|
||||||
},
|
},
|
||||||
new Client
|
new Client
|
||||||
@ -148,7 +146,8 @@ namespace OidcSamples.AuthorizationServer
|
|||||||
{
|
{
|
||||||
"http://localhost:7000/signout-callback-oidc"
|
"http://localhost:7000/signout-callback-oidc"
|
||||||
},
|
},
|
||||||
|
FrontChannelLogoutUri = "http://localhost:7000/signout-callback-oidc",
|
||||||
|
FrontChannelLogoutSessionRequired = true,
|
||||||
RequireConsent = false,
|
RequireConsent = false,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -241,7 +241,14 @@ namespace IdentityServerHost.Quickstart.UI
|
|||||||
return SignOut(new AuthenticationProperties { RedirectUri = url }, vm.ExternalAuthenticationScheme);
|
return SignOut(new AuthenticationProperties { RedirectUri = url }, vm.ExternalAuthenticationScheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
return View("LoggedOut", vm);
|
if (string.IsNullOrEmpty(vm.PostLogoutRedirectUri))
|
||||||
|
{
|
||||||
|
return View("LoggedOut", vm);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Redirect(vm.PostLogoutRedirectUri);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
|
|||||||
@ -14,7 +14,7 @@ We are using IdentityServer 4 to implement our Authorization Server. You can fin
|
|||||||
|
|
||||||
**Dependencies:**
|
**Dependencies:**
|
||||||
|
|
||||||
- [.NET 5 SDK](https://dotnet.microsoft.com/download/dotnet/5.0)
|
- [.NET Core 3.1 SDK](https://dotnet.microsoft.com/download/dotnet-core/3.1) (Because the latest version that IdentityServer4 supports is .NET Core 3.1)
|
||||||
|
|
||||||
**How to run:**
|
**How to run:**
|
||||||
|
|
||||||
|
|||||||
@ -14,8 +14,8 @@ const Navbar = () => {
|
|||||||
|
|
||||||
const user = useSelector((state) => state.auth.user);
|
const user = useSelector((state) => state.auth.user);
|
||||||
|
|
||||||
function signOut() {
|
async function signOut() {
|
||||||
signoutRedirect();
|
await signoutRedirect();
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -7,7 +7,7 @@ const config = {
|
|||||||
redirect_uri: "http://localhost:4000/signin-oidc",
|
redirect_uri: "http://localhost:4000/signin-oidc",
|
||||||
response_type: "code",
|
response_type: "code",
|
||||||
scope: "openid profile real-estate-api",
|
scope: "openid profile real-estate-api",
|
||||||
post_logout_redirect_uri: "http://localhost:4000/signout-oidc",
|
post_logout_redirect_uri: "http://localhost:4000",
|
||||||
};
|
};
|
||||||
|
|
||||||
const userManager = new UserManager(config);
|
const userManager = new UserManager(config);
|
||||||
@ -33,10 +33,14 @@ export function signinRedirectCallback() {
|
|||||||
return userManager.signinRedirectCallback();
|
return userManager.signinRedirectCallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function signoutRedirect() {
|
export async function signoutRedirect() {
|
||||||
|
var user = await userManager.getUser();
|
||||||
|
let id_token = null;
|
||||||
|
if (user) id_token = user.id_token;
|
||||||
|
|
||||||
userManager.clearStaleState();
|
userManager.clearStaleState();
|
||||||
userManager.removeUser();
|
userManager.removeUser();
|
||||||
return userManager.signoutRedirect();
|
return userManager.signoutRedirect({ id_token_hint: id_token });
|
||||||
}
|
}
|
||||||
|
|
||||||
export function signoutRedirectCallback() {
|
export function signoutRedirectCallback() {
|
||||||
|
|||||||
@ -14,8 +14,8 @@ const Navbar = () => {
|
|||||||
|
|
||||||
const user = useSelector((state) => state.auth.user);
|
const user = useSelector((state) => state.auth.user);
|
||||||
|
|
||||||
function signOut() {
|
async function signOut() {
|
||||||
signoutRedirect();
|
await signoutRedirect();
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -7,7 +7,7 @@ const config = {
|
|||||||
redirect_uri: "http://localhost:3000/signin-oidc",
|
redirect_uri: "http://localhost:3000/signin-oidc",
|
||||||
response_type: "code",
|
response_type: "code",
|
||||||
scope: "openid profile traffic-police-api",
|
scope: "openid profile traffic-police-api",
|
||||||
post_logout_redirect_uri: "http://localhost:3000/signout-oidc",
|
post_logout_redirect_uri: "http://localhost:3000"
|
||||||
};
|
};
|
||||||
|
|
||||||
const userManager = new UserManager(config);
|
const userManager = new UserManager(config);
|
||||||
@ -33,10 +33,14 @@ export function signinRedirectCallback() {
|
|||||||
return userManager.signinRedirectCallback();
|
return userManager.signinRedirectCallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function signoutRedirect() {
|
export async function signoutRedirect() {
|
||||||
|
var user = await userManager.getUser();
|
||||||
|
let id_token = null;
|
||||||
|
if (user) id_token = user.id_token;
|
||||||
|
|
||||||
userManager.clearStaleState();
|
userManager.clearStaleState();
|
||||||
userManager.removeUser();
|
userManager.removeUser();
|
||||||
return userManager.signoutRedirect();
|
return userManager.signoutRedirect({ id_token_hint: id_token });
|
||||||
}
|
}
|
||||||
|
|
||||||
export function signoutRedirectCallback() {
|
export function signoutRedirectCallback() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user