成功登錄後,如何在彈簧RestController
中檢索登錄的用戶?什麼是通過彈簧安全(angularjs)登錄用戶的正確方法
我使用下面的方法/原理來獲取登錄的用戶,但它檢索anonymousUser而不是登錄的用戶。
Principal principal = SecurityContextHolder.getContext().getAuthentication();
或
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
在這裏,我在我的打印控制檯。 'org.sprin[email protected]905571d8:Principal:anonymousUser;證書:[PROTECTED];已驗證:true;詳細信息:org.sprin[email protected]0:RemoteIpAddress:127.0.0.1; SessionId:0125899A0DC1CF4F5C5A5416E1D1E49C;授予權限:ROLE_ANONYMOUS' – Sadun89