標簽:configure author class role config 優先 代碼 dmi ted
权限優先级:
在SecurityConfig中configure(HttpSecurity http)方法中,如下代碼
http.authorizeRequests()
.antMatchers("/admin/**").hasRole("admin")
.antMatchers("/**").permitAll()
.anyRequest().authenticated()
;
由于admin的权限写在 “/** ”之前,所以访问时对于“/admin/** ”路径下的资源是不可读的;
反之,寫成如下格式時,“/admin/**”下的路徑都可讀
http.authorizeRequests()
.antMatchers("/**").permitAll()
.antMatchers("/admin/**").hasRole("admin")
.anyRequest().authenticated()
;
標簽:configure author class role config 優先 代碼 dmi ted
原文地址:https://www.cnblogs.com/alike-zhu/p/14942171.html