Skip to content

Commit

Permalink
Task 42 : Define validate token for UserServiceClient with its contro…
Browse files Browse the repository at this point in the history
…ller in user service
  • Loading branch information
Rapter1990 committed Jul 18, 2024
1 parent 08557e2 commit d993580
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.springbootmicroservices.productservice.client;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

Expand All @@ -10,4 +12,7 @@ public interface UserServiceClient {
@PostMapping("/validate-token")
void validateToken(@RequestParam String token);

@GetMapping("/authenticate")
UsernamePasswordAuthenticationToken getAuthentication(@RequestParam String token);

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

Expand Down Expand Up @@ -71,4 +72,10 @@ public CustomResponse<Void> logout(@RequestBody @Valid final TokenInvalidateRequ
return CustomResponse.SUCCESS;
}

@GetMapping("/authenticate")
public ResponseEntity<UsernamePasswordAuthenticationToken> getAuthentication(@RequestParam String token) {
UsernamePasswordAuthenticationToken authentication = tokenService.getAuthentication(token);
return ResponseEntity.ok(authentication);
}

}

0 comments on commit d993580

Please sign in to comment.