apache / apache/grails-core

Using springSecurityService.getCurrentUserId() to grab currentUser's primary identifier?

Open
#15,899 1 comment 0 reactions 0 assignees View on GitHub
relates-to:spring-security
Dominant language
Groovy
Stars
2.9k
Forks
975
Avg merge
1d 22h
Merged PRs (30d)
92

Description

### Issue description

Inside SpringSecurityService.groovy there is a getCurrentUserId() method that returns the id property from the principal. I see no reference to this method in the documentation.

Is this method the optimal way to fetch the currentUser's primary identifier of the applications User entity or should we always use the documented springSecurityService.getCurrentUser() and grab the identifier from this User instance?

The getCurrentUserId() has the benefit of not making an additional database call / transaction to fetch the entire user record (for cases where we just need the identifier).

My concern is that the getCurrentUserId() method is not referenced in any official documentation and therefore it may not be supported or included long term?

Thank you,

henryc-agr

Contributor guide

Open the contributing guide

Research direction

Read SpringSecurityService.groovy, focusing on getCurrentUserId() and getCurrentUser(), then review the official documentation references mentioned in the issue. Determine whether getCurrentUserId() is supported for retrieving the primary identifier and clarify the documented recommendation or add the missing documentation.

Written by the indexing model from the issue text.

Assessment

Tech stack
groovy
Domain
authentication
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.