を考える: 暗黙的およびリソース所有者の流れをサポートアイデンティティ・サーバー。 (構成は下記参照)IdentityServer BestPractiveは暗黙の組み合わせとRessourceOwnerワークフロー
IdentityServerBearerTokenAuthenticationを使用するApi。したがって、認証に使用されるトークンのパスワードを基本的に取引します。
authの暗黙のワークフローを使用します。
これで、保護されたapiメソッドにアクセスできるIDサーバからベアラトークンを取得できました。
また、ユーザーとして、暗黙のフローでログインし、保護されたビューを見ることができます。
問題 署名されたWebFrontEndUserが保護されたAPIにアクセスするときに問題が発生します。
ユーザは、暗黙のフローを使用してuiにログインします。彼は認証された後、保護されたAPIにアクセスしようとします。 Apiは、彼が承認されていないことを返します。
apiがユーザーCookieのopenid情報を使用するように環境を設定する方法を教えてください。
サイトConfing
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
});
app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
ClientId = "foo_implicit",
Authority = identServer,
RedirectUri = "http://localhost/foo/",
ResponseType = "token id_token",
Scope = "openid profile",
SignInAsAuthenticationType = DefaultAuthenticationTypes.ApplicationCookie
});
WEBAPIコンフィグ
app.UseIdentityServerBearerTokenAuthentication(new IdentityServer3.AccessTokenValidation.IdentityServerBearerTokenAuthenticationOptions()
{
Authority = identServer
});
IdentityServerクライアントコンフィグ
new Client
{
Enabled = true,
ClientId = "foo_implicit",
ClientName = "foo Site",
ClientSecrets = new List<Secret>
{
new Secret("foo".Sha256())
},
Flow = Flows.Implicit,
AllowedScopes = new List<string>
{
Constants.StandardScopes.OpenId,
Constants.StandardScopes.Profile,
"read"
},
RedirectUris = new List<string>()
{
"http://localhost/foo/"
}
},
new Client
{
Enabled = true,
ClientId = "foo",
ClientName = "foo api",
ClientSecrets = new List<Secret>
{
new Secret("foo".Sha256())
},
Flow = Flows.ResourceOwner,
AllowedScopes = new List<string>
{
Constants.StandardScopes.OpenId,
"read"
}
}