私はしばらくこのことに苦労していました。私はそれを考え出しました。
最初に、 Azure ADでは、WebApiアプリをアプリケーションタイプとしてWeb App/APIに設定します。 は、ネイティブアプリになると、あなたは上記の追加サービスに必要なアクセス許可を追加するファイルをマニフェストし、次にアプリケーションの種類などのクライアントアプリケーションを作成
[
{
"allowedMemberTypes": [
"User"
],
"displayName": "Reviewer",
"id": "0238c2bb-9857-4d07-b760-a47ec621d57a",
"isEnabled": true,
"description": "Reviewer only have the ability to view tasks and their statuses.",
"value": "reviewer"
},
{
"allowedMemberTypes": [
"User"
],
"displayName": "Approver",
"id": "000018cb-19e3-4f89-bf99-5d7acf30773b",
"isEnabled": true,
"description": "Approvers have the ability to change the status of tasks.",
"value": "approver"
}
]
のようなあなたの役割を追加するために行きます。 SPA角度アプリで
この
var endPoints = {
// "https://localhost:44386/" is the API URL
// "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx" is the Service Application ID
"https://localhost:44386/": "xxxxxxxxxxxxxxxxxxxxxxxxxx"
};
adalAuthenticationServiceProvider.init({
instance: "https://login.microsoftonline.com/",
// tenant is your tenant name (something like below)
tenant: "{NAME}.onmicrosoft.com",
// this is the Native app application ID (ClientID) you registered
clientId: "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyy",
extraQueryParameter: "nux=1",
endpoints: endPoints
}, $httpProvider);
}
])のようなものを追加します。その後
、ごstartup.csに次のようなサービスアプリケーションを設定する必要があります。
app.UseWindowsAzureActiveDirectoryBearerAuthentication(
new WindowsAzureActiveDirectoryBearerAuthenticationOptions
{
TokenValidationParameters = new TokenValidationParameters
{
/* "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx" is the Service Application ID. (Same as you registered in the client app above)*/
ValidAudience = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
RoleClaimType = "roles"
},
/*enant is your tenant name (same as you registered in client app above)*/
Tenant = "{NAME}.onmicrosoft.com"
});
最後に、あなたは= Azureのアクティブディレクトリ=>エンタープライズアプリケーション=>すべてのアプリケーションに移動する必要があります>を選択あなたのwebAPIサービス=>ユーザーとグループ=>ユーザーをロールに割り当てます。あなたが役割
このアプローチを学ぶことが
出典
2017-08-21 22:16:26
Ted
は、ロールに私たちのグループをマッピングし、AzureのActive Directoryのプレミアムのために行くことなく、役割ベースの認証を行うことです。 とにかく、ADAL.jsを使用してトークンを取得してから、サーバー側でMicrosoft Graph APIを呼び出してグループをトークンに挿入できますか? – Pickle
いいえ、不可能です。トークンはAzure ADから発行/署名されているためです。セキュリティの考慮事項のためにトークンを変更することはできません。 –