I am building a multi-tenant application which should enable each tenant to use its own IAM provider for the purpose of users authentication. So finally, for example, Tenant1 can use Keycloak, Tenant2 can use OneIdentity, Tenant3 any IAM provider of its choice... The application should enable registering a new tenant together with its IAM provider dynamically (at runtime). I register the OIDC clients having a ClientRegistrationRepository, like:
@Bean
public ClientRegistrationRepository clientRegistrationRepository() {
return new InMemoryClientRegistrationRepository(
ClientRegistrations.fromIssuerLocation("iam-provider-1-issuer-location")
.registrationId("registration-id")
.clientId("client-id")
.clientSecret("client-secret")
.build(),
ClientRegistrations.fromIssuerLocation("iam-provider-2-issuer-location")
.registrationId("registration-id")
.clientId("client-id")
.clientSecret("client-secret")
.build(),
);
}
But, the ClientRegistrationRepository doesn't provide a way to update the client registrations. Is there a way to introduce a new client registration at runtime which will be taken into consideration from Spring Security?