|
|
|
@ -5,6 +5,7 @@ using Blazorise.Icons.FontAwesome; |
|
|
|
using Medallion.Threading; |
|
|
|
using Medallion.Threading.Redis; |
|
|
|
using Microsoft.AspNetCore.Authentication.Cookies; |
|
|
|
using Microsoft.AspNetCore.Authentication.OpenIdConnect; |
|
|
|
using Microsoft.AspNetCore.Builder; |
|
|
|
using Microsoft.AspNetCore.DataProtection; |
|
|
|
using Microsoft.AspNetCore.Hosting; |
|
|
|
@ -183,6 +184,49 @@ public class MyProjectNameBlazorModule : AbpModule |
|
|
|
options.Scope.Add("phone"); |
|
|
|
options.Scope.Add("MyProjectName"); |
|
|
|
}); |
|
|
|
/* |
|
|
|
* This configuration is used when the AuthServer is running on the internal network such as docker or k8s. |
|
|
|
* Configuring the redirecting URLs for internal network and the web |
|
|
|
* The login and the logout URLs are configured to redirect to the AuthServer real DNS for browser. |
|
|
|
* The token acquired and validated from the the internal network AuthServer URL. |
|
|
|
*/ |
|
|
|
if (configuration.GetValue<bool>("AuthServer:IsContainerized")) |
|
|
|
{ |
|
|
|
context.Services.Configure<OpenIdConnectOptions>("oidc", options => |
|
|
|
{ |
|
|
|
options.TokenValidationParameters.ValidIssuers = new[] |
|
|
|
{ |
|
|
|
configuration["AuthServer:MetaAddress"]!.EnsureEndsWith('/'), |
|
|
|
configuration["AuthServer:Authority"]!.EnsureEndsWith('/') |
|
|
|
}; |
|
|
|
|
|
|
|
options.MetadataAddress = configuration["AuthServer:MetaAddress"]!.EnsureEndsWith('/') + |
|
|
|
".well-known/openid-configuration"; |
|
|
|
|
|
|
|
var previousOnRedirectToIdentityProvider = options.Events.OnRedirectToIdentityProvider; |
|
|
|
options.Events.OnRedirectToIdentityProvider = async ctx => |
|
|
|
{ |
|
|
|
// Intercept the redirection so the browser navigates to the right URL in your host
|
|
|
|
ctx.ProtocolMessage.IssuerAddress = configuration["AuthServer:Authority"]!.EnsureEndsWith('/') + "connect/authorize"; |
|
|
|
|
|
|
|
if (previousOnRedirectToIdentityProvider != null) |
|
|
|
{ |
|
|
|
await previousOnRedirectToIdentityProvider(ctx); |
|
|
|
} |
|
|
|
}; |
|
|
|
var previousOnRedirectToIdentityProviderForSignOut = options.Events.OnRedirectToIdentityProviderForSignOut; |
|
|
|
options.Events.OnRedirectToIdentityProviderForSignOut = async ctx => |
|
|
|
{ |
|
|
|
// Intercept the redirection for signout so the browser navigates to the right URL in your host
|
|
|
|
ctx.ProtocolMessage.IssuerAddress = configuration["AuthServer:Authority"]!.EnsureEndsWith('/') + "connect/logout"; |
|
|
|
|
|
|
|
if (previousOnRedirectToIdentityProviderForSignOut != null) |
|
|
|
{ |
|
|
|
await previousOnRedirectToIdentityProviderForSignOut(ctx); |
|
|
|
} |
|
|
|
}; |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void ConfigureVirtualFileSystem(IWebHostEnvironment hostingEnvironment) |
|
|
|
|