-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b3bd353
commit e4e7730
Showing
20 changed files
with
126 additions
and
46 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
5 changes: 0 additions & 5 deletions
5
samples/Blazor/PerComponent/PerComponent.Client/Components/Auto.razor
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 |
---|---|---|
@@ -1,8 +1,3 @@ | ||
@rendermode InteractiveAuto | ||
|
||
<CallApi Header="InteractiveAuto"></CallApi> | ||
|
||
@code { | ||
[CascadingParameter] | ||
private Task<AuthenticationState>? authenticationState { get; set; } | ||
} |
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
9 changes: 0 additions & 9 deletions
9
samples/Blazor/PerComponent/PerComponent.Client/Components/Wasm.razor
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 |
---|---|---|
@@ -1,12 +1,3 @@ | ||
@rendermode InteractiveWebAssembly | ||
|
||
<CallApi Header="InteractiveWebAssembly"></CallApi> | ||
|
||
@* TODO - This cascading auth state gets the auth state provider running. But | ||
actually, we don't need the auth state provider to be running. I thought it was | ||
weird that it wasn't, so this forces it to do so, but actually we're not doing | ||
anything with the state changes. *@ | ||
@code { | ||
[CascadingParameter] | ||
private Task<AuthenticationState>? authenticationState { get; set; } | ||
} |
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
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
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
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
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
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
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
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
59 changes: 59 additions & 0 deletions
59
src/Duende.Bff/SessionManagement/Configuration/PostConfigureApplicationCookieRefreshToken.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,59 @@ | ||
// Copyright (c) Duende Software. All rights reserved. | ||
// See LICENSE in the project root for license information. | ||
|
||
using IdentityModel; | ||
using Microsoft.AspNetCore.Authentication; | ||
using Microsoft.AspNetCore.Authentication.Cookies; | ||
using Microsoft.Extensions.Logging; | ||
using Microsoft.Extensions.Options; | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace Duende.Bff; | ||
|
||
/// <summary> | ||
/// Cookie configuration to revoke refresh token on logout. | ||
/// </summary> | ||
public class PostConfigureApplicationCookieRevokeRefreshToken : IPostConfigureOptions<CookieAuthenticationOptions> | ||
{ | ||
private readonly BffOptions _options; | ||
private readonly string? _scheme; | ||
private readonly ILogger<PostConfigureApplicationCookieRevokeRefreshToken> _logger; | ||
|
||
/// <summary> | ||
/// ctor | ||
/// </summary> | ||
/// <param name="bffOptions"></param> | ||
/// <param name="authOptions"></param> | ||
/// <param name="logger"></param> | ||
public PostConfigureApplicationCookieRevokeRefreshToken(IOptions<BffOptions> bffOptions, IOptions<AuthenticationOptions> authOptions, ILogger<PostConfigureApplicationCookieRevokeRefreshToken> logger) | ||
{ | ||
_options = bffOptions.Value; | ||
_scheme = authOptions.Value.DefaultAuthenticateScheme ?? authOptions.Value.DefaultScheme; | ||
_logger = logger; | ||
} | ||
|
||
/// <inheritdoc /> | ||
public void PostConfigure(string? name, CookieAuthenticationOptions options) | ||
{ | ||
if (_options.RevokeRefreshTokenOnLogout && name == _scheme) | ||
{ | ||
options.Events.OnSigningOut = CreateCallback(options.Events.OnSigningOut); | ||
} | ||
} | ||
|
||
private Func<CookieSigningOutContext, Task> CreateCallback(Func<CookieSigningOutContext, Task> inner) | ||
{ | ||
async Task Callback(CookieSigningOutContext ctx) | ||
{ | ||
_logger.LogDebug("Revoking user's refresh tokens in OnSigningOut for subject id: {subjectId}", ctx.HttpContext.User.FindFirst(JwtClaimTypes.Subject)?.Value); | ||
await ctx.HttpContext.RevokeRefreshTokenAsync(); | ||
if (inner != null) | ||
{ | ||
await inner.Invoke(ctx); | ||
} | ||
}; | ||
|
||
return Callback; | ||
} | ||
} |