如何在 Identity Server 中设置 .well-known/openid-configuration 端点
How to set up .well-known/openid-configuration endpoint in Identity Server
我是 OpenID Connect 和 Identity Server 的新手,我正在尝试使用 Dylan Beattie IdentityServer3.Samples MVC Authentication project. The problem is that I don't see where a .well-known config endpoint is set up there and I'm not sure how to go about setting that up. I've done a lot of searching for how to do this but have come up empty. I also followed this article 中的示例代码(减去 ngrok)设置测试服务器实例,但它似乎忽略了示例项目中没有 .well-known 端点这一事实。如何设置 .well-known/openid-configuration 端点?
发现端点在 IdentityServer3 本身中实现:
if (options.Endpoints.EnableDiscoveryEndpoint)
{
config.Routes.MapHttpRoute(
Constants.RouteNames.Oidc.DiscoveryConfiguration,
Constants.RoutePaths.Oidc.DiscoveryConfiguration,
new { controller = "DiscoveryEndpoint", action = "GetConfiguration" });
这是 DiscoveryEndpoint 控制器 DiscoveryEndpointController.cs
/// <summary>
/// GET
/// </summary>
/// <returns>Discovery document</returns>
[HttpGet]
public async Task<IHttpActionResult> GetConfiguration()
{
Logger.Info("Start discovery request");
var baseUrl = Request.GetIdentityServerBaseUrl();
var allScopes = await _scopes.GetScopesAsync(publicOnly: true);
var showScopes = new List<Scope>();
寻找使用 IdentityServer 的 .well-known/openid-configuration 的人无需修改上述答案,而是需要查看您在 Startup class.
中定义的映射文件夹
例如:
app.Map("/core", coreApp =>
这会将您为其他人发布的根路径更改为 [website]/core/.well-known/openid-configuration
这最初对我来说并不明显,因为我错误地认为根路径将被假定为我使用的服务的一致性。
我是 OpenID Connect 和 Identity Server 的新手,我正在尝试使用 Dylan Beattie IdentityServer3.Samples MVC Authentication project. The problem is that I don't see where a .well-known config endpoint is set up there and I'm not sure how to go about setting that up. I've done a lot of searching for how to do this but have come up empty. I also followed this article 中的示例代码(减去 ngrok)设置测试服务器实例,但它似乎忽略了示例项目中没有 .well-known 端点这一事实。如何设置 .well-known/openid-configuration 端点?
发现端点在 IdentityServer3 本身中实现:
if (options.Endpoints.EnableDiscoveryEndpoint)
{
config.Routes.MapHttpRoute(
Constants.RouteNames.Oidc.DiscoveryConfiguration,
Constants.RoutePaths.Oidc.DiscoveryConfiguration,
new { controller = "DiscoveryEndpoint", action = "GetConfiguration" });
这是 DiscoveryEndpoint 控制器 DiscoveryEndpointController.cs
/// <summary>
/// GET
/// </summary>
/// <returns>Discovery document</returns>
[HttpGet]
public async Task<IHttpActionResult> GetConfiguration()
{
Logger.Info("Start discovery request");
var baseUrl = Request.GetIdentityServerBaseUrl();
var allScopes = await _scopes.GetScopesAsync(publicOnly: true);
var showScopes = new List<Scope>();
寻找使用 IdentityServer 的 .well-known/openid-configuration 的人无需修改上述答案,而是需要查看您在 Startup class.
中定义的映射文件夹例如:
app.Map("/core", coreApp =>
这会将您为其他人发布的根路径更改为 [website]/core/.well-known/openid-configuration
这最初对我来说并不明显,因为我错误地认为根路径将被假定为我使用的服务的一致性。