-
Notifications
You must be signed in to change notification settings - Fork 13
Sign out functionality #91
base: master
Are you sure you want to change the base?
Changes from 8 commits
48ce4e9
7b3ed30
429bda3
f11ccea
5ca90ec
721c98a
049bdf8
58ebccc
27d80bd
9733bf0
ee44efe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,6 @@ spec: | |
name: easyauth-sample-pod | ||
port: | ||
number: 80 | ||
|
||
--- | ||
apiVersion: networking.k8s.io/v1 | ||
kind: Ingress | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Net.Http; | ||
using System.Security.Claims; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
@@ -58,6 +59,11 @@ public async Task InvokeAsync(HttpContext context) | |
await HandleAuth(context); | ||
return; | ||
} | ||
else if (_configureOptions.SignoutPath == context.Request.Path) | ||
{ | ||
await HandleLogout(context); | ||
return; | ||
} | ||
|
||
// Call the next delegate/middleware in the pipeline | ||
await _next(context); | ||
|
@@ -236,6 +242,19 @@ public async Task HandleAuth(HttpContext context) | |
|
||
} | ||
|
||
public async Task HandleLogout(HttpContext context) | ||
{ | ||
EasyAuthState state = context.EasyAuthStateFromHttpContext(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unnecessary. Can remove |
||
|
||
LogRequestHeaders("HandleLogout", context.Request); | ||
|
||
// Delete the cookie | ||
context.Response.Cookies.Delete(Constants.CookieName); | ||
|
||
// Re route the user to Azure AD to logout | ||
await context.SignOutAsync(OpenIdConnectDefaults.AuthenticationScheme, new AuthenticationProperties { RedirectUri = _configureOptions.DefaultRedirectAfterSignin }) ; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should allow the default redirect uri to be overridden by reading the Contstants.RedirectParameterName query param. We should also allow the literal value of "_blank" to be provided, which would not do a redirect at all, and just leave you at the AAD signout page. This would be the case when there is no path that allows anonymous access. I'm also wondering if we should use a value other than the DefaultRedirectAfterSignin, and render our own razor page after signing out. I need to think about that. |
||
} | ||
|
||
private void LogRequestHeaders(string prefix, HttpRequest request) | ||
{ | ||
StringBuilder sb = new StringBuilder(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/Anonymous is a valid path that we should keep. I'm not sure why it was labeled as "Sign-Out", but we should keep it as
<a class="nav-link" href="/Anonymous">Anonymous</a>
and Sign-out would be a separate nav link.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a button on line 26 for Anonymous. I've got one for signout and one for Anonymous