<commit_before>package com.github.mkopylec.webbackend.security;

import com.github.mkopylec.webbackend.security.authorization.TokenAuthorizationFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.access.intercept.FilterSecurityInterceptor;

import java.util.List;

import static org.apache.commons.collections4.CollectionUtils.isNotEmpty;
import static org.springframework.security.config.http.SessionCreationPolicy.STATELESS;

@Configuration
@EnableWebSecurity
@EnableConfigurationProperties(SecurityProperties.class)
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {

    @Autowired
    private SecurityProperties security;

    @Override
    public void configure(WebSecurity web) throws Exception {
        List<String> ignoredAntPaths = security.getIgnoredAntPaths();
        web.ignoring().antMatchers(ignoredAntPaths.toArray(new String[ignoredAntPaths.size()]));
    }

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        List<String> securedPaths = security.getIgnoredAntPaths();
        if (isNotEmpty(securedPaths)) {
            TokenAuthorizationFilter authenticationFilter = new TokenAuthorizationFilter(security);
            http
                    .csrf().disable()
                    .sessionManagement().sessionCreationPolicy(STATELESS)
                    .and()
                    .addFilterBefore(authenticationFilter, FilterSecurityInterceptor.class);
        }
    }
}<commit_msg>Non conditional security config<commit_after>package com.github.mkopylec.webbackend.security;

import com.github.mkopylec.webbackend.security.authorization.TokenAuthorizationFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.access.intercept.FilterSecurityInterceptor;

import java.util.List;

import static org.springframework.security.config.http.SessionCreationPolicy.STATELESS;

@Configuration
@EnableWebSecurity
@EnableConfigurationProperties(SecurityProperties.class)
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {

    @Autowired
    private SecurityProperties security;

    @Override
    public void configure(WebSecurity web) throws Exception {
        List<String> ignoredAntPaths = security.getIgnoredAntPaths();
        web.ignoring().antMatchers(ignoredAntPaths.toArray(new String[ignoredAntPaths.size()]));
    }

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        TokenAuthorizationFilter authenticationFilter = new TokenAuthorizationFilter(security);
        http
                .csrf().disable()
                .sessionManagement().sessionCreationPolicy(STATELESS)
                .and()
                .addFilterBefore(authenticationFilter, FilterSecurityInterceptor.class);
    }
}
{'fraction_non_alphanumeric': 0.0818394388152767, 'fraction_numerical': 0.0002598077422707197, 'mean_word_length': 4.9875583203732505, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2022078', 'n_tokens_mistral': 908, 'n_tokens_neox': 904, 'n_words': 143}