created new api's for login with spid
This commit is contained in:
@@ -10,6 +10,7 @@ import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import net.gepafin.tendermanagement.enums.UserStatusEnum;
|
||||
import net.gepafin.tendermanagement.model.request.*;
|
||||
import net.gepafin.tendermanagement.model.response.UserSamlResponse;
|
||||
import net.gepafin.tendermanagement.model.response.UserResponseBean;
|
||||
import net.gepafin.tendermanagement.model.util.JWTToken;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
@@ -37,10 +38,11 @@ public interface UserApi {
|
||||
@RequestMapping(value = "",
|
||||
produces = {"application/json"},
|
||||
method = RequestMethod.POST)
|
||||
@PreAuthorize("hasRole('ROLE_SUPER_ADMIN')")
|
||||
default ResponseEntity<Response<UserResponseBean>> createUser(
|
||||
// @PreAuthorize("hasRole('ROLE_SUPER_ADMIN')")
|
||||
default ResponseEntity<Response<JWTToken>> createUser(HttpServletRequest request,
|
||||
@Parameter(description = "temp spid Token", required = false) @RequestParam(value = "tempToken", required = false) String tempToken,
|
||||
@Parameter(description = "User request object", required = true) @Validated @RequestBody UserReq userReq) {
|
||||
return new ResponseEntity<Response<UserResponseBean>>(HttpStatus.NOT_IMPLEMENTED);
|
||||
return new ResponseEntity<Response<JWTToken>>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
@Operation(summary = "Api to update user",
|
||||
@@ -174,6 +176,7 @@ public interface UserApi {
|
||||
@Parameter(description = "status", required = true)@RequestParam(value = "status", required = true) UserStatusEnum status) {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
@Operation(summary = "Api to get valid user from token",
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@@ -186,6 +189,38 @@ public interface UserApi {
|
||||
@GetMapping(value = "/me",
|
||||
produces = { "application/json" })
|
||||
ResponseEntity<Response<UserResponseBean>> getValidUser(HttpServletRequest request);
|
||||
|
||||
@Operation(summary = "Api to validate existing user from saml token",
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
||||
@GetMapping(value = "/sso/validate/existing-user/{token}",
|
||||
produces = { "application/json" })
|
||||
ResponseEntity<Response<JWTToken>> validateExistingUserToken(HttpServletRequest request,
|
||||
@Parameter(description = "The spid token", required = true) @PathVariable("token") String token);
|
||||
|
||||
|
||||
@Operation(summary = "Api to validate new user from saml token",
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
||||
@GetMapping(value = "/sso/validate/new-user/{token}",
|
||||
produces = { "application/json" })
|
||||
ResponseEntity<Response<UserSamlResponse>> validateNewUserToken(HttpServletRequest request,
|
||||
@Parameter(description = "The spid token", required = true) @PathVariable("token") String token);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.enums.UserStatusEnum;
|
||||
import net.gepafin.tendermanagement.model.request.*;
|
||||
import net.gepafin.tendermanagement.model.response.UserSamlResponse;
|
||||
import net.gepafin.tendermanagement.model.response.UserResponseBean;
|
||||
import net.gepafin.tendermanagement.model.util.JWTToken;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
@@ -33,9 +34,9 @@ public class UserApiController implements UserApi {
|
||||
private UserService userService;
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<UserResponseBean>> createUser(@RequestBody UserReq userReq) {
|
||||
public ResponseEntity<Response<JWTToken>> createUser(HttpServletRequest request, String tempToken, @RequestBody UserReq userReq) {
|
||||
log.info("Create User with - Request Body: {}", userReq);
|
||||
UserResponseBean createdUser = userService.createUser(userReq);
|
||||
JWTToken createdUser = userService.createUser(request, tempToken, userReq);
|
||||
return ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(new Response<>(createdUser, Status.SUCCESS, Translator.toLocale(GepafinConstant.USER_CREATED_SUCCESS_MSG)));
|
||||
}
|
||||
@@ -124,4 +125,19 @@ public class UserApiController implements UserApi {
|
||||
.body(new Response<>(user, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_USER_SUCCESS_MSG)));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<JWTToken>> validateExistingUserToken(HttpServletRequest request, String token) {
|
||||
log.info("User login attempt via spid token");
|
||||
JWTToken data = userService.validateExistingUserToken(request, token);
|
||||
return ResponseEntity.ok(new Response<>(data, Status.SUCCESS, Translator.toLocale(GepafinConstant.TOKEN_VALIDATE_SUCCESS_MGE)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<UserSamlResponse>> validateNewUserToken(HttpServletRequest request, String token) {
|
||||
log.info("User validating spid token");
|
||||
UserSamlResponse data = userService.validateNewUserToken(request,token);
|
||||
return ResponseEntity.ok(new Response<>(data, Status.SUCCESS, Translator.toLocale(GepafinConstant.TOKEN_VALIDATE_SUCCESS_MGE)));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user