Class AuthController
java.lang.Object
tech.lastbox.lastshield.basicauth.controller.AuthController
@RestController
@ConditionalOnProperty(name="lastshield.basicauth",
havingValue="true")
public class AuthController
extends Object
Controller responsible for authentication and user management, including login and registration.
This controller exposes endpoints to authenticate users and register new users, generating
JWT tokens for valid users.
-
Constructor Summary
ConstructorsConstructorDescriptionAuthController(UserService userService, JwtService jwtService, BasicAuthProperties basicAuthProperties) -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<?> login(LoginRequest loginRequest) Endpoint for user login.org.springframework.http.ResponseEntity<?> register(RegisterRequest registerRequest) Endpoint for user registration.
-
Constructor Details
-
AuthController
public AuthController(UserService userService, JwtService jwtService, BasicAuthProperties basicAuthProperties)
-
-
Method Details
-
login
@PostMapping("/login") public org.springframework.http.ResponseEntity<?> login(@RequestBody LoginRequest loginRequest) Endpoint for user login. Validates credentials and returns a JWT token.- Parameters:
loginRequest- the login credentials containing the username and password- Returns:
- ResponseEntity with the login result and JWT token
-
register
@PostMapping("/register") public org.springframework.http.ResponseEntity<?> register(@RequestBody RegisterRequest registerRequest) Endpoint for user registration. Registers a new user and returns a JWT token for authentication.- Parameters:
registerRequest- the user registration details- Returns:
- ResponseEntity with the registration result and JWT token
-