This file contains hidden or 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
## docker-compose -f ./dc-08-authentication.yml up -d | |
version: "3.7" | |
services: | |
############################################################## | |
# INFRASTRUCTURE SERVICES | |
################ |
This file contains hidden or 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
routes: | |
- id: authentication | |
uri: lb://AZN-SERVICE | |
predicates: | |
- Path= /api/authentication/** | |
filters: | |
- RewritePath=/api/authentication/(?<segment>.*), /$\{segment} | |
- name: Hystrix |
This file contains hidden or 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
package com.thinkmicroservices.ri.spring.auth; | |
import com.thinkmicroservices.ri.spring.auth.jwt.JWTAuthorizationFilter; | |
import lombok.extern.slf4j.Slf4j; | |
import org.springframework.boot.web.servlet.FilterRegistrationBean; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.Configuration; | |
/** | |
* |
This file contains hidden or 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
package com.thinkmicroservices.ri.spring.auth.jwt; | |
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.List; | |
import lombok.extern.slf4j.Slf4j; | |
/** | |
* The JWTRoleTable provides a mechanism for looking up the required roles for a | |
* given application uri path. The uri paths and corresponding roles are stored |
This file contains hidden or 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
package com.thinkmicroservices.ri.spring.auth.controller; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.http.ResponseEntity; | |
import org.springframework.web.bind.annotation.RequestBody; | |
import org.springframework.web.bind.annotation.RequestMapping; | |
import org.springframework.web.bind.annotation.RequestMethod; | |
import org.springframework.web.bind.annotation.RestController; | |
import org.springframework.http.HttpStatus; |
This file contains hidden or 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
/** | |
* The discovery client provides access | |
* to the <b>ServiceDiscovery</b> service. | |
*/ | |
@Autowired | |
private DiscoveryClient discoveryClient; | |
/** | |
* Provides access to <b>User</b> entities. | |
*/ |
This file contains hidden or 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
/** | |
* | |
* @param refreshToken | |
* @return | |
* @throws RefreshTokenException | |
*/ | |
public AuthenticationToken refreshToken(String refreshToken) throws | |
RefreshTokenException { | |
log.debug("refresh token:" + refreshToken); |
This file contains hidden or 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
/** | |
* | |
* @param email | |
* @param recoveryCode | |
* @param newPassword | |
* @param passwordConfirm | |
* @throws ResetPasswordException | |
*/ | |
public void resetPassword(String email, String recoveryCode, String newPassword, | |
String passwordConfirm) throws ResetPasswordException { |
This file contains hidden or 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
/** | |
* | |
* @param user | |
* @return | |
* @throws RecoverPasswordException | |
*/ | |
public String recoverPassword(String email) throws RecoverPasswordException { | |
log.debug("recover password for:" + email); | |
User userModel = userRepository.findByUsername(email); |