Skip to content

Create single point of defining the default role prefix #3701

@andrei-ivanov

Description

@andrei-ivanov

If one wants to change the default role prefix this must be done in more than one place and this can lead to errors if one of them is forgotten.
Currently I set it in 4 places:

<bean id="defaultMethodSecurityExpressionHandler" class="org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler">
    <property name="defaultRolePrefix" value="ROLE:" />
</bean>

<bean id="defaultWebSecurityExpressionHandler" class="org.springframework.security.web.access.expression.DefaultWebSecurityExpressionHandler">
    <property name="defaultRolePrefix" value="ROLE:" />
</bean>

<bean id="securityContextHolderAwareRequestFilter" class="org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter">
    <property name="rolePrefix" value="ROLE:" />
</bean>

<bean id="daoUserDetailsService" class="custom.DaoUserDetailsServiceImpl">
    <property name="rolePrefix" value="ROLE:" />
</bean>

Some strategy should be created to set the default role in a single place and the other components should use it.

Metadata

Metadata

Assignees

Labels

in: configAn issue in spring-security-configtype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions