当前位置: 首页 > 知识库问答 >
问题:

如何使用Onelogin将我的Web应用程序配置为SAML测试连接器(SP)?

彭弘方
2023-03-14

我已使用SAML测试连接器将我的Web应用程序添加到onelogin中。在配置选项卡中,我给出了以下值

收件人:http://localhost:8080/em/live/pages/samlAuth/

ACS(消费者)URL验证器*:^

ACS(消费者)URL*:http://localhost:8080/ws_em/rest/accounts/consume-saml公司

登录网址:http://localhost:8080/ws_em/rest/accounts/produce-saml

哪里http://localhost:8080/ws_em/rest/accounts/produce-saml通过将IssuerUrl、从Onelogin SSO选项卡复制的samlendpoint和ACS url作为http://localhost:8080/ws_em/rest/accounts/consume-萨姆勒。

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    @Path("/produce-saml")
    public com.virima.em.core.Response SAMLAuthentication(){
         com.Response resp = new com.Response();
         AppSettings appSettings = new AppSettings();
         appSettings.setAssertionConsumerServiceUrl(ACSUrl);
         appSettings.setIssuer(IssuerUrl));
         AccountSettings accSettings = new AccountSettings();
         accSettings.setIdpSsoTargetUrl(IdpSsoTargetUrl);
         AuthRequest authReq = new AuthRequest(appSettings,accSettings);
         Map<String, String[]> parameters = request.getParameterMap();
         String relayState = null;
         for(String parameter : parameters.keySet()) {
           if(parameter.equalsIgnoreCase("relaystate")) {
             String[] values = parameters.get(parameter);
             relayState = values[0];
           }
        }
        String reqString = authReq.getSSOurl(relayState);
        response.sendRedirect(reqString);
        resp.setResponse(reqString);
        return resp;
 }

http://localhost:8080/ws_em/rest/accounts/consume-saml调用应该接受我的SAML请求并进行身份验证。这里我使用Onelogin SSO选项卡中生成的证书

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    @Path("/consume-saml")
    public com.onelogin.saml.Response SAMLAuthenticationResponse(){
        com.onelogin.saml.Response samlResponse = null;
        String certificateS ="c"; //Certificate downloaded from Onelogin SSO Tab
        AccountSettings accountSettings = new AccountSettings();
        accountSettings.setCertificate(certificateS);
        samlResponse = new com.onelogin.saml.Response(accountSettings,request.getParameter("SAMLResponse"),request.getRequestURL().toString());
       if (samlResponse.isValid()) {
           // the signature of the SAML Response is valid. The source is trusted
            java.io.PrintWriter writer = response.getWriter();
            writer.write("OK!");
            String nameId = samlResponse.getNameId();
            writer.write(nameId);
            writer.flush();
      } else {
         // the signature of the SAML Response is not valid
        java.io.PrintWriter writer = response.getWriter();
        writer.write("Failed\n");
        writer.write(samlResponse.getError());
        writer.flush();
      }
            return samlResponse;
}

我得到这个错误

联盟异常:URL格式错误。请与管理员联系。

它似乎没有进入我的应用程序内的ACS url。

我的配置有什么错误吗?或者有更好的方法来做到这一点?

共有1个答案

苏星宇
2023-03-14

ACS是断言消费者服务,是在SP处理身份提供者发送的SAMLResponse的endpoint,因此http://localhost:8080/ws_em/rest/accounts/consume-saml处理并验证saml响应。

您有详细的跟踪错误吗?格式错误的URL必须是代码试图使用非URL字符串构建URL var。

顺便说一句,您使用的是java saml工具包,但1.0版本是推荐的2.0版本。

我强烈建议您使用2.0,在进行集成之前,尝试运行应用程序示例

 类似资料:
  • null null 我试图使示例应用程序针对Weblogic IDP和Shibboleth IDP进行身份验证,但我没有设法使其工作。不是配置不完整就是我缺少了一些基本的东西。

  • 问题内容: 我有一个使用React的网络应用程序,我正在尝试使用Selenium RC创建一些测试。我发现,当Selenium更改字段的值时,不会正确触发事件。我知道这是一个典型的问题,正如WebDriver常见问题所证明的那样,我已经尝试了很多不同的事情,例如使用onFocus而不是onChange并使用sendKeys()和type()确保焦点进出,以编程方式调用该事件以及我可以在网上找到的任

  • 我的应用程序是用Flatter和Firebase RTDB(数据库1)开发的。它是为IOS和Android构建的。 我有一个使用JS和Firebase RTDB(数据库2)开发的辅助应用程序。它是为Web创建的。 现在,我想从我的Flatter应用程序中写入数据库2。我应该一步一步地做什么? 我尝试使用以下方法应用添加多个项目: 但我不确定这是否是一个安全的过程,我不知道如何调用辅助数据库实例..

  • 问题内容: 我刚刚在我的express应用程序中添加了shouldjs和mocha进行测试,但是我想知道如何测试我的应用程序。我想这样做: 当然,测试套件中的最后一个测试只是告诉med,res.render函数(在show_create_user_screen中调用)是未定义的,可能是因为服务器未运行且配置尚未完成。所以我想知道其他人如何设置他们的测试? 问题答案: 好的,虽然测试路由代码是您可能

  • 我有一个部署在Tomcat中的webapp。 webapp使用< code>db.properties文件来解析< code > application context . XML 中的< code>dataSource bean属性: 在此示例中 文件放置在 Tomcat 的公共 目录中。 我不想把它放在公共的,而是放在一个单独的子目录中,比如,并且不应该在应用程序源代码中配置,而应该在Tomc

  • 问题内容: 我正在练习制作一个与PostgreSQL数据库交互的Golang Web应用程序,每个应用程序都在各自的容器上运行。 我正在运行容器 但是我似乎无法正确设置postgres容器。 为简便起见,指向s和其他设置文件的链接位于此要点上(如果您需要在此处,请告诉我)。 工作良好。但是,当应用程序尝试使用以下方法打开数据库连接时: 我从docker compose得到以下错误: 如何使两个容器