Class Saml2LoginConfigurer
Sign-in through a SAML 2.0 identity provider: Okta, Microsoft Entra ID, ADFS, Ping, Google Workspace, Keycloak, Shibboleth.
http.authorizeHttpRequests(auth -> auth.anyRequest().authenticated())
.saml2Login(Customizer.withDefaults());
with, in application.properties,
cn1.security.saml2.relyingparty.registration.okta.assertingparty.metadata-uri=https://...
The identity providers are the application's
RelyingPartyRegistrationRepository bean or the registrations the
configuration declares; see RelyingPartyRegistrations.
A sign-in starts at GET /saml2/authenticate/{registrationId}, which sends
the browser to the identity provider with an AuthnRequest, and ends at
POST /login/saml2/sso/{registrationId}, where the identity provider posts
its response. This server's metadata, for the identity provider's
administrator, is at GET /saml2/service-provider-metadata/{registrationId}.
How a response is judged is Saml2ResponseValidator's; who the user is
here is the authenticationConverter(Saml2AuthenticationConverter)'s, which by default gives every
signed-in user ROLE_USER.
An assertion encrypted to a registration's decryption credential is
decrypted; see RelyingPartyRegistration.Builder.decryptionCredential(byte[], Certificate).
Signing out ends the session here only, unless http.saml2Logout(...)
is declared as well; see Saml2LogoutConfigurer.
The cookie that holds a pending request is signed with
cn1.security.saml2.cookie-secret (at least 32 characters); unset, a key
is made per process, and a response that reaches another server than the
one that sent the request is then taken as unsolicited -- set it when
several servers share the work.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionWho a signed-in user is here; seeSaml2AuthenticationConverter.authenticationRequestBaseUri(String baseUri) The path a sign-in starts at, before the registration's id.voidconfigure(HttpSecurity http) Adds this part's filters; nothing by default.defaultSuccessUrl(String defaultSuccessUrl) defaultSuccessUrl(String defaultSuccessUrl, boolean alwaysUse) failureHandler(AuthenticationFailureHandler failureHandler) What answers a refused sign-in.failureUrl(String failureUrl) Where a refused sign-in goes; the login page with?errorunless set.voidinit(HttpSecurity http) Shares what other parts need to know; nothing by default.The application's own login page, with a link to/saml2/authenticate/{registrationId}for each identity provider.loginProcessingBaseUri(String baseUri) The path responses are posted to, before the registration's id.metadataBaseUri(String baseUri) The path this server's metadata is served at, before the registration's id.Lets everyone reach the login page and the failure page.The identity providers, in place of the application's bean and the configuration.successHandler(AuthenticationSuccessHandler successHandler) Methods inherited from class SecurityConfigurer
disable, getBuilder
-
Field Details
-
SECRET
The setting that holds the key of the pending-request cookie.- See Also:
-
-
Method Details
-
relyingPartyRegistrationRepository
public Saml2LoginConfigurer relyingPartyRegistrationRepository(RelyingPartyRegistrationRepository repository) The identity providers, in place of the application's bean and the configuration. -
authenticationConverter
Who a signed-in user is here; seeSaml2AuthenticationConverter. -
loginPage
The application's own login page, with a link to/saml2/authenticate/{registrationId}for each identity provider. -
authenticationRequestBaseUri
The path a sign-in starts at, before the registration's id. -
loginProcessingBaseUri
The path responses are posted to, before the registration's id. The registrations'acs.locationmust agree with it. -
metadataBaseUri
The path this server's metadata is served at, before the registration's id. -
defaultSuccessUrl
-
defaultSuccessUrl
- Parameters:
alwaysUse- go there even when a page asked for the sign-in
-
successHandler
-
failureUrl
Where a refused sign-in goes; the login page with?errorunless set. -
failureHandler
What answers a refused sign-in. The exception is aSaml2AuthenticationExceptionwhose error code says why. -
permitAll
Lets everyone reach the login page and the failure page. -
init
Description copied from class:SecurityConfigurerShares what other parts need to know; nothing by default.- Overrides:
initin classSecurityConfigurer
-
configure
Description copied from class:SecurityConfigurerAdds this part's filters; nothing by default.- Overrides:
configurein classSecurityConfigurer
-