【问题标题】:Set up end to end Kerberos Authentication in Gemfire(Apache Geode)在 Gemfire(Apache Geode)中设置端到端 Kerberos 身份验证
【发布时间】:2020-05-01 22:41:49
【问题描述】:

我想使用 kerberos 身份验证来保护 gemfire(v9.9) 集群。

我相信我必须这样做,

  1. 使用 JAAS 和 keytab 将客户端和 gemfire 服务器验证到 KDC(在我的例子中是活动目录)
  2. 在客户端使用Subject.doAsSubject获取会话票证(byte []
  3. 将此字节[] 传递给 gemfire 服务器
  4. 在 gemfire 服务器上检查收到的票是否正确

我在这里找到了一些示例代码https://www.programcreek.com/java-api-examples/?code=ampool/monarch/monarch-master/ADS/geode-core/src/main/java/io/ampool/security/KerberosAuthInit.java

我能够成功地执行 LoginContect.login() 并在客户端和 gemfire 服务器上获得 Subject

我的代码:

LoginContext loginCtx = new LoginContext("Client", new TextCallbackHandler());
loginCtx.login();
Subject subject = loginCtx.getSubject();

GSSManager manager = GSSManager.getInstance();
GSSName serverName = manager.createName( servicePrincipalName, GSSName.NT_HOSTBASED_SERVICE);
final GSSContext context = manager.createContext( serverName, new Oid( "1.2.840.113554.1.2.2"), null, GSSContext.DEFAULT_LIFETIME);

byte[] serviceTicket = 
        Subject.doAs(subject, new PrivilegedExceptionAction<byte[]>() {
            @Override
            public byte[] run() throws Exception {
                byte[] serviceTicket = null;
                byte[] token = new byte[0];
                // This is a one pass context initialisation.
                context.requestMutualAuth(false);
                context.requestCredDeleg(false);
                serviceTicket = context.initSecContext(token, 0, token.length);  //code fails here 
                                                                                /*java.security.PrivilegedActionException: 
                                                                                GSSException: No valid credentials provided 
                                                                                    (Mechanism level: Server not found in Kerberos database (7) - UNKNOWN_SERVER)
                                                                                Caused by: KrbException: Identifier doesn't match expected value (906)

                                                                                */
                return serviceTicket;
          }
        });

//send this serviceTicket to gemfire server and then do

//--------------------at the gemfire server level-------------------
String clientContext =
        Subject.doAs( serverSubject, new PrivilegedAction<String>() {
              public String run() {
                try {
                    String clientName = null;
                    // Identify the server that communications are being made to.
                    GSSManager manager = GSSManager.getInstance();
                    GSSContext context = manager.createContext((GSSCredential) null);
                    context.acceptSecContext(serviceTicket, 0, serviceTicket.length);
                    clientName = context.getSrcName().toString();
                    return clientName;
                }
                catch ( Exception e) {
                  e.printStackTrace();
                  return null;
                }
              }
            }
        );

我曾经到达这里的链接

https://github.com/ekoontz/jaas_and_kerberos https://cwiki.apache.org/confluence/display/GEODE/Geode+Security+Framework

我的问题:

  • 我的方法正确吗?
  • 如何获得 byte[] 会话票
  • 在 gemfire 服务器级别验证票证是否正确

【问题讨论】:

    标签: java kerberos gemfire java-security geode


    【解决方案1】:

    在 Gemfire 9.9 中,您应该开始使用集成的安全框架。您使用的链接“https://cwiki.apache.org/confluence/display/GEODE/Geode+Security+Framework”是已弃用的“Authenticator”接口。以下是一些关于 Gemfire 中新的集成安全性的提示:

    https://cwiki.apache.org/confluence/display/GEODE/Geode+Integrated+Security https://cwiki.apache.org/confluence/display/GEODE/Using+Custom+SecurityManager

    基本上,AuthInitialize 接口允许客户端代码将凭据(无论它们是什么形式)发送到服务器,服务器端的 SecurityManager 将对客户端提供的凭据进行身份验证。

    【讨论】:

    • 我如何使用 kerberos 作为身份验证机制,有关如何实现检查 kerberos 票证的 SecurityManager 的任何指南或链接。
    • 那在 Geode 领域之外。建议您为此查看 kerberos 文档。
    猜你喜欢
    • 2011-02-27
    • 2015-12-23
    • 2017-06-28
    • 1970-01-01
    • 1970-01-01
    • 2022-06-23
    • 2015-06-22
    • 1970-01-01
    相关资源
    最近更新 更多