Grails 和 Spring Security:如何从控制器中获取经过身份验证的用户? [英] Grails and Spring Security: How do I get the authenticated user from within a controller?
本文介绍了Grails 和 Spring Security:如何从控制器中获取经过身份验证的用户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我最近从 JSecurity 插件转移到 Spring Security.如何从我的控制器中获取经过身份验证的用户?
I recently moved from the JSecurity plugin to Spring Security. How do I get the authenticated user from within my controllers?
推荐答案
我使用的是 0.5.1,以下对我有用:
I'm using 0.5.1 and the following works for me:
class EventController {
def authenticateService
def list = {
def user = authenticateService.principal()
def username = user?.getUsername()
.....
.....
}
}
这篇关于Grails 和 Spring Security:如何从控制器中获取经过身份验证的用户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文