我需要一個正GET請求從瀏覽器發出後,來驗證JHipster(春季安全/ AngularJS)用戶,然後重定向到AngularJS應用(對於OpenID身份驗證)編程方式登錄和AngularJS認證(JHipster)
@GetMapping("/login")
@Timed
public void login(HttpServletResponse response) throws Exception {
User user = userRepository.findOneByLogin("user").get(); // For testing purposes
Authentication auth = new UsernamePasswordAuthenticationToken(user, null);
SecurityContextHolder.getContext().setAuthentication(auth);
response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
response.setHeader("Location", "http://localhost:8080/#/");
}
爲「http://localhost:8080/#/」是由重定向後,響應頭配備了JSESSIONID,但我不知道這是我需要的令牌(這是「用戶」身份驗證令牌?) ,它不會在瀏覽器中的cookies如果我登錄使用默認JHipst持續(或許是因爲重定向?)
呃AngularJS用戶名/密碼形式,響應頭自帶
Set-Cookie:XSRF-TOKEN=108cadcf-2005-4e36-b055-438d75dc1ce9; path=/
Set-Cookie:JSESSIONID=foVcxycPQbUgS6nviKG1ftXSIgnlgDJdtxEGCSGZ; path=/; HttpOnly
Set-Cookie:remember-me=N2pNMGFRRGJENldhZWpQTGV2d1k6c3NOTkk1WWpnR28xcWRldDE2T3U; path=/; HttpOnly; Max-Age=2678400; Expires=Sun, 07-May-2017 07:40:16 GMT
我認爲在這裏的解決方案將是編程登錄的用戶,獲得有效的JSESSIONID令牌,並將其設置在瀏覽器中一個cookie,而/使用Location頭重定向,但我有這些步驟後麻煩。任何幫助表示讚賞。