Oauth setup
This commit is contained in:
4
pom.xml
4
pom.xml
@@ -38,6 +38,10 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-security</artifactId>
|
<artifactId>spring-boot-starter-security</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-oauth2-client</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
|||||||
@@ -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";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,31 +2,19 @@ package de.zendric.app.xpensely_server.security;
|
|||||||
|
|
||||||
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.security.config.Customizer;
|
||||||
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.web.SecurityFilterChain;
|
import org.springframework.security.web.SecurityFilterChain;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
|
@EnableWebSecurity
|
||||||
public class SecurityConfig {
|
public class SecurityConfig {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
||||||
http
|
http.authorizeHttpRequests(auth -> auth
|
||||||
.authorizeHttpRequests(authorize -> authorize
|
.anyRequest().authenticated()).oauth2Login(Customizer.withDefaults());
|
||||||
.anyRequest().permitAll() // Allow all requests without authentication
|
|
||||||
)
|
|
||||||
.csrf().disable(); // Disable CSRF for development purposes
|
|
||||||
|
|
||||||
return http.build();
|
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();
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user