gpt4 book ai didi

java - 为什么 Kerberos/SPNEGO 身份验证不起作用?

转载 作者:行者123 更新时间:2023-11-28 23:12:05 27 4
gpt4 key购买 nike

我正在使用 Vaadin 框架开发 Java 网络应用程序。我想在不提示输入用户名和密码的情况下对用户进行身份验证。为此,我想实现 Kerberos/SPNEGO 以将这些内容注入(inject)我的 Java 代码中。 我只需要有连接到 webApplication 的用户的域用户名

我按照网站上的说明进行操作:https://tomcat.apache.org/tomcat-9.0-doc/windows-auth-howto.html

然后我做了这里描述的所有事情:http://spnego.sourceforge.net/troubleshoot_hellokeytab.html

现在我有工作的 HelloKDC 返回我:

Postdated Ticket false
Renewable Ticket false
Initial Ticket false
Auth Time = Tue Jun 18 11:25:22 CEST 2019
Start Time = Tue Jun 18 11:25:22 CEST 2019
End Time = Tue Jun 18 21:25:22 CEST 2019
Renew Till = null
Client Addresses Null
Private Credential: C:\tomcat.keytab for
HTTP/myserver.eu.corp.mycompany.net@EU.CORP.MYCOMPANY.NET
Connection test successful.

key 表是使用以下方法生成的:

ktpass -out c:\tomcat.keytab /princ 
HTTP/myserver.eu.corp.mycompany.net@EU.CORP.MYCOMPANY.NET /pass myPass!
/mapuser serviceUser /crypto AES256-SHA1 /ptype KRB5_NT_PRINCIPAL

请记住,该应用程序服务器位于 myserver.EU.CORP.MYCOMPANY.NET 中,而用户来自 CORP.MYCOMPANY.NET 域。

protected void init(VaadinRequest request) {  
System.out.println("5 " + request.getRemoteUser());
}

返回空值。

Tomcat web.xml:

<filter>
<filter-name>SpnegoHttpFilter</filter-name>
<filter-class>net.sourceforge.spnego.SpnegoHttpFilter</filter-class>

<init-param>
<param-name>spnego.allow.basic</param-name>
<param-value>false</param-value>
</init-param>

<init-param>
<param-name>spnego.allow.localhost</param-name>
<param-value>true</param-value>
</init-param>

<init-param>
<param-name>spnego.allow.unsecure.basic</param-name>
<param-value>false</param-value>
</init-param>

<init-param>
<param-name>spnego.login.client.module</param-name>
<param-value>spnego-client</param-value>
</init-param>

<init-param>
<param-name>spnego.krb5.conf</param-name>
<param-value>C:\Program Files\Apache Software Foundation\Tomcat 9.0\bin\krb5.conf</param-value>
</init-param>

<init-param>
<param-name>spnego.login.conf</param-name>
<param-value>C:\Program Files\Apache Software Foundation\Tomcat 9.0\conf\login.conf</param-value>
</init-param>

<init-param>
<param-name>spnego.preauth.username</param-name>
<param-value></param-value>
</init-param>

<init-param>
<param-name>spnego.preauth.password</param-name>
<param-value></param-value>
</init-param>

<init-param>
<param-name>spnego.login.server.module</param-name>
<param-value>spnego-server</param-value>
</init-param>

<init-param>
<param-name>spnego.prompt.ntlm</param-name>
<param-value>false</param-value>
</init-param>

<init-param>
<param-name>spnego.logger.level</param-name>
<param-value>1</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>SpnegoHttpFilter</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>

krb5.conf:

[libdefaults]
default_realm = EU.CORP.MYCOMPANY.NET
default_tkt_enctypes = aes256-cts aes256-cts-hmac-sha1-96 aes128-cts- hmac-sha1-96 aes128-cts rc4-hmac des3-cbc-sha1 des-cbc-md5 des-cbc-crc arcfour-hmac arcfour-hmac-md5
default_tgt_enctypes = aes256-cts aes256-cts-hmac-sha1-96 aes128-cts-hmac-sha1-96 aes128-cts rc4-hmac des3-cbc-sha1 des-cbc-md5 des-cbc-crc arcfour-hmac arcfour-hmac-md5
permitted_enctypes = aes256-cts aes256-cts-hmac-sha1-96 aes128-cts-hmac-sha1-96 aes128-cts rc4-hmac des3-cbc-sha1 des-cbc-md5 des-cbc-crc arcfour-hmac arcfour-hmac-md5
forwardable=true
[realms]
EU.corp.mycompany.net = {
kdc = EUGBDC001.EU.CORP.MYCOMPANY.NET:88
default_domain = EU.CORP.MYCOMPANY.NET
}
[domain_realm]
eu.corp.mycompany.net= EU.CORP.MYCOMPANY.NET
.eu.corp.mycompany.net= EU.CORP.MYCOMPANY.NET

登录配置文件:

spnego-client {
com.sun.security.auth.module.Krb5LoginModule required;
};

spnego-server {
com.sun.security.auth.module.Krb5LoginModule required
storeKey=true
useKeyTab=true
keyTab="file:///C:/tomcat.keytab"
principal="HTTP/myserver.eu.corp.mycompany.net@EU.CORP.MYCOMPANY.NET";
};

似乎没有正确的身份验证。我做错了什么?

最佳答案

经过多日的寻找选择,我找到了解决我的案例的办法。

我的过滤器似乎只适用于 *.jsp 应用程序。我刚刚改变了:

<filter-mapping>
<filter-name>SpnegoHttpFilter</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>

对于:

<filter-mapping>
<filter-name>SpnegoHttpFilter</filter-name>
<url-pattern>*</url-pattern>
</filter-mapping>

它解决了我的问题,也许它会对某人有所帮助。

关于java - 为什么 Kerberos/SPNEGO 身份验证不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56646301/

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