简体   繁体   English

SPNEGO密码验证问题

[英]SPNEGO authentication issue with password

I have configured my application to use Kerberos authentication through SPNEGO with Websphere. 我已将我的应用程序配置为通过SPNEGO和Websphere使用Kerberos身份验证。

Here are the details 这是详细信息

krb5.conf 的krb5.conf

[libdefaults]
    default_realm = ABC.MYCOMPANY.COM
    default_keytab_name = FILE:C:\IBM\WebSphere\AppServer\kerberos\MyServer.keytab
    default_tkt_enctypes = rc4-hmac des-cbc-md5
    default_tgs_enctypes = rc4-hmac des-cbc-md5
    forwardable  = true
    renewable  = true
    noaddresses = true
    clockskew  = 300
[realms]
    ABC.MYCOMPANY.COM = {
        kdc = TEST.abc.mycompany.com:88
        default_domain = mycompany.com
    }
[domain_realm]
    .mycompany.com = ABC.MYCOMPANY.COM

login.conf login.conf的

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

spnego-server {
    com.sun.security.auth.module.Krb5LoginModule required
    storeKey=true
    useKeyTab=true
    keyTab="MyServer.keytab";
};

spnego properties spnego属性

Spnego properties:
spnego.allow.basic=false
spnego.allow.localhost=false
spnego.allow.unsecure.basic=false
spnego.login.client.module=spnego-client
spnego.login.server.module=spnego-server
spnego.prompt.ntlm=false
spnego.allow.delegation=true
spnego.logger.level=1

When I access my application, I get the following error 访问应用程序时,出现以下错误

Config missing param value for: spnego.preauth.password Stack Trace : java.lang.NullPointerException: Config missing param value for: spnego.preauth.password at net.sourceforge.spnego.SpnegoAuthenticator$1.getInitParameter(SpnegoAuthenticator.java:218) at net.sourceforge.spnego.SpnegoFilterConfig.<init>(SpnegoFilterConfig.java:145) at net.sourceforge.spnego.SpnegoFilterConfig.getInstance(SpnegoFilterConfig.java:316) at net.sourceforge.spnego.SpnegoAuthenticator.<init>(SpnegoAuthenticator.java:206)

Command to create keytab file 创建密钥表文件的命令

C:\IBM\WebSphere\AppServer\java>ktpass -out c:\temp\MyServer.keytab -princ HTTP/TEST.abc.mycompany.com@ABC.MYCOMPANY.COM -mapUser wasMyServer -mapOp set -pass mypassword -crypto RC4-HMAC-NT -pType KRB5_NT_PRINCIPAL

I am not using spnego password, I want it to use keytab, I don't understand why it is throwing error saying that param is missing. 我没有使用spnego密码,我希望它使用keytab,但我不明白为什么它会抛出错误,提示缺少参数。

While you didn't tag your question with Active-Directory, you must be running it because you are trying to use RC4-HMAC-NT, which used to be the dominant encryption algorithm to Microsoft Active Directory. 虽然您没有使用Active-Directory标记问题,但您必须运行它,因为您尝试使用RC4-HMAC-NT,它曾经是Microsoft Active Directory的主要加密算法。 I say used to be, because starting with Windows Server 2008 R2, AES26-SHA1 became the default encryption algorithm. 我曾经说过,因为从Windows Server 2008 R2开始,AES26-SHA1成为默认的加密算法。 That said, the Active Directory account wasMyServer needs to be configured to comply with the Kerberos Protocol. 也就是说,Active Directory帐户wasMyServer需要配置为符合Kerberos协议。 It should be a user account, not a computer account, according to WebSphere setup instructions, and to give you the flexibility to run the Kerberized service on the application server properly. 根据WebSphere设置说明,它应该是用户帐户,而不是计算机帐户,并为您提供了在应用程序服务器上正确运行Kerberized服务的灵活性。 That said, on the "Account" tab for the user account “wasMyServer”: 也就是说,在用户帐户“ wasMyServer”的“帐户”选项卡上:

  1. Ensure all account options (except password never expires) are unchecked. 确保未选中所有帐户选项(密码永不过期)。
  2. Ensure the SPN HTTP/TEST.abc.mycompany.com is assigned to the account. 确保将SPN HTTP / TEST.abc.mycompany.com分配给该帐户。

