admin_consent 用于 openid 连接和动态范围

admin_consent for openid connect and dynamic scopes

我们有一个使用 openid connect 的网络应用程序,以 azure 作为身份提供者来登录用户。因此,用户在登录时会发送到 URL,例如:

https://login.microsoftonline.com/{tenant}/oauth2/v2.0/authorize?response_type=id_token+token&client_id=3{clientId}&response_mode=form_post&redirect_uri=http://localhost:8765/ms/oidc/signon/response&scope=openid+profile+https://graph.microsoft.com/user.read&state=1234&nonce={nonce}

这很好用,但需要用户在第一次使用时同意我们的应用程序权限范围。

我们希望为 office365 管理员提供代表其整个租户同意的能力,因此我们将他们发送到如下端点:

https://login.microsoftonline.com/common/adminconsent?client_id={clientId}&state=12345&redirect_uri=http://localhost:8765

这似乎也能正常工作,我通知管理员他们将代表其租户中的所有用户同意。但是,用户在首次登录时仍会看到同意提示。 这是有道理的,因为该应用程序只注册了 user.read 权限,所以如果我们改为将用户发送到

https://login.microsoftonline.com/{tenant}/oauth2/v2.0/authorize?response_type=token&client_id={clientId}&response_mode=form_post&redirect_uri=http://localhost:8765/ms/oidc/signon/response&scope=https://graph.microsoft.com/user.read&state={state}&nonce={nonce}

在没有动态权限请求且响应类型仅设置为令牌的情况下,管理员同意有效,并且不会向用户显示同意提示。 所以,我想我有 2 个问题:

1) 这是它应该如何工作,还是有一些方法可以授予管理员对配置文件和 openid 范围的同意?

2) 不请求这些 (openid+profile) 权限,我真的遗漏了什么吗?我没有收到 id_token 的回复,但似乎 authentication_token 已经包含了比 id_token 更多的信息

1) is this how it's supposed to work, or is there some way to grant admin consent to the profile and openid scopes?

似乎是 azure ad v2.0 consent framework 中的一个错误,当您执行管理员权限时,默认情况下应授予众所周知的范围(openid,profile)。请参考 this link

2) Am I actually missing anything by not requesting these(openid+profile) permissions? I don't receive and id_token in the response, but is seems the authentication_token already contains even more information than the id_token does anyway

您没有使用 OpenID 连接,因为您还没有添加 openid 范围,所以 id_token 没有返回。但是由于你有microsoft graph api的user.read权限,你可以使用microsoft graph api读取用户的基本信息。 Id_token 和 access token 不同,id_token 用来标识认证用户。 access_token 用于证明对受保护资源的访问权限。请点击here了解更多详情。