Add simple auth
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package com.aiteacher.auth;
|
||||
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.security.Principal;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/auth")
|
||||
public class AuthController {
|
||||
|
||||
@GetMapping("/check")
|
||||
public ResponseEntity<Map<String, String>> check(Principal principal) {
|
||||
return ResponseEntity.ok(Map.of("username", principal.getName()));
|
||||
}
|
||||
}
|
||||
@@ -30,9 +30,10 @@ public class SecurityConfig {
|
||||
|
||||
@Bean
|
||||
public UserDetailsService userDetailsService(
|
||||
@Value("${app.auth.username}") String username,
|
||||
@Value("${app.auth.password}") String password) {
|
||||
UserDetails user = User.builder()
|
||||
.username("neurosurgeon")
|
||||
.username(username)
|
||||
.password("{noop}" + password)
|
||||
.roles("USER")
|
||||
.build();
|
||||
|
||||
Reference in New Issue
Block a user