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

あとで困らないための Azure Active Directory 連携開発 A to Z...•Azure との連携開発(All Service) •Azure におけるRBAC 設定(Service すべて) •App Service

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: あとで困らないための Azure Active Directory 連携開発 A to Z...•Azure との連携開発(All Service) •Azure におけるRBAC 設定(Service すべて) •App Service

あとで困らないための

Azure Active Directory 連携開発 A to Z

AD42

Page 2: あとで困らないための Azure Active Directory 連携開発 A to Z...•Azure との連携開発(All Service) •Azure におけるRBAC 設定(Service すべて) •App Service

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

Page 3: あとで困らないための Azure Active Directory 連携開発 A to Z...•Azure との連携開発(All Service) •Azure におけるRBAC 設定(Service すべて) •App Service

• 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

Page 4: あとで困らないための Azure Active Directory 連携開発 A to Z...•Azure との連携開発(All Service) •Azure におけるRBAC 設定(Service すべて) •App Service

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

Page 5: あとで困らないための Azure Active Directory 連携開発 A to Z...•Azure との連携開発(All Service) •Azure におけるRBAC 設定(Service すべて) •App Service

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

API

Page 6: あとで困らないための Azure Active Directory 連携開発 A to Z...•Azure との連携開発(All Service) •Azure におけるRBAC 設定(Service すべて) •App Service

Consistency

Web

Mobile

Page 7: あとで困らないための Azure Active Directory 連携開発 A to Z...•Azure との連携開発(All Service) •Azure におけるRBAC 設定(Service すべて) •App Service

役割の明確化

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

など . . . .

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

Page 8: あとで困らないための Azure Active Directory 連携開発 A to Z...•Azure との連携開発(All Service) •Azure におけるRBAC 設定(Service すべて) •App Service

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

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 パラメーターを使用)

Page 9: あとで困らないための Azure Active Directory 連携開発 A to Z...•Azure との連携開発(All Service) •Azure におけるRBAC 設定(Service すべて) •App Service

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

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 パラメーターを使用)

Page 10: あとで困らないための Azure Active Directory 連携開発 A to Z...•Azure との連携開発(All Service) •Azure におけるRBAC 設定(Service すべて) •App Service

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",

. . .

}

Page 11: あとで困らないための Azure Active Directory 連携開発 A to Z...•Azure との連携開発(All Service) •Azure におけるRBAC 設定(Service すべて) •App Service

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

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 パラメーターを使用)

Page 12: あとで困らないための Azure Active Directory 連携開発 A to Z...•Azure との連携開発(All Service) •Azure におけるRBAC 設定(Service すべて) •App Service

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",

. . .

}

Page 13: あとで困らないための Azure Active Directory 連携開発 A to Z...•Azure との連携開発(All Service) •Azure におけるRBAC 設定(Service すべて) •App Service

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

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 パラメーターを使用)

Page 14: あとで困らないための Azure Active Directory 連携開発 A to Z...•Azure との連携開発(All Service) •Azure におけるRBAC 設定(Service すべて) •App Service

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...

Page 15: あとで困らないための Azure Active Directory 連携開発 A to Z...•Azure との連携開発(All Service) •Azure におけるRBAC 設定(Service すべて) •App Service

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

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 パラメーターを使用)

Page 16: あとで困らないための Azure Active Directory 連携開発 A to Z...•Azure との連携開発(All Service) •Azure におけるRBAC 設定(Service すべて) •App Service

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

Page 17: あとで困らないための Azure Active Directory 連携開発 A to Z...•Azure との連携開発(All Service) •Azure におけるRBAC 設定(Service すべて) •App Service

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

v2.0

Page 18: あとで困らないための Azure Active Directory 連携開発 A to Z...•Azure との連携開発(All Service) •Azure におけるRBAC 設定(Service すべて) •App Service

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 パラメーターを使用)

Page 19: あとで困らないための Azure Active Directory 連携開発 A to Z...•Azure との連携開発(All Service) •Azure におけるRBAC 設定(Service すべて) •App Service

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

Page 20: あとで困らないための Azure Active Directory 連携開発 A to Z...•Azure との連携開発(All Service) •Azure におけるRBAC 設定(Service すべて) •App Service

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. . ."

Page 21: あとで困らないための Azure Active Directory 連携開発 A to Z...•Azure との連携開発(All Service) •Azure におけるRBAC 設定(Service すべて) •App Service

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

resource=someservice

Page 22: あとで困らないための Azure Active Directory 連携開発 A to Z...•Azure との連携開発(All Service) •Azure におけるRBAC 設定(Service すべて) •App Service

Administrator Consent

Page 23: あとで困らないための Azure Active Directory 連携開発 A to Z...•Azure との連携開発(All Service) •Azure におけるRBAC 設定(Service すべて) •App Service

prompt=admin_consent

{tenant realm}/adminconsent

Administrator Consent

Page 24: あとで困らないための Azure Active Directory 連携開発 A to Z...•Azure との連携開発(All Service) •Azure におけるRBAC 設定(Service すべて) •App Service

v2 endpoint における Administrator Consent

Page 25: あとで困らないための Azure Active Directory 連携開発 A to Z...•Azure との連携開発(All Service) •Azure におけるRBAC 設定(Service すべて) •App Service

v2 endpoint における Administrator Consent

Page 26: あとで困らないための Azure Active Directory 連携開発 A to Z...•Azure との連携開発(All Service) •Azure におけるRBAC 設定(Service すべて) •App Service

Azure における Permission の考え方

Page 27: あとで困らないための Azure Active Directory 連携開発 A to Z...•Azure との連携開発(All Service) •Azure におけるRBAC 設定(Service すべて) •App Service

Azure における Permission の考え方

Page 28: あとで困らないための Azure Active Directory 連携開発 A to Z...•Azure との連携開発(All Service) •Azure におけるRBAC 設定(Service すべて) •App Service

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)

Page 29: あとで困らないための Azure Active Directory 連携開発 A to Z...•Azure との連携開発(All Service) •Azure におけるRBAC 設定(Service すべて) •App Service
Page 30: あとで困らないための Azure Active Directory 連携開発 A to Z...•Azure との連携開発(All Service) •Azure におけるRBAC 設定(Service すべて) •App Service
Page 31: あとで困らないための Azure Active Directory 連携開発 A to Z...•Azure との連携開発(All Service) •Azure におけるRBAC 設定(Service すべて) •App Service

API による管理 (Microsoft Graph)

Page 32: あとで困らないための Azure Active Directory 連携開発 A to Z...•Azure との連携開発(All Service) •Azure におけるRBAC 設定(Service すべて) •App Service

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

Page 33: あとで困らないための Azure Active Directory 連携開発 A to Z...•Azure との連携開発(All Service) •Azure におけるRBAC 設定(Service すべて) •App Service

ユーザー同期

Delta Query (id による $filter)

Page 34: あとで困らないための Azure Active Directory 連携開発 A to Z...•Azure との連携開発(All Service) •Azure におけるRBAC 設定(Service すべて) •App Service

© 2018 Microsoft Corporation. All rights reserved.

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