Skip to content

Reloading Saml2RelyingPartyRegistrations with help of Saml2RelyingPartyRegistrationConfiguration #23918

@dawi

Description

@dawi

The spring-security-saml extension provides a HTTPMetadataProvider which is able to automatically refresh SAML metadata in configurable intervals. It would be nice if this feature would also be supported by spring security, but I'm afraid that this feature is out of scope of this library (spring-projects/spring-security#9134).

This is ok, because this feature can be realized fairly simple by implementing a custom RelyingPartyRegistrationRepository.

However the user has to write a lot of code that is already part of Spring Boot and Spring Security internally (e.g. reading certificates, thinking about configuration properties, ...).

It would be nice if a user could just use the existing Spring Boot SAML configuration like this (example on github):

public ReloadingRelyingPartyRegistrationRepository(Saml2RelyingPartyProperties properties) {
    this.properties = properties;
    refreshRelyingPartyRegistrations();
}

@Scheduled(fixedDelayString = "${metadata-refresh-interval}", initialDelay = 10_000)
private void refreshRelyingPartyRegistrations() {

    LOGGER.debug("refreshRelyingPartyRegistrations");

    properties.getRegistration().forEach((registrationId, registrationProperties) -> {

        try {
            registrations.put(registrationId, asRegistration(registrationId, registrationProperties));
        }
        catch (Exception e) {
            LOGGER.warn("Could not refresh RelyingPartyRegistration configuration.", e);
        }
    });
}

My question is, would you consider making the private asRegistration(...) method from Saml2RelyingPartyRegistrationConfiguration in some form accessible to users, so that they don't have to repeat that code? Maybe not in Saml2RelyingPartyRegistrationConfiguration but in a separate utility class?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions