对于最新的稳定版本,请使用 Spring Security Kerberos 2.1.0! |
对于最新的稳定版本,请使用 Spring Security Kerberos 2.1.0! |
参考文档的这一部分将介绍示例 项目。示例可以通过构建主来手动编译 从 github.com/spring-projects/spring-security-kerberos 分发。
如果按原样运行示例,则在正确配置之前,它将无法工作 已应用。有关具体示例,请参阅下面的注释。 |
使用服务器端身份验证器的安全服务器端身份验证示例示例
使用票证验证的 Security Server Spnego 和表单身份验证示例示例 使用 SPNEGO 和 Form
Security Server Spnego 和表单身份验证 Xml 示例示例使用票证 使用 SPNEGO 和 Form 进行验证(XML 配置)
安全客户端 KerberosRestTemplate KerberosRestTemplate 示例示例
如果按原样运行示例,则在正确配置之前,它将无法工作 已应用。有关具体示例,请参阅下面的注释。 |
Security Server Windows 身份验证示例
此示例的目标:
-
在Windows环境中,用户将能够登录到应用程序 使用已输入的 Windows Active Directory 凭据 在登录到 Windows 期间。不应该有任何要求 用户 ID/密码凭据。
-
在非 Windows 环境中,用户将看到一个屏幕 以提供 Active Directory 凭据。
server:
port: 8080
app:
ad-domain: EXAMPLE.ORG
ad-server: ldap://WIN-EKBO0EQ7TS7.example.org/
service-principal: HTTP/[email protected]
keytab-location: /tmp/tomcat.keytab
ldap-search-base: dc=example,dc=org
ldap-search-filter: "(| (userPrincipalName={0}) (sAMAccountName={0}))"
在上面,您可以看到此示例的默认配置。你
可以使用普通的 Spring Boot 技巧覆盖这些设置,例如
使用命令行选项或自定义文件。application.yml
运行服务器。
$ java -jar sec-server-win-auth-2.0.1.jar
您可能需要在 Linux 中使用自定义 kerberos 配置,无论是使用 还是 bean。 |
有关如何使用 Windows Kerberos 环境的更多说明,请参阅安装 Windows 域控制器。 |
使用域凭据登录并访问示例Windows 8.1
从非 Windows VM 访问示例应用程序并使用域 手动凭据。
您可能需要在 Linux 中使用自定义 kerberos 配置,无论是使用 还是 bean。 |
有关如何使用 Windows Kerberos 环境的更多说明,请参阅安装 Windows 域控制器。 |
安全服务器端身份验证示例
此示例演示服务器如何对用户进行身份验证 针对 Kerberos 环境,使用通过 表单登录。
运行服务器。
$ java -jar sec-server-client-auth-2.0.1.jar
server:
port: 8080
Security Server Spnego 和表单身份验证示例
此示例演示如何将服务器配置为接受 基于 Spnego 的浏览器协商,同时仍然能够下降 返回到基于表单的身份验证。
使用主体安装程序 MIT Kerberos,
使用凭据手动执行 Kerberos 登录。user1
$ kinit user1
Password for [email protected]:
$ klist
Ticket cache: FILE:/tmp/krb5cc_1000
Default principal: [email protected]
Valid starting Expires Service principal
10/03/15 17:18:45 11/03/15 03:18:45 krbtgt/[email protected]
renew until 11/03/15 17:18:40
或使用密钥表文件。
$ kinit -kt user2.keytab user1
$ klist
Ticket cache: FILE:/tmp/krb5cc_1000
Default principal: [email protected]
Valid starting Expires Service principal
10/03/15 17:25:03 11/03/15 03:25:03 krbtgt/[email protected]
renew until 11/03/15 17:25:03
运行服务器。
$ java -jar sec-server-spnego-form-auth-2.0.1.jar
现在你应该能够打开你的浏览器,让它做Spnego 使用现有票证进行身份验证。
请参阅为 Spnego 协商配置浏览器,以获取有关配置浏览器以使用 Spnego 的更多指示信息。 |
server:
port: 8080
app:
service-principal: HTTP/[email protected]
keytab-location: /tmp/tomcat.keytab
请参阅为 Spnego 协商配置浏览器,以获取有关配置浏览器以使用 Spnego 的更多指示信息。 |
Security Server Spnego 和表单身份验证 xml 示例
这与 Security Server Spnego 和 Form Auth 示例相同,但 使用基于 xml 的配置而不是 JavaConfig。
运行服务器。
$ java -jar sec-server-spnego-form-auth-xml-2.0.1.jar
安全客户端 KerberosRestTemplate 示例
这是一个使用 Spring RestTemplate 访问 Kerberos 的示例 受保护的资源。您可以将其与 Security Server Spnego 和 Form Auth Sample 一起使用。
默认应用程序配置如下图所示。
app:
user-principal: [email protected]
keytab-location: /tmp/user2.keytab
access-url: http://neo.example.org:8080/hello
使用主体安装程序 MIT Kerberos,
使用凭据手动执行 Kerberos 登录。user1
$ java -jar sec-client-rest-template-2.0.1.jar --app.user-principal --app.keytab-location
在上面,我们简单地将 and 设置为空值,从而禁用 keytab 文件。 |
如果操作成功,您应该看到下面的输出。[email protected]
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
<head>
<title>Spring Security Kerberos Example</title>
</head>
<body>
<h1>Hello [email protected]!</h1>
</body>
</html>
或者使用带有密钥表文件的 。user2
$ java -jar sec-client-rest-template-2.0.1.jar
如果操作成功,您应该看到下面的输出。[email protected]
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
<head>
<title>Spring Security Kerberos Example</title>
</head>
<body>
<h1>Hello [email protected]!</h1>
</body>
</html>
在上面,我们简单地将 and 设置为空值,从而禁用 keytab 文件。 |