我構建了一個向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