@@ -0,0 +1,1732 @@
+package com.serg.config.auth;%0A%0Aimport com.serg.model.Credentials;%0Aimport com.serg.model.User;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.security.authentication.AuthenticationManager;%0Aimport org.springframework.security.authentication.UsernamePasswordAuthenticationToken;%0Aimport org.springframework.security.core.Authentication;%0Aimport org.springframework.security.core.context.SecurityContextHolder;%0Aimport org.springframework.web.bind.annotation.RequestBody;%0Aimport org.springframework.web.bind.annotation.RequestMapping;%0Aimport org.springframework.web.bind.annotation.RequestMethod;%0Aimport org.springframework.web.bind.annotation.RestController;%0A%0Aimport javax.servlet.http.HttpSession;%0A%0A@RestController()%0A@RequestMapping(%22/api/session%22)%0Apublic class AuthenticationResource %7B%0A    @Autowired%0A    private%0A    AuthenticationManager authenticationManager;%0A%0A    @RequestMapping(method = RequestMethod.POST)%0A    public User login(@RequestBody Credentials credentials, HttpSession httpSession) %7B%0A        Authentication authentication = new UsernamePasswordAuthenticationToken(credentials.getUsername(), credentials.getPassword());%0A        SecurityContextHolder.getContext().setAuthentication(authenticationManager.authenticate(authentication));%0A%0A        User user = new User(credentials.getUsername(), httpSession.getId(), true);%0A        httpSession.setAttribute(%22user%22, user);%0A        return user;%0A    %7D%0A%0A    @RequestMapping(method = RequestMethod.GET)%0A    public Object session(HttpSession session) %7B%0A        return session.getAttribute(%22user%22);%0A    %7D%0A%0A    @RequestMapping(method = RequestMethod.DELETE)%0A    public void logout(HttpSession session) %7B%0A        session.invalidate();%0A    %7D%0A%7D%0A

add Auth Resourse