-
Couldn't load subscription status.
- Fork 27
Feat support snowflake spcs OIDC #717
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This commit is mainly meant as an example to complement changes in how we will be performing authentication within the Snowflake Posit Team Native Application. When / if that PR of work for OIDC goes through this will serve as a good example of how it can be supported. I think this PR also highlights the importance of OIDC device flow authentication which is supported in PPM https://packagemanager.rstudio.com/__docs__/admin/appendix//cli/rspm_login_sso.html which would again eliminate the need for an api key. I REALLY like how this package uses the snow command to generate the jwt used for snowflake ingress as this means our Posit libraries don't have to re-implement the snowflake authentication. Going to put this PR in draft and will contribute more after I share this with our team tomorrow at Standup.
This commit refines the Snowflake SPCS (Snowpark Container Services) OIDC authentication implementation to better align with existing codebase patterns and improve type safety. Changes: - Make SPCSConnectServer.api_key Optional[str] to match RSConnectServer - Add comprehensive docstring to SPCSConnectServer class explaining SPCS deployment and authentication approach - Reorder RSConnectExecutor server type detection to check for snowflake_connection_name first, as SPCS is more specific than generic Connect deployment - Ensure api_key is passed to SPCSConnectServer in all instantiations (RSConnectExecutor.__init__ and validate_spcs_server) - Add null check before setting X-RSC-Authorization header to fix type checking error - Update all test cases in SPCSConnectServerTestCase to pass api_key parameter and verify it's set correctly All SPCS-specific tests pass. The implementation now follows the established patterns for server authentication while maintaining backward compatibility. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Add changelog entry documenting the fix for Snowflake SPCS authentication to properly handle API keys and align with codebase patterns. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
☂️ Python Coverage
Overall Coverage
New FilesNo new covered files... Modified Files
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additional changes needed:
rsconnect-python/rsconnect/metadata.py
Lines 350 to 357 in f06b8ee
| if api_key: | |
| target_data = dict(api_key=api_key, insecure=insecure, ca_cert=ca_data) | |
| elif snowflake_connection_name: | |
| target_data = dict(snowflake_connection_name=snowflake_connection_name) | |
| elif account_name: | |
| target_data = dict(account_name=account_name, token=token, secret=secret) | |
| else: | |
| target_data = dict(token=token, secret=secret) |
|
Additional changes needed: rsconnect-python/rsconnect/main.py Lines 587 to 595 in f06b8ee
|
|
Both changes have been made and I have been able to successfully deploy to SPCS-hosted Connect using a saved server configuration. |
Moved to a branch within the repository to run tests so closed PR #715
Intent
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).
This commit is how we will be performing authentication within the Snowflake Posit Team Native Application. This will serve as a good example of how it can be supported in the rsconnect* packages. Posit Connect supports alternate headers for authorization https://docs.posit.co/connect/admin/authentication/proxied/#api-use.
I think this PR also highlights the importance of OIDC device flow authentication which is supported in PPM
https://packagemanager.rstudio.com/__docs__/admin/appendix//cli/rspm_login_sso.html which would again eliminate the need for an api key which this PR reintroduces for SPCS.
Example
Type of Change
Approach
Automated Tests
Directions for Reviewers
Checklist