🗂

App Service 認証でログイン時に指定するスコープを変更したい

2021/12/06に公開

Azure App Service で Azure AD の認証を設定した際に Web 画面でサインインするときに取得するアクセス トークンのスコープを指定する方法をいつも忘れるのでメモっておきます。

認証を構成したあとに、Azure Resource Explorersubscriptions -> サブスクリプション名 -> resourceGroups -> リソースグループ名 -> providers -> Microsoft Web -> sites -> リソース名 -> config -> authsettingsV2 を選択します。

選択すると JSON で設定項目が表示されるので identityProviders -> azureActiveDirectory -> login -> loginParameters に配列でログイン URL のパラメーターを設定できます。

例えば別の Azure AD のアプリの API を呼び出したい場合は以下のような雰囲気になります。

"identityProviders": {
    "azureActiveDirectory": {
        "enabled": true,
        ...省略...
        "login": {
            "loginParameters": [
                "response_type=code id_token",
                "scope=email openid profile api://xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/user_impersonation"
            ],
            "disableWWWAuthenticate": false
        },
        ...省略...
    }
},

参考

https://learn.microsoft.com/ja-jp/azure/app-service/scenario-secure-app-access-microsoft-graph-as-user?tabs=azure-resource-explorer

Microsoft (有志)

Discussion