<commit_before>package de.starwit.application.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.oauth2.client.oidc.web.logout.OidcClientInitiatedLogoutSuccessHandler;
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;

@Profile("!dev")
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    @Autowired
    ClientRegistrationRepository clientRegistrationRepository;
    
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
			.csrf().disable()
			.authorizeRequests()
	        .antMatchers("/api/userinfo", "/api/userinfo/", "/api/user/information", "/api/user/information/").permitAll()
			.antMatchers("/").permitAll()
	        .antMatchers("/static/**/**.{js,html,css,json}").permitAll()
	    	.antMatchers("/**/api/user/**").permitAll()
			.antMatchers("/swagger-ui/**", "/swagger-ui.html", "**/api-docs", "**/api-docs/swagger-config").access("hasRole('ROLE_ADMIN') or hasRole('ROLE_PBUSER')")
			.antMatchers("/**/*.{js,html,css,json}").access("hasRole('ROLE_ADMIN') or hasRole('ROLE_PBUSER')")
	        .antMatchers("/**/app/**").access("hasRole('ROLE_ADMIN') or hasRole('ROLE_PBUSER')")
	        .anyRequest().authenticated()
	        .and()
	        .oauth2Login()
	        	.successHandler(myAuthenticationSuccessHandler())
	        		.userInfoEndpoint()
	        	.userService(injectLocalRolesOAuth2UserService())
	        .and().and()
	        .logout()
	        .deleteCookies("JSESSIONID")
	        .logoutSuccessHandler(oidcLogoutSuccessHandler());
    }

    @Bean
    InjectLocalRolesOAuth2UserService injectLocalRolesOAuth2UserService() {<commit_msg>bugfix .csrf().disable()<commit_after>package de.starwit.application.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.oauth2.client.oidc.web.logout.OidcClientInitiatedLogoutSuccessHandler;
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;

@Profile("!dev")
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    @Autowired
    ClientRegistrationRepository clientRegistrationRepository;
    
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
			.authorizeRequests()
	        .antMatchers("/api/userinfo", "/api/userinfo/", "/api/user/information", "/api/user/information/").permitAll()
			.antMatchers("/").permitAll()
	        .antMatchers("/static/**/**.{js,html,css,json}").permitAll()
	    	.antMatchers("/**/api/user/**").permitAll()
			.antMatchers("/swagger-ui/**", "/swagger-ui.html", "**/api-docs", "**/api-docs/swagger-config").access("hasRole('ROLE_ADMIN') or hasRole('ROLE_PBUSER')")
			.antMatchers("/**/*.{js,html,css,json}").access("hasRole('ROLE_ADMIN') or hasRole('ROLE_PBUSER')")
	        .antMatchers("/**/app/**").access("hasRole('ROLE_ADMIN') or hasRole('ROLE_PBUSER')")
	        .anyRequest().authenticated()
	        .and()
	        .oauth2Login()
	        	.successHandler(myAuthenticationSuccessHandler())
	        		.userInfoEndpoint()
	        	.userService(injectLocalRolesOAuth2UserService())
	        .and().and()
	        .logout()
	        .deleteCookies("JSESSIONID")
	        .logoutSuccessHandler(oidcLogoutSuccessHandler());
    }

    @Bean
    InjectLocalRolesOAuth2UserService injectLocalRolesOAuth2UserService() {
{'fraction_non_alphanumeric': 0.13957446808510637, 'fraction_numerical': 0.002553191489361702, 'mean_word_length': 4.920654911838791, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6442324', 'n_tokens_mistral': 1368, 'n_tokens_neox': 1325, 'n_words': 154}