Spring-Boot-MongoDB-JWT

Build Status

Spring Boot base for projects with MongoDB and JWT based security.


This is a quick-start base for java projects with Spring Boot, MongoDB and configured JWT security.

Running


JWT security

Page http://localhost:8080/api/hello is secured. To access this page, you need to do the following:

Security is based on AuthenticationTokenFilter:

@Override 
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) 
             throws IOException, ServletException { 
  HttpServletRequest httpRequest = (HttpServletRequest) request; 
  Authentication authentication = authenticationService.authenticate(httpRequest); 
  SecurityContextHolder.getContext().setAuthentication(authentication); 
  filterChain.doFilter(request, response); 
  SecurityContextHolder.getContext().setAuthentication(null); 
} 

And some services for Token creation and Token verification.