feat: add API key support for SPCS authentication #1244
Closed
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.
Summary
Prior to recent changes on the Snowflake side, proxied authentication headers carried enough information for Connect running in Snowflake SPCS to identify users. With the move to OIDC, Connect servers no longer trust Snowflake headers for username identification. This requires users to provide both a Snowflake connection (for proxied authentication) and a Connect API key (for OIDC authentication).
Adds API key support for Snowflake SPCS (Snowpark Container Services) authentication due to changes in native application authentication using OIDC. Connect within the SPCS native application no longer relies on Snowflake headers to determine the user. You can think of the SPCS private key now only being used for proxied authentication to pass the request through and the api key is used by connect
Problem
SPCS deployments require a dual authentication model:
Previously,
connectSPCSUser()only handled Snowflake token authentication through thesnowflakeConnectionNameparameter. The API key was not captured or transmitted,preventing proper user identification by the Connect server.
Solution
apiKeyas a required parameter toconnectSPCSUser()authHeaders()to include the API key in theX-RSC-Authorizationheader whenboth
snowflakeTokenandapiKeyare presentapiKeyin account registration alongsidesnowflakeConnectionNameThis mirrors the authentication pattern implemented in
rsconnect-python#715.
Changes
R/http.R: ModifiedauthHeaders()to addX-RSC-Authorizationheader for SPCSR/accounts.R: UpdatedconnectSPCSUser()andgetSPCSAuthedUser()to accept and useAPI key
man/connectSPCSUser.Rd: Updated function documentationtests/testthat/test-spcs.R: Added test coverage for API key handlingNEWS.md: Documented the breaking changeBreaking Change
connectSPCSUser()now requires anapiKeyparameter. Existing code will need tobe updated:
Testing