我构建了一个向IdentityServer4发送身份验证详细信息(用户名/密码)并成功接收令牌(授权类型=资源所有者密码)的Angular 4站点。IdentityServer4 Cookie验证
现在我想从Angular 4站点将用户重定向到另一个(不同的)ASP Core MVC站点。 不知何故,我找不到在重定向中设置“标题”以将令牌传递为授权的方式:承载xxx。
我设置的cookie在角部位,然后就window.location.href = 'www.example.com/another_site
在MVC网站,我配置Startup.cs:
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
...
...
app.UseCookieAuthentication(new CookieAuthenticationOptions()
{
AuthenticationScheme = "Cookies_Authentication",
AutomaticAuthenticate = true,
AutomaticChallenge = true
});
app.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions
{
Authority = "http://my_identityserver4_address:49950",
RequireHttpsMetadata = false,
AuthenticationScheme = "Cookies_Authentication",
ApiName = "Protected_Api.get",
AutomaticAuthenticate = true,
AutomaticChallenge = true
});
}
,但我还是收到从MVC站点401未授权的响应。我做错了什么?
可能是IdentityServer寻找特殊的cookie名称?我将它设置在角为:
cookieService.setItem('access_token', 'eyJhbGciOiJSUzI1NiIsImtpZCI6ImFlOWEyMzNhZDczOTUwNWI4YjJkZGE0NTNiMDE........)
我想你的答案是最接近的 - 我需要更多地了解[OAuth和OpenID Connect](https://identityserver4.readthedocs.io/en/release/quickstarts/3_interactive_login.html),但方向是使用OpneID Connect用于cookie身份验证,而不是承载头。 – Jasper