-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored method getRole to getUserFromJwt to have principal
- Loading branch information
Showing
5 changed files
with
37 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.epam.esm.model; | ||
|
||
public enum Provider { | ||
LOCAL,GOOGLE | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.epam.esm.model; | ||
|
||
public enum Role { | ||
USER, ADMIN | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.epam.esm.model; | ||
|
||
import lombok.*; | ||
|
||
@Builder | ||
@Getter | ||
@Setter | ||
@ToString | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class UserDTO { | ||
private Long id; | ||
private String name; | ||
private String surname; | ||
private String phone; | ||
private String email; | ||
private Provider provider; | ||
private Role role; | ||
} |
5 changes: 3 additions & 2 deletions
5
src/main/java/com/epam/esm/utils/openfeign/AuthFeignClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
package com.epam.esm.utils.openfeign; | ||
|
||
import com.epam.esm.model.UserDTO; | ||
import org.springframework.cloud.openfeign.FeignClient; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestHeader; | ||
|
||
@FeignClient(name = "auth-service", configuration = CustomFeignClientConfiguration.class) | ||
public interface AuthFeignClient { | ||
@GetMapping("api/v1/auth/role") | ||
ResponseEntity<String> getRole(@RequestHeader(value = "Authorization") String authorizationHeader); | ||
@GetMapping("api/v1/auth/user") | ||
ResponseEntity<UserDTO> getUserFromJwt(@RequestHeader(value = "Authorization") String authorizationHeader); | ||
} |