Skip to content

Spring Boot starter library for multi-tenant OAuth2 resource servers (Spring Boot 3, Spring Security 6)

License

Notifications You must be signed in to change notification settings

quantics-io/multitenant-oauth2-spring-boot-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

84 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Boot starter library for multi-tenant OAuth2 resource servers

This is a starter library for multi-tenant OAuth2 resource servers implemented with Spring. The code in this project is based on the samples from the official Spring Security documentation.

Installation

Add the dependency to your pom.xml file:

<dependency>
    <groupId>io.quantics</groupId>
    <artifactId>multitenant-oauth2-spring-boot-starter</artifactId>
    <version>0.4.0</version>
</dependency>

Usage

The auto-configuration for a multi-tenant OAuth2 resource server can be activated by adding the property spring.security.oauth2.resourceserver.multitenant.enabled=true to your application properties.

Configuration

All configuration properties start with the prefix spring.security.oauth2.resourceserver.multitenant.*

Key Allowed values Default value
enabled
  • true
  • false
false
resolve-mode
  • jwt
  • header
jwt
jwt.authorities-converter Any class extending AbstractJwtGrantedAuthoritiesConverter none
header.header-name Any string X-TENANT-ID

Resolving the tenant

By JWT

Setting the resolve mode to JWT will resolve the tenant by the OAuth2 iss claim found in the JWT.

By request header

Alternatively, the tenant can be resolved by a custom HTTP header by setting the resolve mode to header.

Note: Resolving the tenant by an HTTP header is not suggested for production-grade applications, but rather for quick validation that things are working as expected.

About

Spring Boot starter library for multi-tenant OAuth2 resource servers (Spring Boot 3, Spring Security 6)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages