jjzjj

antMatchers

全部标签

java - 如何重新启用对 Spring Boot Health 端点的匿名访问?

可能我在这里做错了什么,我只是想不通是什么......我在同一个应用程序中有一个Oauth2身份验证服务器和一个资源服务器。资源服务器配置:@Configuration@EnableResourceServer@EnableGlobalMethodSecurity(prePostEnabled=true)@Order(SecurityProperties.ACCESS_OVERRIDE_ORDER-1)publicclassResourceServerConfigextendsResourceServerConfigurerAdapter{publicstaticfinalString

使用 Vaadin 进行 Spring Security 的 Java 配置

我是这些框架的新手(Vaadin:7.6.1,SpringSecurity:4.0.3),如果我想构建Vaadin应用程序,我在问自己如何配置授权请求。我查了几个这样写的例子:@EnableWebSecuritypublicclassSecurityConfigextendsWebSecurityConfigurerAdapter{[...]@Overrideprotectedvoidconfigure(HttpSecurityhttp)throwsException{http.authorizeRequests().antMatchers("/login**").permitAll(

java - Spring Boot Actuator Endpoints 安全性不适用于自定义 Spring 安全配置

这是我的SpringBoot1.5.1Actuatorapplication.properties:#SpringBootActuatormanagement.contextPath:/actuatormanagement.security.roles=R_0这是我的WebSecurityConfig:@Configuration@EnableWebSecuritypublicclassWebSecurityConfigextendsWebSecurityConfigurerAdapter{@AutowiredprivateUserDetailsServiceuserDetailsSe

java - Spring Security 在休息服务中获取用户信息,用于经过身份验证和未经过身份验证的用户

我有一个springrest服务,我想将它用于经过身份验证和未经过身份验证的用户。如果用户通过身份验证,我想从SecurityContextHolder.getContext().getAuthentication()获取用户信息。如果我使用.antMatchers("/app/rest/question/useroperation/list/**").permitAll()在ouath2配置中,如下所示,然后我可以获得用户信息经过身份验证的用户,但未经过身份验证的用户出现401错误。如果我.antMatchers("/app/rest/question/useroperation/l

java - Spring Security 在休息服务中获取用户信息,用于经过身份验证和未经过身份验证的用户

我有一个springrest服务,我想将它用于经过身份验证和未经过身份验证的用户。如果用户通过身份验证,我想从SecurityContextHolder.getContext().getAuthentication()获取用户信息。如果我使用.antMatchers("/app/rest/question/useroperation/list/**").permitAll()在ouath2配置中,如下所示,然后我可以获得用户信息经过身份验证的用户,但未经过身份验证的用户出现401错误。如果我.antMatchers("/app/rest/question/useroperation/l

java - 默认情况下如何拒绝对所有 URL 的访问?

在定义新的springbootREST资源时,我往往会忘记为它们的url模式创建一个spring安全配置。如何在默认情况下拒绝访问所有URL,只允许访问明确配置的URL模式?(我使用.hasRole来允许访问)我想尽可能多地避免意外的安全漏洞。假设我有三个REST资源:/jobs、/desks和/salary。我当前的代码可能如下所示:http.authorizeRequests().antMatchers(HttpMethod.GET,"/jobs").hasRole("my_user").antMatchers(HttpMethod.GET,"/desks").hasRole("m

java - 默认情况下如何拒绝对所有 URL 的访问?

在定义新的springbootREST资源时,我往往会忘记为它们的url模式创建一个spring安全配置。如何在默认情况下拒绝访问所有URL,只允许访问明确配置的URL模式?(我使用.hasRole来允许访问)我想尽可能多地避免意外的安全漏洞。假设我有三个REST资源:/jobs、/desks和/salary。我当前的代码可能如下所示:http.authorizeRequests().antMatchers(HttpMethod.GET,"/jobs").hasRole("my_user").antMatchers(HttpMethod.GET,"/desks").hasRole("m

java - Spring 安全 : Java Config: How to add the method type?

我正在使用SpringSecuritysJavaConfig。想要翻译以下XML:使用Java配置:http.authorizeUrls().antMatchers("/login").permitAll();但是有一个问题:我仍然可以在浏览器中使用“/login”并执行GET请求。但我只希望url可以通过POST访问。问题:如何将这个>>method="POST" 最佳答案 如果您要查看antMatchers的文档方法,您将看到HttpMethod的枚举可以作为第一个参数传递。所以这样的事情应该可以工作:http.authoriz

java - Spring 安全 : Java Config: How to add the method type?

我正在使用SpringSecuritysJavaConfig。想要翻译以下XML:使用Java配置:http.authorizeUrls().antMatchers("/login").permitAll();但是有一个问题:我仍然可以在浏览器中使用“/login”并执行GET请求。但我只希望url可以通过POST访问。问题:如何将这个>>method="POST" 最佳答案 如果您要查看antMatchers的文档方法,您将看到HttpMethod的枚举可以作为第一个参数传递。所以这样的事情应该可以工作:http.authoriz

Spring Security 使用 HttpSecurity 授权对 url 和方法的请求

有没有办法使用org.springframework.security.config.annotation.web.builders.HttpSecurity授权对特定url的发布请求?我正在使用HttpSecurity作为:@Overrideprotectedvoidconfigure(HttpSecurityhttp)throwsException{http.addFilterAfter(newCsrfCookieGeneratorFilter(),CsrfFilter.class).exceptionHandling().authenticationEntryPoint(auth
12