Help

Integration

Spring Boot SAML Integration with Monosign

Updated 23 Nov 2026 6 min read

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

  1. Creating an Application on Monosign

  2. Creating the SAML Key on Monosign

  3. Configuring the SAML Settings on Monosign

  4. Assigning a User to the Spring Boot Application

  5. Configuring Single Sign-On for Spring Boot

  6. Sign-In Test

1- Creating an Application on Monosign

Open Applications from the left menu and select Add New.

image-20261030-191725.png

Select Create from scratch.

image-20261030-191750.png

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

https://spring-boot-saml.example.com/

The application home page. Replace the example hostname with your HTTPS origin.

Logo

Optional

Upload an application logo if desired.

image-20261123-115906.png

On the Access tab, restrict access to assigned users and select Create Application.

image-20261030-192040.png

2- Creating the SAML Key on Monosign

Open the application, select Keys, and choose Add New Access Key.

image-20261030-192203.png

Select SAML as the key type and create the key.

image-20261031-102756.png

The key details show the IdP Entity Id, Sign On Service, metadata URL, and certificate download. You will use these in step 5.

image-20261123-130832.png

3- Configuring the SAML Settings on Monosign

On the SAML key, select Configure, open SAML Settings → Configuration, enter the values below, and select Update.

image-20261123-132331.png

Property

Spring Boot example

Description

Assertion Consumer Url

https://spring-boot-saml.example.com/login/saml2/sso/monosign

The application receives the SAML Response here via HTTP POST. The last part is the registration id monosign from step 5.

Audience

https://spring-boot-saml.example.com/saml2/service-provider-metadata/monosign

The SP Entity ID of the application. It is the Spring Security default for the registration id monosign.

ACS Validation Mode

Enforce

Rejects AuthnRequests that specify an unregistered ACS URL. Warn Only (default) works as well.

NameId Format

System Default (unspecified)

Default value.

Name Id

Email

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.

image-20261123-132703.png

Attribute

Value

Description

uid

{{UserName}}

Unique name of the user.

displayName

{{FormattedUserName}}

Display name of the user.

email

{{Email}}

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.

image-20261030-193315.png

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.

image-20261030-193652.png

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

false

The sign-in request of the sample is not signed.

assertingparty.verification.credentials[0].certificate-location

classpath:idp.crt

The downloaded public certificate. It verifies the signature of the SAML Response.

server.forward-headers-strategy

framework

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.

image-20261123-132217.png

Authenticate as the assigned user using a method available in your Monosign tenant. An existing Monosign session may skip this prompt.

image-20261123-132244.png

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.

image-20261123-132625.png

Open a fresh private window to test again without reusing a Monosign session.

Troubleshooting

Symptom

Cause

Solution

The application fails to start with relyingPartyRegistrationRepository cannot be null.

spring-boot-starter-security-saml2 is missing.

Add the starter as shown in step 5.

The application fails to start because idp.crt cannot be found.

The certificate file is missing.

Save the public certificate as src/main/resources/idp.crt (step 5).

Monosign rejects the ACS, or the application shows invalid_destination.

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 server.forward-headers-strategy=framework.

The application reports a SAML validation failure, for example invalid_signature.

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.

Permanent link