Spring security added prefix “ROLE_” to all roles name?

前端 未结 5 1532
被撕碎了的回忆
被撕碎了的回忆 2020-12-01 12:00

I have this code in my Web Security Config:

 @Override
protected void configure(HttpSecurity http) throws Exception {
    http
            .authorizeRequests         


        
5条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-01 12:40

    _ROLE prefix is used by spring security, to identify that it is as a role. A role has a set of privileges a.k.a Authorities, these authorities define varies permissions for a role. ex:- EDIT_PROFILE, DELETE_PROFILE

    You can define both the roles and authorities, if you are defining a role then it must be prefixed with "ROLE_"

    In your case you are looking for a role, so by default spring security looks for a string that is prefixed with "ROLE_".

提交回复
热议问题