This guide shows how to integrate a Spring Boot application with Monosign using SAML 2.0. Monosign acts as the Identity Provider (IdP), and the Spring Boot sample acts as the Service Provider (SP) with Spring Security. The user signs in through Monosign and returns to the application, where the verified SAML NameID and attributes are displayed.
The sign-in flow was verified with the Spring Boot sample (Spring Boot 4.0.6, Spring Security 7, Java 17) at http://localhost:8080. For your deployment, use a browser-accessible HTTPS origin throughout the configuration. The reference screenshots illustrate the Monosign navigation, and application names and tenant values may vary.
Download the Spring Boot sample application
Download springboot-saml-monosign.zip
The ZIP includes the ready-to-run Spring Boot SAML sample, the README, and the idp.crt.example template. Extract it and follow step 5 to run the app.
Prerequisites
Java 17 or later, a browser-accessible address for the application (HTTPS for production), and access to the Monosign Management Portal. Maven is not required because the sample includes the Maven wrapper (mvnw).
Instructions
Creating an Application on Monosign
Creating the SAML Key on Monosign
Configuring the SAML Settings on Monosign
Assigning a User to the Spring Boot Application
Configuring Single Sign-On for Spring Boot
Sign-In Test
1- Creating an Application on Monosign
Open Applications from the left menu and select Add New.
Select Create from scratch.
Enter the application details and select Next.
Property | Value | Description |
|---|---|---|
Name | Spring Boot | The display name shown in Monosign. |
Type | Web | The sample runs in the browser. |
Url |
| The application home page. Replace the example hostname with your HTTPS origin. |
Logo | Optional | Upload an application logo if desired. |
On the Access tab, restrict access to assigned users and select Create Application.
2- Creating the SAML Key on Monosign
Open the application, select Keys, and choose Add New Access Key.
Select SAML as the key type and create the key.
The key details show the IdP Entity Id, Sign On Service, metadata URL, and certificate download. You will use these in step 5.
3- Configuring the SAML Settings on Monosign
On the SAML key, select Configure, open SAML Settings → Configuration, enter the values below, and select Update.
Property | Spring Boot example | Description |
|---|---|---|
Assertion Consumer Url |
| The application receives the SAML Response here via HTTP POST. The last part is the registration id |
Audience |
| The SP Entity ID of the application. It is the Spring Security default for the registration id |
ACS Validation Mode | Enforce | Rejects AuthnRequests that specify an unregistered ACS URL. |
NameId Format | System Default (unspecified) | Default value. |
Name Id | Spring Security shows this value as the name of the signed-in user. Choose a populated field for your assigned users. |
For a localhost test, use http://localhost:8080/login/saml2/sso/monosign and http://localhost:8080/saml2/service-provider-metadata/monosign.
Open the Attribute Mapping tab, add the attributes below, and select Update. The sample lists all received attributes on its protected page.
Attribute | Value | Description |
|---|---|---|
uid |
| Unique name of the user. |
displayName |
| Display name of the user. |
| E-mail address of the user. |
Attribute names are case sensitive. Your application reads them with the same names, for example principal.getFirstAttribute("email").
4- Assigning a User to the Spring Boot Application
Open Assignments and select Assign a User.
Search for the test user, check the assignment expiration date, then save. If Name ID is set to Email, confirm that the user has an email address.
5- Configuring Single Sign-On for Spring Boot
Download springboot-saml-monosign.zip, extract it, and open the project folder. Download the public signing certificate from the SAML key details and save it as src/main/resources/idp.crt. Then set these values in src/main/resources/application.properties.
Property | Value | Source |
|---|---|---|
assertingparty.entity-id | Entity Id | Monosign SAML key details or IdP metadata. |
assertingparty.singlesignon.url | Sign On Service | Monosign SAML key details or IdP metadata. |
assertingparty.singlesignon.sign-request |
| The sign-in request of the sample is not signed. |
assertingparty.verification.credentials[0].certificate-location |
| The downloaded public certificate. It verifies the signature of the SAML Response. |
server.forward-headers-strategy |
| Only behind a reverse proxy or load balancer, so that the public HTTPS address is used. |
spring.security.saml2.relyingparty.registration.monosign.assertingparty.entity-id=https://<monosign-host>/saml/<key> spring.security.saml2.relyingparty.registration.monosign.assertingparty.singlesignon.url=https://<monosign-host>/saml/<key>/login spring.security.saml2.relyingparty.registration.monosign.assertingparty.singlesignon.sign-request=false spring.security.saml2.relyingparty.registration.monosign.assertingparty.verification.credentials[0].certificate-location=classpath:idp.crt
The sample already contains the SAML dependency and the security configuration. To add SAML to your own project, use these parts. The home page (/) is public and every other page needs a sign-in.
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security-saml2</artifactId> </dependency>
@Configuration
@EnableWebSecurity
public class SecurityConfig {
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http
.authorizeHttpRequests(authorize -> authorize
.requestMatchers("/").permitAll()
.anyRequest().authenticated())
.saml2Login(Customizer.withDefaults());
return http.build();
}
}
In Spring Boot 4 the settings in application.properties are read only when spring-boot-starter-security-saml2 is in the project. With only spring-security-saml2-service-provider the application fails to start with relyingPartyRegistrationRepository cannot be null. The sample pom.xml also adds the Shibboleth repository (https://build.shibboleth.net/maven/releases/) because some OpenSAML libraries may be served from there.
Start the application. Restart it after editing application.properties or idp.crt.
./mvnw spring-boot:run
6- Sign-In Test
Open the application home page in a private browser window and select the sign-in button.
Authenticate as the assigned user using a method available in your Monosign tenant. An existing Monosign session may skip this prompt.
After authentication, Monosign sends the SAML Response to the application. Confirm that the protected page opens and shows the NameID and the attributes of the test user.
Open a fresh private window to test again without reusing a Monosign session.
Troubleshooting
Symptom | Cause | Solution |
|---|---|---|
The application fails to start with |
| Add the starter as shown in step 5. |
The application fails to start because | The certificate file is missing. | Save the public certificate as |
Monosign rejects the ACS, or the application shows | The configured URL differs from the AuthnRequest, often behind a proxy. | Compare the scheme, host, port, and path with step 3. Behind a proxy, set |
The application reports a SAML validation failure, for example | The signing certificate, issuer, or Audience differs from the configuration, or the clocks differ. | Download the certificate of the key again and compare Entity Id and Audience with steps 3 and 5. Check that the server clocks agree. |
A user attribute is empty. | The attribute is not in the Attribute Mapping, or the name differs. | Add it in the Attribute Mapping and select Update (step 3). Use the same name in the application. |
A user cannot sign in. | The user is unassigned or the assignment expired. | Check the Monosign assignment in step 4. |













