Repository navigation
[API Server] Keep user_type on the request user for authenticated requests - #11458
Open
amitgelber wants to merge 1 commit into
Open
amitgelber wants to merge 1 commit into
amitgelber wants to merge 1 commit into
Conversation
…uests skypilot-org#11292 skips the users upsert for authenticated requests, so the user the request runs as carries only id and name. Admin policies then see UserRequest.user.user_type=None for every authenticated user, the value they would see for a request with no auth. Read the users row for authenticated requests, as the workspace resolver already does.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since #11292,
override_request_env_and_configskips the users upsert for authenticated requests and builds the request user from the id and name stamped on the request body. That user has nouser_type, so an admin policy seesUserRequest.user.user_type is Nonefor every SSO and service-account request. That is the same value a request gets when the server has no auth and the identity comes from the client'sSKYPILOT_USER.A policy that uses
user_typeto tell a verified identity from a self-asserted one now treats every authenticated user as unauthenticated. We hit this after upgrading to 0.14.3: our RestfulAdminPolicy rejected every launch on our cluster.This PR reads the users row for authenticated requests (
global_user_state.get_user(user.id) or user), the same read the workspace resolver already does a few lines further down. It is a primary-key read, not the upsert #11292 removed. If you would rather avoid the read, the auth middleware already has the user's type, and stamping it on the request body next toauthenticatedwould work too. Happy to switch to that.Tested (run the relevant ones):
yapf==0.32.0 --diffclean on both filestest_authenticated_request_user_carries_user_type: fails on master (assert None == 'sso'), passes with the change. The existing auth-path tests intest_executor.pypass. (test_stamp_keeps_loopback_env[False]fails locally on master both with and without this change.)user_type=ssoagain, and launches are accepted./smoke-test(CI) orpytest tests/test_smoke.py(local)/smoke-test -k test_name(CI) orpytest tests/test_smoke.py::test_name(local)/quicktest-core(CI) orpytest tests/smoke_tests/test_backward_compat.py(local)