2017-11-13 6 views
0

Micrsoft Graph API를 사용하여 프로그래밍 방식으로 클라이언트 응용 프로그램, 자원 서버를 등록하고 자원 서버의 역할을 클라이언트 응용 프로그램에 할당합니다. 다음 단계는 다음과 같습니다AAD에서 발행 한 JWT 토큰에 누락 된 역할 클레임

  1. 액세스 토큰 받기 ->https://login.windows.net/ /oauth2/token/?api-version=1.6

  2. 클라이언트 응용 프로그램 등록 ->https://graph.windows.net//응용 프로그램/API 버전을? = 매니페스트에서 응용 프로그램 역할 아래 1.6

  3. 고객 서비스 교장

  4. 자원 서버 등록 :

    "appRoles": [ 
        { 
         "allowedMemberTypes": [ 
          "Application" 
         ], 
         "description": "Description of Role - Resource_API_11092017", 
         "displayName": "Role_Resource_API_11092017", 
         "id": "5ff0033d-fa87-4a77-9b3d-b4b201dfc32e", 
         "isEnabled": true, 
         "value": "Read_Only_Resource_API_11092017" 
        } 
    ], 
    
  5. 자원 서버 서비스 사용자 생성

  6. 클라이언트 응용 프로그램에 역할을 할당. 내가 클라이언트 응용 프로그램의 자격 증명을 사용하여 액세스 토큰을 얻기 위해 노력하고 있어요 때

, 나는 JWT에서 어떤 역할이나 리소스 서버의 정보를 얻고 있지 않다.

심지어 클라이언트 응용 프로그램의 포털에서 리소스 서버의 역할에 권한을 부여합니다. 그러나 여전히 운이 없다.

도움이 될 것입니다. 자세한 내용이 필요한 경우 알려주십시오.

감사합니다. 2017년 11월 14일에

@Update :

는 JWT의 페이로드를 찾아주세요.

{ "aud": "https://xxxxx.onmicrosoft.com/Resource_API_11092017", "iss": "https://sts.windows.net/caa4bd37-xxxx-xxxx-xxxx-bba4bd0e22a6/", "iat": 1510679930, "nbf": 1510679930, "exp": 1510683830, "aio": "Y2NgYLipff1Ghn65atEd97grbjxxxx==", "appid": "3ec8690d-xxxx-xxxx-xxxx-739709a758cc", "appidacr": "1", "idp": "https://sts.windows.net/caa4bd37-xxxx-xxxx-xxxx-bba4bd0e22a6/", "tid": "caa4bd37-xxxx-xxxx-xxxx-bba4bd0e22a6", "ver": "1.0" } 서비스 주체에 역할이 포함되어 있지 않습니다. 하지만 포털을 사용하여 Role_Assigned_API_11092017을 응용 프로그램 권한으로 지정했습니다. 이 Role_Assigned_API_11092017은 자원 응용 프로그램 Resource_API_11092017에서 역할로 정의됩니다.

권한은 Resource_API_11092017에서 Portal을 통해 부여됩니다.

+0

안녕하세요. 어떤 정보를 다시 얻고 있습니까? 어떤 주장을하고 있습니까? 디코딩 된 JWT는 어떻게 생겼습니까? –

+0

[Graph Explorer] (https://graphexplorer.azurewebsites.net/)에서 appRoleAssignments를 확인할 수 있습니다. 클라이언트 응용 프로그램의 서비스 주체가 가지고 있어야하므로'https : // graph.windows.net/tenant-id/servicePrincipals/client-sp-id/appRoleAssignments'를 시도하십시오. – juunas

+0

권한 부여를 누르면 이러한 할당이 만들어집니다. – juunas

답변

0

토큰에서 역할 클레임을 가져올 수있었습니다. 다음은 클라이언트 앱에 리소스 앱에 정의 된 역할을 부여하려는 경우 따라야하는 단계입니다.
1. Create client App. 2. Create service principal of the client app. 3. Create resource app with roles defined as "appRoles": [{ "allowedMemberTypes": [ "Application" ], 4.Create service principal for the resource app. 5. Patch the client app and resource app with the roles defined in the resource app. - Allow Roles in the Required Permission section of the client app 6. Grant permission on the client app logging through your admin account from azure portal 6 단계 이외에도 Microsoft Graph API를 사용하여 디렉토리에 앱을 등록 할 수있는 권한이있는 앱의 액세스 토큰을 사용하여 모든 작업을 수행 할 수 있습니다.
클라이언트 응용 프로그램에서 권한 부여 작업에 해당하는 API가있는 사람이있는 경우. 저에게 알려주세요. 지금 우리는 이것을 수동으로 취하고 있습니다.
감사합니다.

{ 
    "aud": "https://xxxxxxx.onmicrosoft.com/resource_app_11202017", 
    "iss": "https://sts.windows.net/caa4bd37-xxxx-xxxx-xxxx-bba4bdxxxxa6/", 
    "iat": 1511209576, 
    "nbf": 1511209576, 
    "exp": 1511213476, 
    "aio": "Y2xxxxBlVE3nxxxxHtx3xSxxxxLAQ==", 
    "appid": "dffe69ef-xxxx-xxxx-xxxx-3550bxxxxbd7", 
    "appidacr": "1", 
    "idp": "https://sts.windows.net/caa4bd37-xxxx-xxxx-xxxx-bba4bdxxxxa6/", 
    "oid": "f2af0608-xxxx-xxxx-xxxx-a5acacxxxx8d", 
    "roles": [ 
    "readonly_role_resource_app_11202017", 
    "writeonly_role_resource_app_11202017" 
    ], 
    "sub": "f2af0608-xxxx-xxxx-xxxx-a5acacxxxx8d", 
    "tid": "caa4bd37-xxxx-xxxx-xxxx-bba4bdxxxxa6", 
    "uti": "VW6inKHUI0SgkuNMi6AcAA", 
    "ver": "1.0" 
}