小编For*_*e85的帖子

Spring Boot 3 安全 requestMatchers.permitAll 不起作用

下面是SecurityFilterChain根据新的 Spring Security 6 / Spring boot 3 文档创建的 bean。但是,requestMatchers -> AntPathRequestMatcher -> permitAll不起作用。每个请求都达到了OncePerRequestFilter。请告诉我这是预期的结果还是出现问题。

代码:

@Configuration
@EnableWebSecurity
@RequiredArgsConstructor
@EnableMethodSecurity
public class WebSecurityConfig {
   List<String> publicApis = List.of("/generate/**", "validated/**");
   
   @Bean
   public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
        http
                .cors()
                .configurationSource(corsConfigurationSource())
                .and()
                .csrf()
                .disable()
                .formLogin()
                .disable()
                .httpBasic()
                .disable()
                .exceptionHandling()
                .authenticationEntryPoint(restAuthenticationEntryPoint())
                .and()
                .authorizeHttpRequests(
                        r -> r.requestMatchers(
                                        publicApis().stream()
                                                .map(AntPathRequestMatcher::new)
                                                .toArray(RequestMatcher[]::new)
                                )
                                .permitAll()
                                .anyRequest()
                                .authenticated()
                )
                .sessionManagement(s -> s.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
                .addFilterBefore(tokenAuthenticationFilter, UsernamePasswordAuthenticationFilter.class);

        return http.build();
    }

    @Bean
    public WebSecurityCustomizer webSecurityCustomizer() { …
Run Code Online (Sandbox Code Playgroud)

java spring spring-security spring-boot

5
推荐指数
1
解决办法
2万
查看次数

KV 过滤器不包括空间值

Logstashkv过滤器不包含带空格的值。请检查下面 Logstash 生成的输入和输出消息。所需的输出应包含空格。

输入消息:

key1=first value key2=second value key3=value3
Run Code Online (Sandbox Code Playgroud)

期望的输出:

{
    "key1" => "first value",
    "key2" => "second value",
    "key3" => "value3",
    "message" => "key1=first value key2=second value key3=value3"
}
Run Code Online (Sandbox Code Playgroud)

获得的输出:

{
    "key1" => "first",
    "key2" => "second",
    "key3" => "value3",
    "message" => "key1=first value key2=second value key3=value3"
}
Run Code Online (Sandbox Code Playgroud)

我需要将值中的空格包含在字段中。如何在 Logstash 中执行此操作?

logstash

1
推荐指数
1
解决办法
2895
查看次数

标签 统计

java ×1

logstash ×1

spring ×1

spring-boot ×1

spring-security ×1