2017-02-17 6 views
0

저는 OAuth2 및 OpenID Connect 공간에 익숙하지 않습니다. API를 만들고 IdentityServer4를 사용하여 보안을 강화하려고합니다. 나는 다음과 같은 리소스를 생성 : -Identityserver4 동일한 이름의 ApiResource 및 IdentityResource

public static class MyResources 
{ 
    public static IEnumerable<IdentityResource> GetIdentityResources() 
    { 
     return new List<IdentityResource>() 
     { 
      new IdentityResources.OpenId(), 
      new IdentityResources.Profile(), 
      new IdentityResource("someResource", "some description", new [] { "something" }) 
     }; 
    } 

    public static IEnumerable<ApiResource> GetApiResources() 
    { 
     return new List<ApiResource>() 
     { 
      new ApiResource("someResource", "some other description", new [] { "somethingElse" }) 
     }; 
    } 
} 

그래서 당신은 내가 someResource라는 IdentityResource 또한 someResource라는 같은 이름의 ApiResource을 가지고 있음을 알 수있다. 나는 응용 프로그램을 실행할 때 마지막으로, 내 클라이언트 구성에서, 나는 액세스

public static class Clients 
{ 
    public static IEnumerable<Client> GetClients() 
    { 
     return new[] 
     { 
      new Client 
      { 
       ClientId = "MyClientId", 
       ClientName = "My Client Name", 
       ClientSecrets = new List<Secret> { new Secret("secret".Sha256()) }, 
       AllowedGrantTypes = GrantTypes.HybridAndClientCredentials, 
       RedirectUris = { "http://localhost:5002/signin-oidc" }, 
       PostLogoutRedirectUris = { "http://localhost:5002" }, 
       AllowedScopes = new List<string> 
       { 
        StandardScopes.OpenId, 
        StandardScopes.Profile, 
        "someResource" 
       }, 
       RequireConsent = true, 
       AllowOfflineAccess = true 
      } 
     }; 
    } 
} 

에 대한 someResource을 포함하는 다음 클라이언트 범위를 정의한이 내가 동의 화면

ID4 Consent Screen

에 표시되는 내용입니다

스크린 샷에서 볼 수 있듯이 동의 화면에서는 someResource라는 ApiResource뿐 아니라 IdentityResource도 제공합니다. 이 디자인은 의도적이며 자원의 이름 지정은 충돌하지 않도록주의 깊게 계획해야합니다. 클라이언트 스코프는 리소스 유형이 아닌 이름으로 만 구별 할 수 있기 때문에 같은 이름을 가진 두 개의 다른 리소스가 런타임 오류를 던질 것으로 예상됩니다. 당신의 생각은 무엇입니까?

답변

0

범위 이름은 고유해야합니다.

리소스를 만드는 "단순화 된"방법을 사용하는 경우 동일한 이름의 범위가 암시 적으로 만들어집니다.

IOW -하지 마세요)