을 감안할 때 : 암시 적 및 자원 소유자 흐름을 지원하는 신원 서버. (구성은 아래 참조)IdentityServer BestPractive는 암시 적 결합 및 RessourceOwner 워크 플로우
IdentityServerBearerTokenAuthentication을 사용하는 Api입니다. 따라서 인증에 사용되는 토큰에 대한 비밀번호를 기본으로 교환합니다.
auth에 암시 적 워크 플로우를 사용합니다.
이제 보호 api 메소드에 액세스 할 수있는 ID 서버에서 베어러 토큰을 가져올 수 있습니다.
또한 사용자로서 암시 적 플로우로 로그인하고 보호 된보기를 볼 수 있습니다.
문제 로그인 한 WebFrontEndUser가 보호 된 API에 액세스하려고 할 때 문제가 발생합니다.
사용자는 암시 적 플로우를 사용하여 ui에 로그인합니다. 인증을받은 후에는 보호 된 API에 액세스하려고 시도합니다. Api가 권한이 없다고 반환합니다.
api가 사용자 쿠키의 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"
}
}