jmix-framework / jmix

Jmix framework
https://www.jmix.io
Apache License 2.0
487 stars 112 forks source link

Replace Jmix HTTP security configurers with a static helper class #3391

Closed gorbunkov closed 2 weeks ago

gorbunkov commented 2 weeks ago

Problem Description

The Jmix security add-on includes several classes known as configurers:

These classes extend the AbstractHttpConfigurer abstract class. However, they do not utilize any methods defined in the org.springframework.security.config.annotation.SecurityConfigurer interface.

Spring Security expects the following sequence when configuring HttpSecurity:

The current implementations of Jmix configurers (AnonymousConfigurer, AuthorizedApiUrlsConfigurer, etc.) do not follow this approach. Instead, they use a workaround by overriding the setBuilder() method.

Possible Improvement

We could replace invocations like:

http.with(new SessionManagementConfigurer(), Customizer.withDefaults());

with a static helper method invocation:

JmixHttpSecurityUtils.configureSessionManagement(http);

Using a static helper method invocation more clearly indicates how and when the code from the "configurer" will be applied.