single-sign-on - 反向代理后面的 Jira 5.2 Seraph SSO 登录

标签 single-sign-on jira reverse-proxy webseal

几天以来,我试图为 Jira 5.2 启用 SSO,并发现 Jira 的帮助页面已经过时。

每个示例都使用旧版本的 atlassian-seraph(Jira 5.2 使用 2.6.0)。

目标:
如果我登录到 Webseal(反向代理),我想自动登录到 Jira。

背景:

sequence diagram

  • Jira 在反向代理后面(见图)。
  • 该代理对用户进行身份验证并保持 session 。
  • 如果我已登录,我也想登录 Jira
  • 提供的唯一信息是用户名

  • 问题:

    如何编写从 http_header 读取用户名并验证用户的自定义登录模块?

    链接:
  • https://confluence.atlassian.com/display/DEV/Single+Sign-on+Integration+with+JIRA+and+Confluence
  • http://docs.atlassian.com/atlassian-seraph/latest/sso.html
  • https://answers.atlassian.com/questions/23245/how-to-integrate-jira-with-my-company-s-sso
  • 最佳答案

    最后我自己想通了:

  • 您需要一个自定义身份验证器
    public class MyCustomAuthenticator extends DefaultAuthenticator {
    
      protected boolean authenticate(Principal user, String password)
        throws AuthenticatorException {
        return true;
      }
    
      protected Principal getUser(String username) {
       return getCrowdService().getUser(username);
      }
    
      private CrowdService getCrowdService() {
        return (CrowdService)ComponentManager.getComponent(CrowdService.class);
      }
    }
    
  • 将 MyCustomAuthenticator 添加到 seraph-config.xml
    <authenticator class="com.company.jira.MyCustomAuthenticator"/>
    
  • 编写一个自定义过滤器来设置来自 http-header 的用户名
    public class CustomFilter extends PasswordBasedLoginFilter {
    
        @Override
        protected UserPasswordPair extractUserPasswordPair(
            HttpServletRequest request) {
            String username = request.getHeader("iv-header");
    
            if (username != null && username.trim().length() != 0) {
                return new PasswordBasedLoginFilter.UserPasswordPair(
                    username, "DUMMY", false);
            }
            return null;
        }
    }
    

  • 替换 web.xml 中的过滤器
    <filter>
       <filter-name>login</filter-name>
       <filter-class>com.company.jira.CustomFilter</filter-class>
     </filter>
    

  • Jira 5.2 需要这些 jar
  • 嵌入式人群 api-2.6.2
  • jira-core-5.2.1
  • atlassian-seraph-2.6.0
  • 关于single-sign-on - 反向代理后面的 Jira 5.2 Seraph SSO 登录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16273566/

    相关文章:

    c# - 开源单点登录项目

    google-plus - Google+ 登录 : authenticating session users

    jquery - 无法更改 fullcalendar 事件颜色 ('fc-event-inner' CSS)(在 JIRA 下使用)

    apache - 带有 Apache HTTPD 的负载均衡器

    docker - docker反向代理:无法在多个网桥网络上使用jwilder/nginx反向代理

    nginx - 通过 nginx 反向代理在 docker 容器内的 phpMyAdmin

    用于创建加密 SAML 断言的 Java 代码

    java - 使用 jdbc 和 Kerberos 委派连接到 SAP HANA 数据库

    c# - 如何通过 rest api 更新问题状态?

    JIRA 与 Service-Now 的软件项目管理对比