jjzjj

java - Spring Security + MVC : same @RequestMapping, 不同@Secured

假设我们有一个使用SpringMVC和SpringSecurity配置的API端点。我们希望能够处理一对@RequestMapping和@Secured注释,其中唯一的@Secured注释值因对而不同。这样,我们就可以根据相同请求的安全规则返回不同的响应正文。通过避免将安全规则直接检查到方法主体中,这可能使我们的代码更易于维护。有一个不工作的例子,这是我们想做的:@Controller@RequestMapping("/api")publicclassController{@Secured({"ROLE_A"})@RequestMapping(value="{uid}",method=

spring - @RolesAllowed 与 @PreAuthorize 与 @Secured

我有一个基本的SpringBoot应用程序。使用SpringInitializer、嵌入式Tomcat、Thymeleaf模板引擎,并打包为可执行JAR文件。我想保护Controller:@Controller@RequestMapping("/company")@RolesAllowed({"ROLE_ADMIN"})@PreAuthorize("hasRole('ADMIN')")@Secured("ADMIN")publicclassCompanyController{}我知道有不同的选择,但我真的不知道我应该使用哪个 最佳答案

spring - @RolesAllowed 与 @PreAuthorize 与 @Secured

我有一个基本的SpringBoot应用程序。使用SpringInitializer、嵌入式Tomcat、Thymeleaf模板引擎,并打包为可执行JAR文件。我想保护Controller:@Controller@RequestMapping("/company")@RolesAllowed({"ROLE_ADMIN"})@PreAuthorize("hasRole('ADMIN')")@Secured("ADMIN")publicclassCompanyController{}我知道有不同的选择,但我真的不知道我应该使用哪个 最佳答案

spring - 如何在我的 Controller 中验证(@Valid)之前检查安全访问(@Secured 或 @PreAuthorize)?

这是我的Controller代码:@PreAuthorize("hasRole('CREATE_USER')")@RequestMapping(method=RequestMethod.POST,produces=MediaType.APPLICATION_JSON_VALUE,consumes=MediaType.APPLICATION_JSON_VALUE)@ResponseBodypublicUserReturnROcreateUser(@Valid@RequestBodyUserROuserRO)throwsBadParameterException{returnuserSer

spring - 如何在我的 Controller 中验证(@Valid)之前检查安全访问(@Secured 或 @PreAuthorize)?

这是我的Controller代码:@PreAuthorize("hasRole('CREATE_USER')")@RequestMapping(method=RequestMethod.POST,produces=MediaType.APPLICATION_JSON_VALUE,consumes=MediaType.APPLICATION_JSON_VALUE)@ResponseBodypublicUserReturnROcreateUser(@Valid@RequestBodyUserROuserRO)throwsBadParameterException{returnuserSer

spring - @Secured 在 Controller 中不起作用,但拦截 URL 似乎工作正常

看起来我的@Controller中的@Securedon方法没有被读取。当使用基于sec:intercept-url的安全过滤时,这似乎工作得很好。以下代码导致SpringSecurity给我这个日志条目:DEBUG:org.springframework.security.web.access.intercept.FilterSecurityInterceptor-Publicobject-authenticationnotattemptedweb.xml上下文配置位置/WEB-INF/spring/root-context.xmlorg.springframework.web.co

spring - @Secured 在 Controller 中不起作用,但拦截 URL 似乎工作正常

看起来我的@Controller中的@Securedon方法没有被读取。当使用基于sec:intercept-url的安全过滤时,这似乎工作得很好。以下代码导致SpringSecurity给我这个日志条目:DEBUG:org.springframework.security.web.access.intercept.FilterSecurityInterceptor-Publicobject-authenticationnotattemptedweb.xml上下文配置位置/WEB-INF/spring/root-context.xmlorg.springframework.web.co

java - Spring Security,方法安全注释(@Secured)不起作用(java config)

我正在尝试使用@Secured("ADMIN")设置方法安全注释(没有任何XML,只有java配置,SpringBoot)。但是通过角色访问不起作用。安全配置:@Configuration@EnableWebSecuritypublicclassAppSecurityConfigurationextendsWebSecurityConfigurerAdapter{.....@Overrideprotectedvoidconfigure(HttpSecurityhttp)throwsException{http.authorizeRequests().antMatchers("/api/

java - Spring Security,方法安全注释(@Secured)不起作用(java config)

我正在尝试使用@Secured("ADMIN")设置方法安全注释(没有任何XML,只有java配置,SpringBoot)。但是通过角色访问不起作用。安全配置:@Configuration@EnableWebSecuritypublicclassAppSecurityConfigurationextendsWebSecurityConfigurerAdapter{.....@Overrideprotectedvoidconfigure(HttpSecurityhttp)throwsException{http.authorizeRequests().antMatchers("/api/

php - Symfony2 : how to check if an action is secured?

我想从Controller内部检查它是否是安全页面。如何做到这一点?我的用例如下:用户可以注册并登录如果他登录并尝试访问安全页面,他将被重定向到“测试版”页面,直到6月底。如果他尝试访问普通页面(不安全),他将能够在没有任何重定向的情况下访问该页面。感谢您的帮助!奥雷尔 最佳答案 当Symfony2处理请求时,它会将url模式与app/config/security.yml中定义的每个防火墙进行匹配。当url模式与防火墙模式匹配时,Symfony2创建一些监听器对象并调用这些对象的handle方法。如果任何监听器返回一个Respon