在 ASP.NET Core 中,为什么 AddOpenIdConnect 不像 AddoAuth 那样将 AuthorizationEndpoint 作为选项?
In ASP.NET Core, why AddOpenIdConnect does not have AuthorizationEndpoint as an option, like AddoAuth has?
OIDC 需要授权端点。尽管如此,AddOpenIDConnect 没有 AuthorizationEndpoint 选项,而 AddOAuth 有。
OpenID Connect 处理程序通常使用特殊的“发现”端点来查找授权端点(除其他外)。
它需要您的权限并在其后附加“/.well-known/openid-configuration”以获取元数据。
从那里它从 JSON.
得到 authorization_endpoint
例如,将权限设置为 https://login.microsoftonline.com/common/v2.0
(Azure AD) 将从 https://login.microsoftonline.com/common/v2.0/.well-known/openid-configuration.
获取元数据
{
"authorization_endpoint":"https://login.microsoftonline.com/common/oauth2/v2.0/authorize"
}
请注意,这是处理程序默认情况下使用最少配置执行的操作。
您可以设置 MetadataAddress
而不是 Authority
以手动设置发现端点 URL。
如果您根本不想使用发现端点,
您可以手动提供 Configuration
属性:
o.Configuration = new Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectConfiguration
{
// Other properties omitted
AuthorizationEndpoint = ""
};
OIDC 需要授权端点。尽管如此,AddOpenIDConnect 没有 AuthorizationEndpoint 选项,而 AddOAuth 有。
OpenID Connect 处理程序通常使用特殊的“发现”端点来查找授权端点(除其他外)。 它需要您的权限并在其后附加“/.well-known/openid-configuration”以获取元数据。
从那里它从 JSON.
得到authorization_endpoint
例如,将权限设置为 https://login.microsoftonline.com/common/v2.0
(Azure AD) 将从 https://login.microsoftonline.com/common/v2.0/.well-known/openid-configuration.
{
"authorization_endpoint":"https://login.microsoftonline.com/common/oauth2/v2.0/authorize"
}
请注意,这是处理程序默认情况下使用最少配置执行的操作。
您可以设置 MetadataAddress
而不是 Authority
以手动设置发现端点 URL。
如果您根本不想使用发现端点,
您可以手动提供 Configuration
属性:
o.Configuration = new Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectConfiguration
{
// Other properties omitted
AuthorizationEndpoint = ""
};