|
46 | 46 | import static org.springframework.util.StringUtils.hasText;
|
47 | 47 |
|
48 | 48 | /**
|
| 49 | + * This {@code Filter} formulates a |
| 50 | + * <a href="https://docs.oasis-open.org/security/saml/v2.0/saml-core-2.0-os.pdf">SAML 2.0 AuthnRequest</a> (line 1968) |
| 51 | + * and redirects to a configured asserting party. |
| 52 | + * |
| 53 | + * <p> |
| 54 | + * It supports the |
| 55 | + * <a href="https://docs.oasis-open.org/security/saml/v2.0/saml-bindings-2.0-os.pdf">HTTP-Redirect</a> (line 520) |
| 56 | + * and |
| 57 | + * <a href="https://docs.oasis-open.org/security/saml/v2.0/saml-bindings-2.0-os.pdf">HTTP-POST</a> (line 753) |
| 58 | + * bindings. |
| 59 | + * |
| 60 | + * <p> |
| 61 | + * By default, this {@code Filter} responds to authentication requests |
| 62 | + * at the {@code URI} {@code /oauth2/authorization/{registrationId}}. |
| 63 | + * The {@code URI} template variable {@code {registrationId}} represents the |
| 64 | + * {@link RelyingPartyRegistration#getRegistrationId() registration identifier} of the relying party |
| 65 | + * that is used for initiating the authentication request. |
| 66 | + * |
49 | 67 | * @since 5.2
|
| 68 | + * @author Filip Hanik |
| 69 | + * @author Josh Cummings |
50 | 70 | */
|
51 | 71 | public class Saml2WebSsoAuthenticationRequestFilter extends OncePerRequestFilter {
|
52 | 72 |
|
53 | 73 | private final RelyingPartyRegistrationRepository relyingPartyRegistrationRepository;
|
54 | 74 | private RequestMatcher redirectMatcher = new AntPathRequestMatcher("/saml2/authenticate/{registrationId}");
|
55 | 75 | private Saml2AuthenticationRequestFactory authenticationRequestFactory = new OpenSamlAuthenticationRequestFactory();
|
56 | 76 |
|
| 77 | + /** |
| 78 | + * Construct a {@link Saml2WebSsoAuthenticationRequestFilter} with the provided parameters |
| 79 | + * |
| 80 | + * @param relyingPartyRegistrationRepository a repository for relying party configurations |
| 81 | + */ |
57 | 82 | public Saml2WebSsoAuthenticationRequestFilter(RelyingPartyRegistrationRepository relyingPartyRegistrationRepository) {
|
58 | 83 | Assert.notNull(relyingPartyRegistrationRepository, "relyingPartyRegistrationRepository cannot be null");
|
59 | 84 | this.relyingPartyRegistrationRepository = relyingPartyRegistrationRepository;
|
60 | 85 | }
|
61 | 86 |
|
| 87 | + /** |
| 88 | + * Use the given {@link Saml2AuthenticationRequestFactory} for formulating the SAML 2.0 AuthnRequest |
| 89 | + * |
| 90 | + * @param authenticationRequestFactory the {@link Saml2AuthenticationRequestFactory} to use |
| 91 | + */ |
62 | 92 | public void setAuthenticationRequestFactory(Saml2AuthenticationRequestFactory authenticationRequestFactory) {
|
63 | 93 | Assert.notNull(authenticationRequestFactory, "authenticationRequestFactory cannot be null");
|
64 | 94 | this.authenticationRequestFactory = authenticationRequestFactory;
|
65 | 95 | }
|
66 | 96 |
|
| 97 | + /** |
| 98 | + * Use the given {@link RequestMatcher} that activates this filter for a given request |
| 99 | + * |
| 100 | + * @param redirectMatcher the {@link RequestMatcher} to use |
| 101 | + */ |
67 | 102 | public void setRedirectMatcher(RequestMatcher redirectMatcher) {
|
68 | 103 | Assert.notNull(redirectMatcher, "redirectMatcher cannot be null");
|
69 | 104 | this.redirectMatcher = redirectMatcher;
|
70 | 105 | }
|
71 | 106 |
|
| 107 | + /** |
| 108 | + * {@inheritDoc} |
| 109 | + */ |
72 | 110 | @Override
|
73 | 111 | protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
|
74 | 112 | throws ServletException, IOException {
|
|
0 commit comments