【问题标题】:Using OpenIdConnect without specifying metadata endpint在不指定元数据端点的情况下使用 OpenId Connect
【发布时间】:2017-02-01 22:18:20
【问题描述】:

我正在 ASP.Net MVC C# 中开发一个依赖方,它应该在外部身份提供程序中进行身份验证,我正在使用 Microsoft 的 owin 库。我遇到的问题是 Idp 没有公开元数据端点,即使我没有在配置中指定它,当我尝试联系 Idp 时也会引发异常。

[InvalidOperationException: IDX10803: 无法创建获取 配置来自: 'https://domain.com/oidc/.well-known/openid-configuration'.]

我有以下代码sn-p:

            var options = new OpenIdConnectAuthenticationOptions();
            options.AuthenticationType = authenticationType;            
            options.ClientId = clientConfiguration.ClientID;
            options.ClientSecret = AppSettings.ClientSecret;            
            options.Notifications = new OpenIdConnectAuthenticationNotifications
            {
                SecurityTokenValidated = n => ReceiveValidSecurityToken(n),
                RedirectToIdentityProvider = n => ROSAddProtocolToken(n, clientConfiguration),
                AuthenticationFailed = n => AuthenticationFailed(n),
            };
            options.Authority = AppSettings.Authority;

            options.RedirectUri = clientConfiguration.GetPostLoginRedirectUri(clientConfiguration.CurrentCulture).ToString();
            options.ResponseType = "code";
            options.Scope = AppSettings.Scope;
            options.ClientSecret = clientConfiguration.ClientSecret;

            options.SignInAsAuthenticationType = CookieAuthenticationDefaults.AuthenticationType;

我的问题是,如何指定 MS Owin 库中的所有端点(授权、令牌、用户信息、Jwls)?

Idp 需要以下设置: 范围:openid Http 绑定:GET 响应类型:代码 令牌端点认证方法:client_secret_jwt

【问题讨论】:

  • 你在运行你的 Idp 吗?此外,此 Idp 是否配置了上述 ResponseTypeScope。错误说..客户端无法与 Idp 通信。
  • 您是否可以使用AppSettings.Authority 中的链接访问 idp 发现文档?
  • 我已经用 Idp 规范更新了帖子。 Idp 在我们公司外部,我无法更改。元数据端点被阻止,例如我无法使用浏览器检索元数据。
  • 我认为您的域无法访问 Idp。这可能是访问/防火墙问题。我会先检查 idp。证书也可以。
  • 这不是问题。 idp 根本不暴露元数据端点,外部公司说他们不允许发现,所以他们故意阻止它。

标签: c# asp.net owin openid-connect


【解决方案1】:

好吧,几个小时后,我想出了如何指定端点。

var options = new OpenIdConnectAuthenticationOptions();
            options.Configuration = new OpenIdConnectConfiguration
            {
                AuthorizationEndpoint = AppSettings.Authority + "/" + AutorizationEndpointSufix,                
                JwksUri = AppSettings.Authority + "/" + JwksEndpointSufix,
                TokenEndpoint = AppSettings.Authority + "/" + TokenEndpointSufix,
                UserInfoEndpoint = AppSettings.Authority + "/" + UserInfoEndpointSufix,
                Issuer = AppSettings.Authority

            };

如果您实例化配置属性,那么它将忽略元数据。我设法从授权端点获得响应,只是想知道如何触发令牌端点,知道吗?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-10-09
    • 2018-04-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-11
    • 1970-01-01
    • 2016-11-15
    相关资源
    最近更新 更多