|
| 1 | += OpenSAML Support |
| 2 | + |
| 3 | +Spring Security provides an API for implementing SAML 2.0 features, and it also provides a default implementation using OpenSAML. |
| 4 | + |
| 5 | +Because Spring Security supports more than one version of OpenSAML at the same time, the components use the following naming convention: |
| 6 | + |
| 7 | +* Any component that is usable across all supported versions is named `OpenSamlXXX`. |
| 8 | +* Any component that targets OpenSAML 4.x is named `OpenSaml4XXX` |
| 9 | +* Any component that targets OpenSAML 5.x is named `OpenSaml5XXX` |
| 10 | +
|
| 11 | +`spring-security-config` selects between these implementations by default by discovering which version your application is currently using. |
| 12 | +For example, if you are using OpenSAML 4, Spring Security will use the `OpenSaml4XXX` components. |
| 13 | + |
| 14 | +== Selecting OpenSAML 4 |
| 15 | + |
| 16 | +Spring Security depends on OpenSAML 4 by default, so you need do nothing to begin using it other than importing the `spring-security-saml` dependency. |
| 17 | + |
| 18 | +== Selecting OpenSAML 5 |
| 19 | + |
| 20 | +To use OpenSAML, you should override the `opensaml` dependencies as follows: |
| 21 | + |
| 22 | +[tabs] |
| 23 | +====== |
| 24 | +Maven:: |
| 25 | ++ |
| 26 | +[source,maven,role="primary"] |
| 27 | +---- |
| 28 | +<dependencyManagement> |
| 29 | + <dependencies> |
| 30 | + <dependency> |
| 31 | + <groupId>org.opensaml</groupId> |
| 32 | + <artifactId>opensaml-core-api</artifactId> |
| 33 | + <version>5.1.2</version> |
| 34 | + </depedency> |
| 35 | + <dependency> |
| 36 | + <groupId>org.opensaml</groupId> |
| 37 | + <artifactId>opensaml-core-impl</artifactId> |
| 38 | + <version>5.1.2</version> |
| 39 | + </depedency> |
| 40 | + <dependency> |
| 41 | + <groupId>org.opensaml</groupId> |
| 42 | + <artifactId>opensaml-saml-api</artifactId> |
| 43 | + <version>5.1.2</version> |
| 44 | + </depedency> |
| 45 | + <dependency> |
| 46 | + <groupId>org.opensaml</groupId> |
| 47 | + <artifactId>opensaml-saml-imple</artifactId> |
| 48 | + <version>5.1.2</version> |
| 49 | + </depedency> |
| 50 | + </dependencies> |
| 51 | +</dependencyManagement> |
| 52 | +
|
| 53 | +// ... |
| 54 | +
|
| 55 | +<dependencies> |
| 56 | + <dependency> |
| 57 | + <groupId>org.springframework.security</groupId> |
| 58 | + <artifactId>spring-security-saml2-service-provider</artifactId> |
| 59 | + <exclusions> |
| 60 | + <exclusion> |
| 61 | + <groupId>org.opensaml</groupId> |
| 62 | + <artifactId>opensaml-core</artifactId> |
| 63 | + </exclusion> |
| 64 | + </exclusions> |
| 65 | + </dependency> |
| 66 | +</dependencies> |
| 67 | +---- |
| 68 | +
|
| 69 | +Gradle:: |
| 70 | ++ |
| 71 | +[source,gradle,role="secondary"] |
| 72 | +---- |
| 73 | +dependencies { |
| 74 | + constraints { |
| 75 | + implementation "org.opensaml:opensaml-core-api:5.1.2" |
| 76 | + implementation "org.opensaml:opensaml-core-impl:5.1.2" |
| 77 | + implementation "org.opensaml:opensaml-saml-api:5.1.2" |
| 78 | + implementation "org.opensaml:opensaml-saml-impl:5.1.2" |
| 79 | + } |
| 80 | +
|
| 81 | + // ... |
| 82 | +
|
| 83 | + implementation ('org.springframework.security:spring-security-saml2-service-provider') { |
| 84 | + exclude group: "org.opensaml", module: "opensaml-core" |
| 85 | + } |
| 86 | +
|
| 87 | + // ... |
| 88 | +} |
| 89 | +---- |
| 90 | +====== |
| 91 | + |
| 92 | +[NOTE] |
| 93 | +The exclusion is necessary because OpenSAML 5 splits `opensaml-core` into `opensaml-core-api` and `opensaml-core-impl` |
0 commit comments