Reference: Administering SPNEGO within WebSphere Application Server: Tips on using Kerberos service principal names 参考: 在WebSphere Application Server中管理SPN​​EGO:使用Kerberos服务主体名称的提示

EDITS: EDITS:

KRB5.CONF 的krb5.conf

There appears to be a problem inside your krb5.conf. 您的krb5.conf内部似乎存在问题。 You have only these two lines showing as supporting RC4-HMAC: 您只有这两行显示为支持RC4-HMAC:

default_tkt_enctypes = rc4-hmac des-cbc-md5
default_tgs_enctypes = rc4-hmac des-cbc-md5

To fully enable the RC4-HMAC encryption type, add the additional line underneath: 要完全启用RC4-HMAC加密类型,请在下面添加其他行:

permitted_enctypes = rc4-hmac des-cbc-md5

(As a side note, no one uses des-cbc-md5 encryption type anymore, but I left it in there) (作为一个补充说明,没有人使用des-cbc-md5加密类型,但是我把它留在了那里)

The DNS domain name needs to be consistent throughout this file. DNS域名在整个文件中必须保持一致。 For simplicity sake, the DNS domain name and Kerberos realm name should match (apart from the Kerberos realm name being specified in UPPER case). 为简单起见,DNS域名和Kerberos领域名称应匹配(除了在UPPER情况下指定的Kerberos领域名称)。 They don't have to match, but it makes troubleshooting orders of magnitude harder when they don't match. 它们不必匹配,但是如果不匹配,则使疑难解答数量级增加。

Since you clarified that your AD domain name is abc.mycompany.com , I suggest to use a krb5.conf file which looks like this: 既然您澄清了您的AD域名是abc.mycompany.com ,我建议使用如下所示的krb5.conf文件:

[libdefaults]
    default_realm = ABC.MYCOMPANY.COM
    default_keytab_name = FILE:C:\IBM\WebSphere\AppServer\kerberos\MyServer.keytab
    default_tkt_enctypes = rc4-hmac des-cbc-md5
    default_tgs_enctypes = rc4-hmac des-cbc-md5
    permitted_enctypes = rc4-hmac des-cbc-md5
    forwardable  = true
    renewable  = true
    noaddresses = true
    clockskew  = 300
[realms]
    ABC.MYCOMPANY.COM = {
        kdc = TEST.abc.mycompany.com:88
        default_domain = abc.mycompany.com
    }
[domain_realm]
    .abc.mycompany.com = ABC.MYCOMPANY.COM
   abc.mycompany.com = ABC.MYCOMPANY.COM

Reference: Secure Communications Using Stronger Encryption Algorithms 参考: 使用更强大的加密算法的安全通信

SPNs 结节

All SPNs must be unique within any given Kerberos realm. 在任何给定的Kerberos领域中,所有SPN都必须是唯一的。 In the event of a duplicate SPN, run the below command to find the AD accounts to which duplicate SPNs are registered, and remove the SPN from the account which the SPN is not being used. 如果存在重复的SPN,请运行以下命令来查找已注册重复SPN的AD帐户,然后从未使用SPN的帐户中删除SPN。 The hint for that, is that the SPN to the AD account with which the keytab was generated is the only place where the SPN should be registered. 提示是,生成密钥表所用的AD帐户的SPN是应该注册SPN的唯一位置。 So for this case, only the AD account wasMyServer should have the SPN HTTP/TEST.abc.mycompany.com . 因此,在这种情况下,只有AD帐户wasMyServer应该具有SPN HTTP / TEST.abc.mycompany.com To find all duplicate SPNs in the Directory, run the following in a Windows Command Shell on a computer joined to the AD domain: 要在目录中查找所有重复的SPN,请在加入AD域的计算机上的Windows Command Shell中运行以下命令:

setspn -X

The output will list all AD accounts to which duplicate SPNs are registered, and you can take corrective action according to my guidance. 输出将列出注册了重复SPN的所有AD帐户,您可以根据我的指导采取纠正措施。 The command: 命令:

