For learning purposes, I make an application, as an Angular 2 client on the Spring boot backend, are on different servers. At the moment, made the registration of a user with autologin, but after registration only anonymousUser returned. As a method of authorization, I chose token authentication. If you make such authorization through JSP everything works, and through the SPA there is not enough knowledge how to implement it and examples in the network can not be found.
I hope for a hint that you need to add for authorization.
UPDATE 1
Fixed a cant so that SecurityServiceImpl was not used anywhere. Now the session is saved in the database and it seems like the authorization has passed, but SecurityContextHolder.getContext().getAuthentication().getDetails() returns null .
withCredentials=true, without it, authorization does not work. - MrFylypenkowithCredentialsalwaystrueyou can see it here on line 18 on github.com/Bleser92/frontend-spring-angular2-sci-lvl-4/blob/… - BleserwithCredentials, you can read here . Those. when requested without this parameter (when cross-domain requests), the server will NEVER know that this is the current user and will always see it as a new one and open a new session for each request. In your example on github, fron sends the post a request for registration with this parameter, and in the user service het request without it, so getting the user will always be zero or anonymous. - MrFylypenko