Skip to content

[API Server] Keep user_type on the request user for authenticated requests - #11458

Open
amitgelber wants to merge 1 commit into
skypilot-org:masterfrom
amitgelber:fix/admin-policy-user-type
Open

amitgelber wants to merge 1 commit into
skypilot-org:masterfrom
amitgelber:fix/admin-policy-user-type

Conversation

@amitgelber

@amitgelber amitgelber commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Since #11292, override_request_env_and_config skips the users upsert for authenticated requests and builds the request user from the id and name stamped on the request body. That user has no user_type, so an admin policy sees UserRequest.user.user_type is None for 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's SKYPILOT_USER.

A policy that uses user_type to 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 to authenticated would work too. Happy to switch to that.

Tested (run the relevant ones):

  • Code formatting: yapf==0.32.0 --diff clean on both files
  • Any manual or new tests for this PR (please specify below)
    • New test_authenticated_request_user_carries_user_type: fails on master (assert None == 'sso'), passes with the change. The existing auth-path tests in test_executor.py pass. (test_stamp_keeps_loopback_env[False] fails locally on master both with and without this change.)
    • Running the same change on a 0.14.3 server with oauth2-proxy auth: the admin policy receives user_type=sso again, and launches are accepted.
  • All smoke tests: /smoke-test (CI) or pytest tests/test_smoke.py (local)
  • Relevant individual tests: /smoke-test -k test_name (CI) or pytest tests/test_smoke.py::test_name (local)
  • Backward compatibility: /quicktest-core (CI) or pytest tests/smoke_tests/test_backward_compat.py (local)

Devin Review

…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.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant