Project

General

Profile

Feature #27430

Allow /users endpoint to return current user

Added by Jeremy Lenz 12 months ago. Updated 11 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
API
Target version:
-
Difficulty:
easy
Triaged:
No
Bugzilla link:
Fixed in Releases:
Found in Releases:

Description

Currently the Foreman API doesn't have a way to request the current user. Doing some UI work in Katello, we would like this ability so that we can avoid showing buttons, etc. for actions the user doesn't have permission to do.

The User model would need only one small change to the scoped_search setup. After this change, you can do

`GET api/v2/users?search=id=current`

and the API would return the currently logged-in user.

Associated revisions

Revision 07c4fec4 (diff)
Added by Jeremy Lenz 11 months ago

Fixes #27430: Allow for returning current user

Modify the find_resource method in API users controller so that
GET api/v2/current_user
will return the current user.
Same output as if you specified the current user's ID
in GET /api/v2/users/:id
Added test for logged-out user
update test per PR review

History

#1 Updated by The Foreman Bot 12 months ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/6929 added

#2 Updated by The Foreman Bot 11 months ago

  • Fixed in Releases 1.24.0 added

#3 Updated by Jeremy Lenz 11 months ago

  • Status changed from Ready For Testing to Closed

Also available in: Atom PDF