-
-
Notifications
You must be signed in to change notification settings - Fork 83
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
github-actions
committed
Nov 27, 2021
1 parent
6cfda20
commit b06eb8e
Showing
9 changed files
with
76 additions
and
36 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
43 changes: 43 additions & 0 deletions
43
src/BlazorApp/Aguacongas.TheIdServer.BlazorApp.Infrastructure/OidcOptionsConfiguration.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,43 @@ | ||
using Microsoft.AspNetCore.Components; | ||
using Microsoft.AspNetCore.Components.WebAssembly.Authentication; | ||
using Microsoft.Extensions.Options; | ||
using System; | ||
|
||
namespace Aguacongas.TheIdServer.BlazorApp | ||
{ | ||
internal class OidcOptionsConfiguration : IPostConfigureOptions<RemoteAuthenticationOptions<OidcProviderOptions>> | ||
{ | ||
private readonly NavigationManager _navigationManager; | ||
|
||
public OidcOptionsConfiguration(NavigationManager navigationManager) => _navigationManager = navigationManager; | ||
|
||
public void Configure(RemoteAuthenticationOptions<OidcProviderOptions> options) | ||
{ | ||
options.UserOptions.AuthenticationType ??= options.ProviderOptions.ClientId; | ||
|
||
var redirectUri = options.ProviderOptions.RedirectUri; | ||
if (redirectUri == null || !Uri.TryCreate(redirectUri, UriKind.Absolute, out _)) | ||
{ | ||
redirectUri ??= "authentication/login-callback"; | ||
options.ProviderOptions.RedirectUri = _navigationManager | ||
.ToAbsoluteUri(redirectUri).AbsoluteUri; | ||
} | ||
|
||
var logoutUri = options.ProviderOptions.PostLogoutRedirectUri; | ||
if (logoutUri == null || !Uri.TryCreate(logoutUri, UriKind.Absolute, out _)) | ||
{ | ||
logoutUri ??= "authentication/logout-callback"; | ||
options.ProviderOptions.PostLogoutRedirectUri = _navigationManager | ||
.ToAbsoluteUri(logoutUri).AbsoluteUri; | ||
} | ||
} | ||
|
||
public void PostConfigure(string name, RemoteAuthenticationOptions<OidcProviderOptions> options) | ||
{ | ||
if (string.Equals(name, Options.DefaultName)) | ||
{ | ||
Configure(options); | ||
} | ||
} | ||
} | ||
} |
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