我正在尝试构建多个小型的ASP.NET Core Mvc服务,这些服务连接到使用IdentityServer4构建的身份验证服务器。
我已经在MVC服务上设置了类似于以下内容的OpenIdOption:
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationScheme = "Cookies"
});
app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions
{
AuthenticationScheme = "oidc",
SignInScheme = "Cookies",
Authority = "http://localhost:5000",
RequireHttpsMetadata = false,
ClientId = "mvc",
ClientSecret = "secret",
ResponseType = "code id_token",
Scope = { "api1", "offline_access" },
GetClaimsFromUserInfoEndpoint = true,
SaveTokens = true
});
我的Identity服务器运行在http://localhost:5000
端点上。假设我的MVC服务器在http://localhost:5002
,那么当我将[Authorize]
属性设置为控制器时,它会重定向到我的Identity服务器,如果检查失败,则会在http://localhost:5002/signin-oidc
寻找登录页面。
现在我的问题是,我希望登录页由我的Identity服务器
托管,托管在http://localhost:5000/signin-oidc
,以便所有MVC服务都可以使用它来获取用户身份,但不幸的是我无法看到如何设置这个RedirectUrl
。
我知道图表的工作流程不准确,只是试图简化我想要完成的内容 :)
这是否可能实现?
问候 Kiran
https://myapp.com
,则重定向URL应为https://myapp.com/signin-oidc
; 当您通过https://myapp.local
访问应用程序时,则重定向URL应为https://myapp.local/signin-oidc
。因此,应用程序本身(按设计)完全不知道它是如何被托管的。 - poke