szerhusenBC / jwt-spring-security-demo

A demo for using JWT (Json Web Token) with Spring Security and Spring Boot 2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SecurityContextHolder setAuthentication is unused?

gafarma89 opened this issue · comments

Hi

first thank for your sharing...

I would like to ask why we need this:

SecurityContextHolder.getContext().setAuthentication(authentication);

source:

https://github.com/szerhusenBC/jwt-spring-security-demo/blob/master/src/main/java/org/zerhusen/security/rest/AuthenticationRestController.java#L44

@PostMapping("/authenticate") method returns only header from controller. Is there any reason of above line? If not, can we remove it?

Thank you