【发布时间】:2022-01-26 15:22:38
【问题描述】:
我的应用程序中有两个 URL:
-
/sa/abc(角色应该可以访问 - ABC) -
/sa/practice(角色应该可以访问 - ADMIN)
为此我已配置:
http
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
.authorizeRequests()
.antMatchers("/sa/**").authenticated()
.antMatchers("/sa/abc/**").hasAnyAuthority("ABC")
.antMatchers("/sa/practices/**").hasAnyAuthority("ADMIN")
我希望角色为ABC 的用户无法访问/sa/practices/link1,但他可以。
我还想知道antMatchers 中未提及的链接会发生什么情况。我的猜测是,无论角色如何,都可以毫无问题地访问它们。
我说的对吗?
【问题讨论】:
标签: java spring spring-boot spring-security