Skip to content
Snippets Groups Projects
Unverified Commit e0620e33 authored by Hamza Remmal's avatar Hamza Remmal :homes:
Browse files

chore: disable LDAP auth for now

parent 1818fa45
No related branches found
No related tags found
1 merge request!277chore: finally, a fully working shared secret authentication chain :-)
Pipeline #224261 passed
...@@ -57,7 +57,8 @@ ...@@ -57,7 +57,8 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId> <artifactId>spring-boot-starter-actuator</artifactId>
</dependency> </dependency>
<dependency> <!-- TODO: UNCOMMENT THIS TO ENABLE THE LDAP AUTH
<dependency>
<groupId>org.springframework.ldap</groupId> <groupId>org.springframework.ldap</groupId>
<artifactId>spring-ldap-core</artifactId> <artifactId>spring-ldap-core</artifactId>
</dependency> </dependency>
...@@ -65,7 +66,7 @@ ...@@ -65,7 +66,7 @@
<groupId>org.springframework.security</groupId> <groupId>org.springframework.security</groupId>
<artifactId>spring-security-ldap</artifactId> <artifactId>spring-security-ldap</artifactId>
</dependency> </dependency>
-->
</dependencies> </dependencies>
<build> <build>
......
...@@ -3,26 +3,15 @@ package ch.epfl.autograde.config; ...@@ -3,26 +3,15 @@ package ch.epfl.autograde.config;
import ch.epfl.autograde.auth.token.ShareSecretAuthenticationProvider; import ch.epfl.autograde.auth.token.ShareSecretAuthenticationProvider;
import ch.epfl.autograde.auth.token.SharedSecretConfigurer; import ch.epfl.autograde.auth.token.SharedSecretConfigurer;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order; import org.springframework.core.annotation.Order;
import org.springframework.ldap.core.support.BaseLdapPathContextSource;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.ProviderManager; import org.springframework.security.authentication.ProviderManager;
import org.springframework.security.config.annotation.web.builders.HttpSecurity; 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.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.config.annotation.web.configurers.RequestCacheConfigurer; import org.springframework.security.config.annotation.web.configurers.RequestCacheConfigurer;
import org.springframework.security.config.ldap.LdapBindAuthenticationManagerFactory;
import org.springframework.security.ldap.DefaultSpringSecurityContextSource;
import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.servlet.util.matcher.MvcRequestMatcher;
import org.springframework.security.web.util.matcher.NegatedRequestMatcher;
import org.springframework.web.servlet.handler.HandlerMappingIntrospector;
import static org.springframework.security.config.Customizer.withDefaults;
/** /**
* Security configuration and setup of the autograde service. * Security configuration and setup of the autograde service.
...@@ -44,7 +33,7 @@ public class SecurityConfig { ...@@ -44,7 +33,7 @@ public class SecurityConfig {
@Bean @Bean
@Order(1) @Order(1)
public SecurityFilterChain filterChain(HttpSecurity http, ShareSecretAuthenticationProvider provider) throws Exception { public SecurityFilterChain filterChain(HttpSecurity http, ShareSecretAuthenticationProvider provider) throws Exception {
http.apply(new SharedSecretConfigurer()); http.apply(new SharedSecretConfigurer<>());
return http return http
.securityMatcher("/api/**") .securityMatcher("/api/**")
.authenticationManager(new ProviderManager(provider)) .authenticationManager(new ProviderManager(provider))
...@@ -77,10 +66,14 @@ public class SecurityConfig { ...@@ -77,10 +66,14 @@ public class SecurityConfig {
.httpBasic(AbstractHttpConfigurer::disable) .httpBasic(AbstractHttpConfigurer::disable)
.formLogin(AbstractHttpConfigurer::disable) .formLogin(AbstractHttpConfigurer::disable)
.sessionManagement(AbstractHttpConfigurer::disable) .sessionManagement(AbstractHttpConfigurer::disable)
.authorizeHttpRequests(auth -> auth.anyRequest().permitAll()) .authorizeHttpRequests(auth -> {
auth.requestMatchers("/actuator/heath").permitAll();
auth.anyRequest().authenticated();
})
.build(); .build();
} }
/* TODO: UNCOMMENT THIS TO ENABLE THE LDAP AUTH
@Bean @Bean
@Order(Ordered.LOWEST_PRECEDENCE) @Order(Ordered.LOWEST_PRECEDENCE)
public SecurityFilterChain defaultSecurityFilterChain(HttpSecurity http, @Qualifier("ldapAuthenticationManager") AuthenticationManager manager, HandlerMappingIntrospector introspector) throws Exception { public SecurityFilterChain defaultSecurityFilterChain(HttpSecurity http, @Qualifier("ldapAuthenticationManager") AuthenticationManager manager, HandlerMappingIntrospector introspector) throws Exception {
...@@ -120,6 +113,7 @@ public class SecurityConfig { ...@@ -120,6 +113,7 @@ public class SecurityConfig {
public BaseLdapPathContextSource contextSource() { public BaseLdapPathContextSource contextSource() {
return new DefaultSpringSecurityContextSource("ldaps://ldap.epfl.ch"); return new DefaultSpringSecurityContextSource("ldaps://ldap.epfl.ch");
} }
*/
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment