0% found this document useful (0 votes)
5 views2 pages

2

This document defines a security configuration class for a Spring application that disables security for testing purposes. It is activated by default when the property 'azure.ad.enabled' is set to false. The configuration allows all HTTP requests and disables CSRF protection.

Uploaded by

amal selmi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

2

This document defines a security configuration class for a Spring application that disables security for testing purposes. It is activated by default when the property 'azure.ad.enabled' is set to false. The configuration allows all HTTP requests and disables CSRF protection.

Uploaded by

amal selmi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd

package com.irts.prestations.

config;

import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;

import org.springframework.context.annotation.Bean;

import org.springframework.context.annotation.Configuration;

import
org.springframework.security.config.annotation.web.builders.HttpSecurity;

import
org.springframework.security.config.annotation.web.configuration.EnableW
ebSecurity;

import org.springframework.security.web.SecurityFilterChain;

/**

* Configuration de sécurité désactivée pour les tests

* Active par défaut quand azure.ad.enabled=false

*/

@Configuration

@EnableWebSecurity

@ConditionalOnProperty(name = "azure.ad.enabled", havingValue =


"false", matchIfMissing = true)

public class TestSecurityConfig {

@Bean

public SecurityFilterChain testFilterChain(HttpSecurity http) throws


Exception {

http

.csrf(csrf -> csrf.disable())

.authorizeHttpRequests(authz -> authz

.anyRequest().permitAll()

);
return http.build();

You might also like