ssk.adoc 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. [[springsecuritykerberos]]
  2. = Spring and Spring Security Kerberos
  3. :figures: servlet/authentication/kerberos
  4. This part of the reference documentation explains the core functionality
  5. that Spring Security Kerberos provides to any Spring based application.
  6. <<ssk-authprovider>> describes the authentication provider support.
  7. <<ssk-spnego>> describes the spnego negotiate support.
  8. <<ssk-resttemplate>> describes the RestTemplate support.
  9. [[ssk-authprovider]]
  10. == Authentication Provider
  11. Provider configuration using JavaConfig.
  12. [source,java,indent=0]
  13. ----
  14. include::example$kerberos/AuthProviderConfig.java[tags=snippetA]
  15. ----
  16. [[ssk-spnego]]
  17. == Spnego Negotiate
  18. Spnego configuration using JavaConfig.
  19. [source,java,indent=0]
  20. ----
  21. include::example$kerberos/SpnegoConfig.java[tags=snippetA]
  22. ----
  23. [[ssk-resttemplate]]
  24. == Using KerberosRestTemplate
  25. If there is a need to access Kerberos protected web resources
  26. programmatically we have `KerberosRestTemplate` which extends
  27. `RestTemplate` and does necessary login actions prior to delegating to
  28. actual RestTemplate methods. You basically have few options to
  29. configure this template.
  30. - Leave keyTabLocation and userPrincipal empty if you want to
  31. use cached ticket.
  32. - Use keyTabLocation and userPrincipal if you want to use
  33. keytab file.
  34. - Use loginOptions if you want to customise Krb5LoginModule options.
  35. - Use a customised httpClient.
  36. With ticket cache.
  37. [source,java,indent=0]
  38. ----
  39. include::example$kerberos/KerberosRestTemplateConfig.java[tags=snippetA]
  40. ----
  41. With keytab file.
  42. [source,java,indent=0]
  43. ----
  44. include::example$kerberos/KerberosRestTemplateConfig.java[tags=snippetB]
  45. ----
  46. [[ssk-kerberosldap]]
  47. == Authentication with LDAP Services
  48. With most of your samples we're using `DummyUserDetailsService`
  49. because there is not necessarily need to query a real user details
  50. once kerberos authentication is successful and we can use kerberos
  51. principal info to create that dummy user. However there is a way to
  52. access kerberized LDAP services in a say way and query user details
  53. from there.
  54. `KerberosLdapContextSource` can be used to bind into LDAP via kerberos
  55. which is at least proven to work well with Windows AD services.
  56. [source,java,indent=0]
  57. ----
  58. include::example$kerberos/KerberosLdapContextSourceConfig.java[tags=snippetA]
  59. ----
  60. [TIP]
  61. ====
  62. Sample xref:servlet/authentication/kerberos/samples.adoc#samples-sec-server-win-auth[Security Server Windows Auth Sample]
  63. is currently configured to query user details from AD if authentication happen via kerberos.
  64. ====