forked from spring-projects/spring-security-kerberos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add better support for KerberosRestTemplate
- Better configuration model - Updates to ref docs - New boot based client sample
- Loading branch information
Showing
12 changed files
with
432 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -145,7 +145,7 @@ services. | |
---- | ||
|
||
Now you can use `kadmin` with previously created `root/admin` | ||
principal. Lets create our first user. | ||
principal. Lets create our first user `user1`. | ||
|
||
[source,text,indent=0] | ||
---- | ||
|
@@ -157,15 +157,22 @@ Re-enter password for principal "[email protected]": | |
Principal "[email protected]" created. | ||
---- | ||
|
||
If you like you can create a keytab file for this user. | ||
Lets create our second user `user2` and export a keytab file. | ||
|
||
[source,text,indent=0] | ||
---- | ||
kadmin: ktadd -k /tmp/user1.keytab [email protected] | ||
Entry for principal [email protected] with kvno 2, encryption type aes256-cts-hmac-sha1-96 added to keytab WRFILE:/tmp/user1.keytab. | ||
Entry for principal [email protected] with kvno 2, encryption type arcfour-hmac added to keytab WRFILE:/tmp/user1.keytab. | ||
Entry for principal [email protected] with kvno 2, encryption type des3-cbc-sha1 added to keytab WRFILE:/tmp/user1.keytab. | ||
Entry for principal [email protected] with kvno 2, encryption type des-cbc-crc added to keytab WRFILE:/tmp/user1.keytab. | ||
kadmin: addprinc user2 | ||
WARNING: no policy specified for [email protected]; defaulting to no | ||
policy | ||
Enter password for principal "[email protected]": | ||
Re-enter password for principal "[email protected]": | ||
Principal "[email protected]" created. | ||
kadmin: ktadd -k /tmp/user2.keytab [email protected] | ||
Entry for principal [email protected] with kvno 2, encryption type aes256-cts-hmac-sha1-96 added to keytab WRFILE:/tmp/user2.keytab. | ||
Entry for principal [email protected] with kvno 2, encryption type arcfour-hmac added to keytab WRFILE:/tmp/user2.keytab. | ||
Entry for principal [email protected] with kvno 2, encryption type des3-cbc-sha1 added to keytab WRFILE:/tmp/user2.keytab. | ||
Entry for principal [email protected] with kvno 2, encryption type des-cbc-crc added to keytab WRFILE:/tmp/user2.keytab. | ||
---- | ||
|
||
Lets create a service ticket for tomcat and export credentials to a | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,8 @@ with spnego and form | |
<<samples-sec-server-spnego-form-auth-xml>> sample using ticket | ||
validation with spnego and form (xml config) | ||
|
||
<<samples-sec-client-rest-template>> sample for KerberosRestTemplate | ||
|
||
[[samples-sec-server-win-auth]] | ||
== Security Server Windows Auth Sample | ||
Goals of this sample: | ||
|
@@ -102,7 +104,7 @@ Spnego based negotiation from a browser while still being able to fall | |
back to a form based authentication. | ||
|
||
Using a `user1` principal <<setupmitkerberos>>, do a kerberos login | ||
either using credentials. | ||
manually using credentials. | ||
[source,text] | ||
---- | ||
$ kinit user1 | ||
|
@@ -121,11 +123,11 @@ or using a keytab file. | |
|
||
[source,text] | ||
---- | ||
$ kinit -kt user1.keytab user1 | ||
$ kinit -kt user2.keytab user1 | ||
$ klist | ||
Ticket cache: FILE:/tmp/krb5cc_1000 | ||
Default principal: user1@EXAMPLE.ORG | ||
Default principal: user2@EXAMPLE.ORG | ||
Valid starting Expires Service principal | ||
10/03/15 17:25:03 11/03/15 03:25:03 krbtgt/[email protected] | ||
|
@@ -167,3 +169,66 @@ Run a server. | |
$ java -jar sec-server-spnego-form-auth-xml-{revnumber}.jar | ||
---- | ||
|
||
[[samples-sec-client-rest-template]] | ||
== Security Client KerberosRestTemplate Sample | ||
This is a sample using a Spring RestTemplate to access Kerberos | ||
protected resource. You can use this together with | ||
<<samples-sec-server-spnego-form-auth>>. | ||
|
||
Default application is configured as shown below. | ||
[source,yaml,indent=0] | ||
---- | ||
app: | ||
user-principal: [email protected] | ||
keytab-location: /tmp/user2.keytab | ||
access-url: https://neo.example.org:8080/hello | ||
---- | ||
|
||
|
||
Using a `user1` principal <<setupmitkerberos>>, do a kerberos login | ||
manually using credentials. | ||
[source,text,subs="attributes"] | ||
---- | ||
$ java -jar sec-client-rest-template-{revnumber}.jar --app.user-principal --app.keytab-location | ||
---- | ||
|
||
[NOTE] | ||
==== | ||
In above we simply set `app.user-principal` and `app.keytab-location` | ||
to empty values which disables a use of keytab file. | ||
==== | ||
|
||
If operation is succesfull you should see below output with `[email protected]`. | ||
[source,text] | ||
---- | ||
<html xmlns="https://www.w3.org/1999/xhtml" | ||
xmlns:sec="https://www.thymeleaf.org/thymeleaf-extras-springsecurity3"> | ||
<head> | ||
<title>Spring Security Kerberos Example</title> | ||
</head> | ||
<body> | ||
<h1>Hello [email protected]!</h1> | ||
</body> | ||
</html> | ||
---- | ||
|
||
Or use a `user2` with a keytab file. | ||
[source,text,subs="attributes"] | ||
---- | ||
$ java -jar sec-client-rest-template-{revnumber}.jar | ||
---- | ||
|
||
If operation is succesfull you should see below output with `[email protected]`. | ||
[source,text] | ||
---- | ||
<html xmlns="https://www.w3.org/1999/xhtml" | ||
xmlns:sec="https://www.thymeleaf.org/thymeleaf-extras-springsecurity3"> | ||
<head> | ||
<title>Spring Security Kerberos Example</title> | ||
</head> | ||
<body> | ||
<h1>Hello [email protected]!</h1> | ||
</body> | ||
</html> | ||
---- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.