SSO - 未找到 OpenID 端点

2023-12-04

我正在尝试让 SSO openid 与 dotnetopenauth 一起使用。

我有两个单独的项目,分别进行调试(都在本地主机上,但有两个不同的端口),一个充当提供者,一个充当依赖方。

依赖方正在运行localhost:1903。 提供者正在运行localhost:3314.

依赖方代码:

    public ActionResult Authenticate()
    {
        UriBuilder returnToBuilder = new UriBuilder(Request.Url);
        returnToBuilder.Path = "/OpenId/";
        returnToBuilder.Query = null;
        returnToBuilder.Fragment = null;

        Uri returnTo = returnToBuilder.Uri;
        returnToBuilder.Path = "/";
        Realm realm = returnToBuilder.Uri;
        realm = "http://localhost:3314/OpenId/";
        returnTo = new Uri("http://localhost:3314/OpenId/");
        var response = openid.GetResponse();

        if (response == null) {
            if (Request.QueryString["ReturnUrl"] != null && User.Identity.IsAuthenticated) {
            } else {
                string strIdentifier = "testidentifier";
                var request = openid.CreateRequest(
                    strIdentifier,
                    realm,
                    returnTo);

                var fetchRequest = new FetchRequest();
                request.AddExtension(fetchRequest);
                request.RedirectToProvider();
            }
        } else {
            switch (response.Status) {
                case AuthenticationStatus.Canceled:
                    //stuff got cancelled for some reason
                    break;
                case AuthenticationStatus.Failed:
                    //response.Exception.Message;
                    break;
                case AuthenticationStatus.Authenticated:
                    //a bunch of applying roles that i don't think we care about
                    break;
            }
        }

        return new EmptyResult();
    }

提供商代码:

    public ActionResult Index()
    {
        IAuthenticationRequest iR = (IAuthenticationRequest)Request;

        if (iR.IsReturnUrlDiscoverable(ProviderEndpoint.Provider.Channel.WebRequestHandler) != RelyingPartyDiscoveryResult.Success) {
            iR.IsAuthenticated = false;
            return new EmptyResult();
        }

        if (iR.IsDirectedIdentity) {
            if (User.Identity.IsAuthenticated) {
                iR.LocalIdentifier = BuildIdentityUrl();
                iR.IsAuthenticated = true;
            } else {
                if (iR.Immediate || ImplicitAuth) {
                    iR.IsAuthenticated = false;
                } else {
                    if (!Request.Path.EndsWith("Login", StringComparison.OrdinalIgnoreCase)) {
                        return RedirectToAction("Login", "User");
                    }
                }
            }
        } else {
            string userOwningOpenIdUrl = ExtractUserName(iR.LocalIdentifier);

            iR.IsAuthenticated = userOwningOpenIdUrl == User.Identity.Name;

            if (!iR.IsAuthenticated.Value && !ImplicitAuth && !iR.Immediate) {
                if (!Request.Path.EndsWith("Login", StringComparison.OrdinalIgnoreCase)) {
                    return RedirectToAction("Login", "User");
                }
            }
        }

        if (iR.IsAuthenticated.Value) {
            var fetchRequest = iR.GetExtension<FetchRequest>();

            if (fetchRequest != null) {
                var fetchResponse = new FetchResponse();
                //roles and stuff

                iR.AddResponseExtension(fetchResponse);
            }
        }

        return new EmptyResult();
    }

当我运行依赖方代码时,出现错误openid.CreateRequest方法。我在我的提供程序代码上启用了调试,但它从未被命中。

研究该错误时,我发现了很多有关代理问题的建议,但这对我来说不应该成为问题,因为我只会访问本地主机。

也许这是相当明显的事情,但我不知道我做错了什么。

先谢谢您的帮助!

编辑:仅供参考,我从 DotNetOpenAuth 示例中获取了此代码。


好吧,我最终手动单步查看源代码并在某种程度上解决了问题。

事实证明 dumdum 在某种程度上是正确的 - 我的第一个问题是它确实需要 URI 作为标识符,所以一旦我将标识符更改为http://localhost:3314/OpenId/(尽管这本身是无效的)我克服了这个例外。

第二个问题是我忘记向 web.config 添加信息 - 所以localhost未列入白名单并且CreateRequest那里失败了。

在我解决了这两个问题之后,我的提供程序代码得到了很好的解决 - 我在那里遇到了其他错误,但这是我想象的一个单独的问题。

网络配置:

<configSections>
  <sectionGroup name="dotNetOpenAuth" type="DotNetOpenAuth.Configuration.DotNetOpenAuthSection, DotNetOpenAuth">
    <section name="openid" type="DotNetOpenAuth.Configuration.OpenIdElement, DotNetOpenAuth" requirePermission="false" allowLocation="true"/>
    <section name="oauth" type="DotNetOpenAuth.Configuration.OAuthElement, DotNetOpenAuth" requirePermission="false" allowLocation="true"/>
    <section name="messaging" type="DotNetOpenAuth.Configuration.MessagingElement, DotNetOpenAuth" requirePermission="false" allowLocation="true"/>
    <section name="reporting" type="DotNetOpenAuth.Configuration.ReportingElement, DotNetOpenAuth" requirePermission="false" allowLocation="true"/>
    </sectionGroup>
</configSections>

<dotNetOpenAuth>
<openid>
  <relyingParty>
    <security requireSsl="false">
      <!-- Uncomment the trustedProviders tag if your relying party should only accept positive assertions from a closed set of OpenID Providers. -->
      <!--<trustedProviders rejectAssertionsFromUntrustedProviders="true">
        <add endpoint="https://www.google.com/accounts/o8/ud" />
      </trustedProviders>-->
    </security>
    <behaviors>
      <!-- The following OPTIONAL behavior allows RPs to use SREG only, but be compatible
           with OPs that use Attribute Exchange (in various formats). -->
      <add type="DotNetOpenAuth.OpenId.RelyingParty.Behaviors.AXFetchAsSregTransform, DotNetOpenAuth"/>
      <!--<add type="DotNetOpenAuth.OpenId.RelyingParty.Behaviors.GsaIcamProfile, DotNetOpenAuth" />-->
    </behaviors>
    <!-- Uncomment the following to activate the sample custom store.  -->
    <!--<store type="OpenIdRelyingPartyWebForms.CustomStore, OpenIdRelyingPartyWebForms" />-->
  </relyingParty>
</openid>
<messaging>
  <untrustedWebRequest>
    <whitelistHosts>
      <!-- since this is a sample, and will often be used with localhost -->
      <add name="localhost"/>
    </whitelistHosts>
  </untrustedWebRequest>
</messaging>
<!-- Allow DotNetOpenAuth to publish usage statistics to library authors to improve the library. -->
<reporting enabled="true"/>
</dotNetOpenAuth>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

SSO - 未找到 OpenID 端点 的相关文章

随机推荐

  • 对象到对象映射实用程序

    我喜欢将公共和域完全分开objects 所以 nHibernate 在这里不会提供帮助 这最终迫使我编写大量代码来将一个对象映射到另一个对象 有哪些工具 插件可以消除在 NET 中手动执行此映射的单调乏味 每当我 Google 搜索此内容时
  • 使用 tr1::regex 时出现链接器错误

    我有一个程序使用tr1 regex 当它编译时 它给了我非常详细的链接器错误 这是我的头文件 MapObject hpp include
  • SQL Server 查询优化:Where (Col=@Col 或 @Col=Null)

    不知道从哪里开始 不确定问题是否是我欺骗了查询优化器 或者它是否是涉及空值时索引工作方式的固有问题 我遵循的一种编码约定是对存储过程进行编码 如下所示 declare procedure SomeProc ID int null as se
  • 使用 Worklight Console 部署应用程序失败:“无法部署应用程序 .wlapp”。:错误

    我正在使用 Worklight 5 0 6 20130311 0918 在 RedHat Linux 上的 WebSphere 应用程序服务器 7 0 0 21 上运行 并且我正在尝试使用 Worklight Console 部署应用程序
  • Javascript 焦点和选择在 FF 中不起作用

    使用jQuery 以下在FF中不起作用 但在IE中有效 this focus select 我环顾四周 发现你可以使用超时来解决这个问题 但如果我可以避免的话 这不是我想做的事情 有谁知道另一种方法来做到这一点并让它在 FF 中工作 都会
  • SQL Server 跟踪日期变化时的计划班次

    我什至不知道从哪里开始解决这个问题 我需要从我们的 MS SQL 2012 数据库查询生产数据 该数据库具有基于记录的班次的日期时间戳 棘手的部分是我们运行 4 个 12 小时班次采用 2 开 2 关 3 开 2 关的模式 即 2013 年
  • 如何绘制立方体的面?

    我已经做了一个可以在 python 上旋转的立方体 但现在我想为这些面着色 以便在旋转时识别每个面 代码如下 from mpl toolkits mplot3d import Axes3D import matplotlib pyplot
  • 如何使用 Tesseract 对图像进行 OCR

    我开始学习 OpenCV 和 Tesseract 并且在一个看似非常简单的示例上遇到了麻烦 这是我尝试 OCR 的图像 内容为 171 m 我做了一些预处理 由于蓝色是文本的主色 因此我提取蓝色通道并应用简单的阈值处理 img cv2 im
  • 执行Excel4Macro从关闭的工作簿中获取范围/图表

    我使用这些行从关闭的工作簿中获取值 Arg Path File Sheet R4C4 Arg CStr Arg GetValue ExecuteExcel4Macro Arg 除了循环之外还有其他方法从范围中获取值吗 循环解决方案正在工作
  • JavaScript 原型不工作

    嗨 我不知道这是否是我理解 Javascript 原型对象的错误 需要明确的是 我对 Javascript 单例概念很陌生 并且缺乏明确的知识 但是通过一些推荐网站 我为我的系统制作了示例代码 但它给出了一些错误 我找不到原因 所以我 我请
  • Android 创建位图时出现 OutOfMemory 错误

    我收到错误java lang OutOfMemoryError bitmap size exceeds VM budget 当为了手动绘制折线图而创建位图时会发生这种情况 width display getWidth 10 height w
  • Jenkins 日志变得巨大并填满了整个磁盘空间

    每周我都会惊讶地发现我的 Jenkins 服务器达到了 Jenkins 日志使用的 100 磁盘 所以我删除了该文件 然后我的磁盘再次获得大量可用空间 ec2 user ip xxx xxx xxx xxx df h Filesystem
  • 如何将环境设置导入到我的 Perl 程序中?

    我有一个脚本 其内容只是导出 Linux 中的一个变量 export LD LIBRARY PATH 我想在我的 Perl 脚本中运行这个脚本 这样无论是谁运行我的 Perl 脚本都会有他们的LD LIBRARY PATH放 我可以在 Pe
  • 初级ILNumerics:VS2012下安装

    我对 ILNUmerics 非常感兴趣 想尝试免费版本 但我遇到了麻烦 我已经从控制台应用程序开始 并尝试运行 hello ilnumerics 控制台应用程序 但我注意到 VS 无法找到 MKL 库 我在 Windwos 8 下使用 VS
  • Azure函数应用程序使用slf4j登录App Insights

    使用 Spring Cloud Functions 实现了 Azure Function App 在应用程序设置 APPINSIGHTS INSTRUMENTATIONKEY 中配置的 App Insights 检测密钥 我使用 lombo
  • react-native fetch - 请求正文 - 意外的 EOF

    在我的反应本机应用程序中 我尝试使用以下命令发出获取请求body 但是 我收到错误消息unexpected EOF 实际上 请求已发出 我的意思是我可以通过后端日志看到请求已发送 而在请求之后 它立即显示错误消息 这是我的fetch met
  • python: += s, 中的逗号有什么作用?

    我正在做一个问题 输入是字符串 abc bcd acef xyz az ba a z 代码如下所示 def groupStrings self strings groups collections defaultdict list for
  • 如何获取res文件夹的Uri?

    我正在尝试获取可绘制文件夹中图像的 Uri 我尝试了很多可能的方法 但似乎没有任何效果 谁能建议我如何获取 res 文件夹的 Uri 任何帮助深表感谢 嗯 实际上很容易 包中资源的基本 URI 类似于以下可能性 android resour
  • 如何为 iphone 5 设置 apple-touch-startup-image?

    I tried 但这没有用 苹果的界面指南还没有针对 iPhone 5 进行更新 有谁知道吗 谢谢 1 视口不要使用 width device width 使用以下代码
  • SSO - 未找到 OpenID 端点

    我正在尝试让 SSO openid 与 dotnetopenauth 一起使用 我有两个单独的项目 分别进行调试 都在本地主机上 但有两个不同的端口 一个充当提供者 一个充当依赖方 依赖方正在运行localhost 1903 提供者正在运行