Oauth setup

This commit is contained in:
2024-12-25 01:04:05 +01:00
parent aa4ed91b9d
commit e20be63e5e
3 changed files with 22 additions and 17 deletions

View File

@@ -0,0 +1,13 @@
package de.zendric.app.xpensely_server.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
class HomeController {
@GetMapping("/")
public String getAll() {
return "Welcome";
}
}

View File

@@ -2,31 +2,19 @@ package de.zendric.app.xpensely_server.security;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.web.SecurityFilterChain;
@Configuration
@EnableWebSecurity
public class SecurityConfig {
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http
.authorizeHttpRequests(authorize -> authorize
.anyRequest().permitAll() // Allow all requests without authentication
)
.csrf().disable(); // Disable CSRF for development purposes
http.authorizeHttpRequests(auth -> auth
.anyRequest().authenticated()).oauth2Login(Customizer.withDefaults());
return http.build();
}
// @Bean
// public SecurityFilterChain securityFilterChain(HttpSecurity http) throws
// Exception {
// return http.authorizeHttpRequests(auth -> {
// auth.requestMatchers("/").permitAll();
// auth.anyRequest().permitAll();
// // auth.anyRequest().authenticated();
// }).oauth2Login(Customizer.withDefaults())
// .build();
// }
}