4

Grails 1.3.7 を使用しています。認証中に作成されるカスタムUserDetailsオブジェクトがあります。customUserDetailsServiceこのカスタムUserDetailsオブジェクトはセッションのどこかに保存されると思います。ただし、それを取得する方法が見つかりません。

私はそれができると思っていましたが、それは私のカスタム UserDetails ではなく、SecurityContextHolder.getContext().getAuthentication().getDetails()type: のオブジェクトを返します。org.springframework.security.web.authentication.WebAuthenticationDetails

4

1 に答える 1

6

私は 2.0.4 と春のセキュリティ プラグインを使用していますが、プラグインを使用しているように見えますか?

もしそうなら試してみてください:

// Inject 
def springSecurityService

// Action
def index() { 
  UserDetails currentUser = springSecurityService.principal 
}
于 2012-07-26T06:03:37.987 に答える