-
-
Notifications
You must be signed in to change notification settings - Fork 301
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the Contruum sample to enable the logout endpoint and update R…
…EADME.md to include a link to an OIDC session management sample
- Loading branch information
Showing
5 changed files
with
63 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
samples/Contruum/Contruum.Server/Pages/Connect/EndSession.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
@page | ||
@model Contruum.Server.Pages.Connect.EndSessionModel | ||
@using Microsoft.Extensions.Primitives | ||
|
||
<div class="jumbotron"> | ||
<h1>Log out</h1> | ||
<p class="lead text-left">Are you sure you want to sign out?</p> | ||
|
||
<form asp-antiforgery="true" method="post"> | ||
@* Flow the request parameters so they can be received by the LogoutPost action: *@ | ||
@foreach (var parameter in Request.HasFormContentType ? | ||
(IEnumerable<KeyValuePair<string, StringValues>>)Request.Form : Request.Query) | ||
{ | ||
<input type="hidden" name="@parameter.Key" value="@parameter.Value" /> | ||
} | ||
|
||
<input class="btn btn-lg btn-success" name="Confirm" type="submit" value="Yes" /> | ||
</form> | ||
</div> |
30 changes: 30 additions & 0 deletions
30
samples/Contruum/Contruum.Server/Pages/Connect/EndSession.cshtml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Authentication; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.RazorPages; | ||
using OpenIddict.Server.AspNetCore; | ||
|
||
namespace Contruum.Server.Pages.Connect; | ||
|
||
public class EndSessionModel : PageModel | ||
{ | ||
public IActionResult OnGet() | ||
{ | ||
return Page(); | ||
} | ||
|
||
public async Task<IActionResult> OnPostAsync() | ||
{ | ||
await HttpContext.SignOutAsync(); | ||
|
||
// Returning a SignOutResult will ask OpenIddict to redirect the user agent | ||
// to the post_logout_redirect_uri specified by the client application or to | ||
// the RedirectUri specified in the authentication properties if none was set. | ||
return SignOut( | ||
authenticationSchemes: OpenIddictServerAspNetCoreDefaults.AuthenticationScheme, | ||
properties: new AuthenticationProperties | ||
{ | ||
RedirectUri = "/" | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters