Skip to content

Commit fcdc4ec

Browse files
committed
[BaseController::Authentication] Use :api_includes
Use the new `:lookup_scope` argument for `.authenticate` and `.lookup_by_identity` to reduce the number of user based queries on every request.
1 parent e174d80 commit fcdc4ec

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

app/controllers/api/base_controller/authentication.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def api_token_mgr
8787
end
8888

8989
def auth_user(userid)
90-
auth_user_obj = User.lookup_by_identity(userid)
90+
auth_user_obj = User.lookup_by_identity(userid, lookup_scope: :api_includes)
9191
authorize_user_group(auth_user_obj)
9292
validate_user_identity(auth_user_obj)
9393
User.current_user = auth_user_obj
@@ -154,7 +154,7 @@ def authenticate_with_jwt
154154

155155
def basic_authentication(username, password)
156156
timeout = ::Settings.api.authentication_timeout.to_i_with_method
157-
user = User.authenticate(username, password, request, :require_user => true, :timeout => timeout)
157+
user = User.authenticate(username, password, request, :require_user => true, :timeout => timeout, :lookup_scope => :api_includes)
158158
auth_user(user.userid)
159159
rescue MiqException::MiqEVMLoginError => e
160160
raise AuthenticationError, e.message

0 commit comments

Comments
 (0)