setspn -D HTTP/TEST.abc.mycompany.com wasMyServer

...will remove a duplicate SPN from an AD account name. ...将会从广告帐号中删除重复的SPN。 Or you can remove it within the AD Users and Computers GUI as well. 或者,您也可以在“ AD用户和计算机” GUI中将其删除。 Run the above command to clean the AD account each time right before you re-create the keytab. 在重新创建密钥表之前,每次都运行上述命令来清理AD帐户。

Keytab 密钥表

  1. Restart the WebSphere application service anytime you replace the keytab. 每次更换密钥表时,请重新启动WebSphere Application Service。
  2. Validate the keytab on the WAS server by running the following command. 通过运行以下命令来验证WAS服务器上的密钥表。 The validation pulls a Kerberos ticket from the KDC so if it is successful, that means nothing is wrong with the keytab. 验证会从KDC中提取Kerberos票证,因此,如果成功,则意味着密钥表没有任何问题。

kinit -k -t MyServer.keytab HTTP/TEST.abc.mycompany.com kinit -k -t MyServer.keytab HTTP / TEST.abc.mycompany.com

Note: kinit does not come with Windows, but it does come with Java JRE/JDK, so you need to either place a copy of the keytab into the same directory where kinit exists or otherwise ensure <JAVA HOME> is in the system PATH in order to run the command successfully. 注意:kinit不随Windows一起提供,但随Java JRE / JDK一起提供,因此您需要将keytab的副本放入kinit存在的同一目录中,否则请确保<JAVA HOME>在系统PATH中。为了成功运行命令。

Web Browser 网页浏览器

Ensure that your web browser is configured to send Windows credentials (essentially, a SPNEGO token containing a Kerberos service ticket) to the application server automatically. 确保将Web浏览器配置为自动将Windows凭据(实质上是包含Kerberos服务票证的SPNEGO令牌)发送到应用程序服务器。 To do this, follow the below instructions. 为此,请按照以下说明进行操作。

Internet Explorer: IE浏览器:

  1. Open the Internet Options dialog box by choosing Internet Options either from Control Panel or from the Tools menu in Internet Explorer. 通过从控制面板或Internet Explorer的“工具”菜单中选择“ Internet选项”,打开“ Internet选项”对话框。
  2. In the Internet Options dialog box, on the Security tab, select Local Intranet, and then click Custom Level. 在“ Internet选项”对话框的“安全性”选项卡上,选择“本地Intranet”,然后单击“自定义级别”。
  3. In the Security Settings dialog box, under Logon, select "Automatic logon only in Intranet zone", and then click OK. 在“安全设置”对话框的“登录”下,选择“仅在Intranet区域中自动登录”,然后单击“确定”。
  4. In the Internet Options dialog box on the Security Settings tab with Local Intranet still selected, click Sites. 在“安全设置”选项卡上的“ Internet选项”对话框中,仍然选择“本地Intranet”,单击“站点”。
  5. In the Local intranet dialog box, click Advanced. 在“本地Intranet”对话框中,单击“高级”。
  6. In the next dialog box (also titled Local intranet), type the URL of your web site (for example, http://test.abc.mycompany.com ) in the "Add this Web site to the zone" box, and then click Add. 在下一个对话框(也称为“本地Intranet”)中,在“将此网站添加到区域中”框中键入网站的URL(例如, http://test.abc.mycompany.com ),然后单击添加。
  7. In the Local Intranet dialog, box click OK. 在“本地Intranet”对话框中,单击“确定”。
  8. In the original Local Intranet dialog box, click OK. 在原始的本地Intranet对话框中,单击“确定”。
  9. Under the Advanced tab, ensure that "Enable Integrated Windows Authentication" is enabled (this is the default). 在“高级”选项卡下,确保已启用“启用集成Windows身份验证”(这是默认设置)。
  10. In the Internet Options dialog box, click OK. 在“ Internet选项”对话框中,单击“确定”。

Reference: Configuring Internet Explorer for Automatic Logon 参考: 配置Internet Explorer进行自动登录

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM