Expected Behavior
There are many places where the stringliteral 'ROLE_' is used.
Why not define a public static final constant?
Like the following:
public static final String DEFAULT_ROLE_PREFIX = "ROLE_";
Then replace all the places where 'ROLE_' literals are used with 'DEFAULT_ROLE_PREFIX' constants.
Current Behavior
Context
I haven't thought about where to define this constant, maybe in the org.springframework.security.core.GrantedAuthority interface.
I would like to contribute code if I can, thanks.
Comment From: marcusdacoregio
Hi @sunchaser-lilu,
I don't see how this can bring value to the codebase. In my opinion, the constant would be useful if the default role prefix could change, which I don't think will ever change. With the string literal you know exactly what the value is without navigating to another class, this is especially useful when reviewing the code for the browser or a place with limited navigation support.
Comment From: llnancy
Hi @marcusdacoregio,
I strongly agree with you that this is especially useful when reviewing the code for the browser or a place with limited navigation support, It may not be necessary to replace this existing code. But there is no place in the application where the developer can get the ROLE_ constant, and the developer still needs to write the stringliteral ROLE_ in their own code when using the framework, rather than the constant provided by the framework, in my opinion. It would probably be more comfortable to write code if the framework provided this constant, maybe we have different programming habits, it doesn't matter, but thanks anyway, I agree with you.
Comment From: marcusdacoregio
Thanks for the input @sunchaser-lilu, we will keep an eye on this.
I'm closing this for now but anyone can feel free to contribute to this discussion, we can always reconsider.