あとで困らないための Azure Active Directory 連携開発 A to Z...•Azure...

Post on 04-Oct-2020

0 views 0 download

Transcript of あとで困らないための Azure Active Directory 連携開発 A to Z...•Azure...

あとで困らないための

Azure Active Directory 連携開発 A to Z

AD42

その知識、どこで使える ?

• Azure との連携開発 (All Service)• Azure における RBAC 設定 (Service すべて)

• App Service AuthN / AuthZ

• Data Lake Store Access Permissions, SQL Database Credentials, etc…

• Office 365 との連携開発 (All App)• API 連携 (App すべて)

• In App での Auth (Office Add-in, Teams Tab, etc)

• Dynamics CRM / ERP との連携開発• Bot Service を使った開発• Power BI との連携開発 etc…

その知識、どこで使える ?

- Linux App Service / VM (Preview)

az vm extension set ¥--publisher Microsoft.Azure.ActiveDirectory.LinuxSSH ¥--name AADLoginForLinux ¥--resource-group myResourceGroup ¥--vm-name myVM

https://login.microsoftonline.com/ /oauth2

認証・認可のフロー (OAuth の場合)Protected

API

Consistency

Web

Mobile

役割の明確化

開発者にとってのブラックボックス

など . . . .

開発者の関心 IT 管理者の関心

クライアントとアクセスパターン

Client Type Access Pattern

Web Clientclient id と client secret の使用

(client secret で「なりすまし」を防止)

Native Clientrefresh token を使用した「なりすまし」防止

(client secret は不使用)

Single Page Web Clientrefresh token も client secret も使わない方式

(token 取り直しには hidden iframe を使用)

Daemon / Service ClientLogin UI を伴わない App-only context

(client secret を使用)

Scenario Access Pattern

オフライン接続 refresh token を使用した access token の取り直し

(別 resource も指定可能)複数リソースの使用

Impersonation (偽装)access token を使用した access token の取り直し

(on_behalf_of パラメーターを使用)

クライアントとアクセスパターン

Client Type Access Pattern

Web Clientclient id と client secret の使用

(client secret で「なりすまし」を防止)

Native Clientrefresh token を使用した「なりすまし」防止

(client secret は不使用)

Single Page Web Clientrefresh token も client secret も使わない方式

(token 取り直しには hidden iframe を使用)

Daemon / Service ClientLogin UI を伴わない App-only context

(client secret を使用)

Scenario Access Pattern

オフライン接続 refresh token を使用した access token の取り直し

(別 resource も指定可能)複数リソースの使用

Impersonation (偽装)access token を使用した access token の取り直し

(on_behalf_of パラメーターを使用)

POST https://login.microsoftonline.com/common/oauth2/token

Content-Type: application/x-www-form-urlencoded

grant_type=refresh_token&refresh_token=<received refresh token>&client_id=<client id>&resource=<another resource id>

{

"access_token":"eyJ0eXAiOiJKV1. . .",

"token_type":"Bearer",

"expires_in":"28800",

"expires_on":"1373631999",

. . .

}

クライアントとアクセスパターン

Client Type Access Pattern

Web Clientclient id と client secret の使用

(client secret で「なりすまし」を防止)

Native Clientrefresh token を使用した「なりすまし」防止

(client secret は不使用)

Single Page Web Clientrefresh token も client secret も使わない方式

(token 取り直しには hidden iframe を使用)

Daemon / Service ClientLogin UI を伴わない App-only context

(client secret を使用)

Scenario Access Pattern

オフライン接続 refresh token を使用した access token の取り直し

(別 resource も指定可能)複数リソースの使用

Impersonation (偽装)access token を使用した access token の取り直し

(on_behalf_of パラメーターを使用)

POST https://login.microsoftonline.com/common/oauth2/token

Content-Type: application/x-www-form-urlencoded

grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer&

assertion=<received access token>&requested_token_use=on_behalf_of&

resource=<new resource>&scope=openid&client_id=<new client id>&client_secret=<new client secret>

{

"access_token":"eyJ0eXAiOiJKV1. . .",

"token_type":"Bearer",

"expires_in":"28800",

"expires_on":"1373631999",

. . .

}

クライアントとアクセスパターン

Client Type Access Pattern

Web Clientclient id と client secret の使用

(client secret で「なりすまし」を防止)

Native Clientrefresh token を使用した「なりすまし」防止

(client secret は不使用)

Single Page Web Clientrefresh token も client secret も使わない方式

(token 取り直しには hidden iframe を使用)

Daemon / Service ClientLogin UI を伴わない App-only context

(client secret を使用)

Scenario Access Pattern

オフライン接続 refresh token を使用した access token の取り直し

(別 resource も指定可能)複数リソースの使用

Impersonation (偽装)access token を使用した access token の取り直し

(on_behalf_of パラメーターを使用)

https://login.microsoftonline.com/common/oauth2/authorize?response_type=token&client_id=2ecc2d71-8fcc-4007-b18e-165413028cae&resource=https%3A%2F%2Ftest-sv.azurewebsites.net&redirect_uri=https%3A%2F%2Ftest.com%2Ftest.html

https://test.com/test.html#access_token=eyJ0eXAiOi...&token_type=Bearer&expires_in=3599&session_state=eb83c98a-9831-4b18-b1a1-bdf483104d66

HTML Azure AD

#access_token=eyJ0eXAiOi...

クライアントとアクセスパターン

Client Type Access Pattern

Web Clientclient id と client secret の使用

(client secret で「なりすまし」を防止)

Native Clientrefresh token を使用した「なりすまし」防止

(client secret は不使用)

Single Page Web Clientrefresh token も client secret も使わない方式

(token 取り直しには hidden iframe を使用)

Daemon / Service ClientLogin UI を伴わない App-only context

(client secret を使用)

Scenario Access Pattern

オフライン接続 refresh token を使用した access token の取り直し

(別 resource も指定可能)複数リソースの使用

Impersonation (偽装)access token を使用した access token の取り直し

(on_behalf_of パラメーターを使用)

App Azure AD

POST https://login.microsoftonline.com/xxx.onmicrosoft.com/oauth2/token

Content-Type: application/x-www-form-urlencoded

resource=. . . &client_id=. . . &client_assertion_type=urn%3Aietf%3Aparams%3Aoauth%3Aclient-assertion-type%3Ajwt-bearer&client_assertion=eyJhbGciOiJSUzI...&grant_type=client_credentials

2 つのエンドポイント : v1 and v2

v2.0

v2 endpoint の対応シナリオとクライアントタイプ

Client Type Access Pattern

Web Clientclient id と client secret の使用

(client secret で「なりすまし」を防止)

Native Clientrefresh token を使用した「なりすまし」防止

(client secret は不使用)

Single Page Web Clientrefresh token も client secret も使わない方式

(token 取り直しには hidden iframe を使用)

Daemon / Service ClientLogin UI を伴わない App-only context

(client secret を使用)

Scenario Access Pattern

オフライン接続 refresh token を使用した access token の取り直し

(別 resource も指定可能)複数リソースの使用

Impersonation (偽装)access token を使用した access token の取り直し

(on_behalf_of パラメーターを使用)

OAuth における Azure AD 独自の仕様

OAuth における Azure AD 独自の仕様Office 365

API

"access_token":"eyJ0eXAiOiJKV1. . ."

token1 token2 token3. .

dot (.) 区切りのトークンRFC 4648 による変形 Base 64 エンコード文字列

{

"typ":"JWT",

"alg":"RS256",

"x5t":"MnC_VZcA..."

}

{

"aud":"https://testcorp.onmicrosoft.com/",

"given_name":"Taro",

"family_name":"Demo",

"appid":"e29d918e-4da6-4d42-aeb2-d949b73be432",

...

}

デジタル署名

"access_token":"eyJ0eXAiOiJKV1. . ."

OAuth における Azure AD 独自の仕様

resource=someservice

Administrator Consent

prompt=admin_consent

{tenant realm}/adminconsent

Administrator Consent

v2 endpoint における Administrator Consent

v2 endpoint における Administrator Consent

Azure における Permission の考え方

Azure における Permission の考え方

Azure AD Managed Service Identity (MSI)

App Service

Azure Service

(e.g., ARM, Key Vault)Your code

Local token

service

Credentials

1

2

3

Azure (inject and roll credentials)

API による管理 (Microsoft Graph)

API によるWorkflow Automation 例

新規の採用

• Set profile

• Assign licenses

• Set manager

デバイスの付与

• Provision mobile device

• Register owner

アクセス認可

• Assign to groups

• Assign to roles

POST /users

POST /users/{id}/manager/$ref

POST /users/{id}/assignLicense

POST /groups/{id}/members/$ref

POST

/groups/{id}/directoryRoles/$ref

POST /devices

POST

/devices/{id}/registere

dOwners

ユーザー同期

Delta Query (id による $filter)

© 2018 Microsoft Corporation. All rights reserved.

本コンテンツの著作権、および本コンテンツ中に出てくる商標権、団体名、ロゴ、製品、サービスなどはそれぞれ、各権利保有者に帰属します。