Skip to content

Instantly share code, notes, and snippets.

@thinkmicroservices
thinkmicroservices / AuthenticationService: docker-compose dc-08-authentication.yml
Created March 20, 2020 21:39
AuthenticationService: docker-compose dc-08-authentication.yml
## docker-compose -f ./dc-08-authentication.yml up -d
version: "3.7"
services:
##############################################################
# INFRASTRUCTURE SERVICES
################
@thinkmicroservices
thinkmicroservices / AuthenticationService: API-Gateway application.yml
Created March 20, 2020 02:17
AuthenticationService: API-Gateway application.yml
routes:
- id: authentication
uri: lb://AZN-SERVICE
predicates:
- Path= /api/authentication/**
filters:
- RewritePath=/api/authentication/(?<segment>.*), /$\{segment}
- name: Hystrix
@thinkmicroservices
thinkmicroservices / AuthenticationFilter:FilterConfig.java
Last active March 20, 2020 01:08
AuthenticationFilter:FilterConfig.java
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;
/**
*
@thinkmicroservices
thinkmicroservices / AuthenticationService:JWTAuthorizationFilter.java
Last active March 20, 2020 01:07
AuthenticationService:JWTAuthorizationFilter.java
package com.thinkmicroservices.ri.spring.auth.jwt;
import java.io.IOException;
import java.util.List;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
@thinkmicroservices
thinkmicroservices / AuthenticationService:JWTRoleTable.java
Created March 20, 2020 00:57
AuthenticationService:JWTRoleTable.java
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
@thinkmicroservices
thinkmicroservices / AuthenticationService: AuthenticationController.java
Created March 20, 2020 00:05
AuthenticationService: AuthenticationController.java
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;
/**
* The discovery client provides access
* to the <b>ServiceDiscovery</b> service.
*/
@Autowired
private DiscoveryClient discoveryClient;
/**
* Provides access to <b>User</b> entities.
*/
@thinkmicroservices
thinkmicroservices / AuthenticationService: refreshToken().java
Created March 19, 2020 20:23
AuthenticationService: refreshToken().java
/**
*
* @param refreshToken
* @return
* @throws RefreshTokenException
*/
public AuthenticationToken refreshToken(String refreshToken) throws
RefreshTokenException {
log.debug("refresh token:" + refreshToken);
@thinkmicroservices
thinkmicroservices / AuthenticationService:resetPassword().java
Last active March 20, 2020 00:31
AuthenticationService:resetPassword().java
/**
*
* @param email
* @param recoveryCode
* @param newPassword
* @param passwordConfirm
* @throws ResetPasswordException
*/
public void resetPassword(String email, String recoveryCode, String newPassword,
String passwordConfirm) throws ResetPasswordException {
@thinkmicroservices
thinkmicroservices / AuthenticationService: recoverPassword().java
Created March 19, 2020 20:20
AuthenticationService: recoverPassword().java
/**
*
* @param user
* @return
* @throws RecoverPasswordException
*/
public String recoverPassword(String email) throws RecoverPasswordException {
log.debug("recover password for:" + email);
User userModel = userRepository.findByUsername(email);