callicoder / spring-security-react-ant-design-polls-app

Full Stack Polls App built using Spring Boot, Spring Security, JWT, React, and Ant Design
https://www.callicoder.com/spring-boot-spring-security-jwt-mysql-react-app-part-1/
1.77k stars 1.07k forks source link

@CurrentUser annotation, authenticated user controllers, Signin controller. #31

Open a-korzhov opened 4 years ago

a-korzhov commented 4 years ago

1.Could you tell me the reason of @CurrentUser annotation, if there is no logic implemented for that? It is like empty annotation that nothing changes?

  1. Why you are autowiring AuthenticationManager to controllers? You could just add Authentication to arguments of controllers, where you need for authenticated users. And from that Authentication get user data.
  2. And why you are creating redundunt login controller, if Spring Security provides that? You need just add filter method from "extends UsernamePasswordAuthenticationFilter" and override Authentication attemptAuthentication. There you are getting user and authenticate him with username and password.