gpt4 book ai didi

java - 制作我自己的 Kerberos 身份验证票证

转载 作者:可可西里 更新时间:2023-11-01 16:11:05 25 4
gpt4 key购买 nike

我正在使用 Java 类 org.apache.hadoop.security。来自 Apache 的 authentication.server.AuthenticationFilterHadoop 2.5.0 作为 Tomcat 6 Servlet 前面的过滤器我们希望添加 Kerberos 身份验证。

我正在尝试针对此过滤器编写一些测试用例以便我们更好地了解它是如何工作原理以及它的作用。

为了让过滤器对用户进行身份验证,它正在读取HTTP 请求的“授权” header ,期望值包含“协商”

我对 Kerberos 工作原理的理解使我相信我应该能够在创建我的时编写代码看起来像这样的 HTTP 请求:

// normally the server principal keytab is not available from the client side,
// but for the purpose of making test cases I see no problem with sharing the keytab
// between the client side and the server side
javax.security.auth.kerberos.Keytab kt = KeyTab.getInstance("keytab");
KerberosKey keys[] = kt.getKeys("HTTP/voltage-pp-0000.albert.int@ALBERTS.INT");
SomeTokenType token = new SomeTokenType();
<code to set token parameters>

// my understanding of Kerberos is that the only cyphertext key
// needed on this token
// is one of the server principal's keys from the Keytab file
// (which does contain ~5
// keys of different sizes and types, I've checked)
EncryptedTokenType etoken = <encrypt token with a key from keys>
byte[] array = etoken.getBytes();

httprequest.addHeader("Authorization","Negotiate " + new Base64(0).encode(array));

所以,问题在这里:

  1. 包含发送的 Kerberos 授权 token 的 Java 类是什么 在“授权协商”中?
  2. 该身份验证 token 的哪些字段必须设置为哪些值?
  3. 用于加密授权 token 的加密算法是什么 针对 keytab 键?
  4. 最好使用的 keytab key 是什么?
  5. 一次对授权 token 进行字节序列化的机制是什么 加密?

最佳答案

您是正确的,因为以这种方式“伪造”票证是可能的。但是,我知道没有标准的 kerberos API 可以执行此操作。

您基本上需要对整个 kerberos 协议(protocol)进行逆向工程以根据 key 表创建服务票证。服务单格式为记录在这里

https://www.ietf.org/rfc/rfc4120.txt

您可以使用 key 表中的任何 key 来加密服务票证。一次你有服务票,你需要实现这个 RFC 来创建协商 header 。

https://www.rfc-editor.org/rfc/rfc4559

通常,为客户端主体获取 key 表并使用它和 kinit 获取用于测试的服务票据要简单得多。你的方法可行并且可能在某个地方有黑客代码来实现它,但它是在 kerberos 环境中进行测试的一种非常不标准的方法。

关于java - 制作我自己的 Kerberos 身份验证票证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31036483/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com