-
Notifications
You must be signed in to change notification settings - Fork 44
Add provider_query_params to getAuthorizationUrl method
#1347
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
Add provider_query_params to getAuthorizationUrl method
#1347
Conversation
provider_query_params to getAuthorizationUrl method
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.
Greptile Summary
This PR adds support for provider_query_params to the SSO getAuthorizationUrl method, bringing it in line with similar functionality already present in the UserManagement module. The changes involve three key modifications:
Interface Enhancement: A new optional providerQueryParams property is added to the SSOAuthorizationURLOptions interface, typed as Record<string, string | boolean | number> to support common query parameter data types.
Implementation Refactor: The SSO class undergoes a significant change in query string serialization. The existing toQueryString function is completely rewritten to use the qs library instead of the native URLSearchParams API. This enables handling of complex objects and arrays while maintaining backward compatibility through specific configuration options (alphabetical key sorting, RFC1738 format for space encoding as +).
Comprehensive Testing: New test cases verify the functionality works correctly with populated provider query params containing mixed data types (string, number, boolean) and handles empty objects gracefully. The tests use inline snapshots to verify exact URL encoding behavior.
The implementation follows the established pattern from the UserManagement module, using qs.stringify with consistent configuration options. The change also simplifies provider_scopes handling by removing manual array joining, as the qs library handles array serialization natively with the 'repeat' format. This maintains backward compatibility while extending functionality to support structured query parameters for identity providers during SSO authorization flows.
Confidence score: 4/5
- This PR introduces significant query string serialization changes that could affect existing integrations, though backward compatibility measures are in place
- Score reflects the major refactoring of core URL generation logic combined with comprehensive testing and careful compatibility considerations
- Pay close attention to the SSO implementation file and verify the
qslibrary configuration maintains exact backward compatibility
3 files reviewed, no comments
provider_query_params to getAuthorizationUrl methodprovider_query_params to getAuthorizationUrl method
Add support for provider_query_params parameter to SSO getAuthorizationUrl method, matching the existing UserManagement implementation. This allows passing custom query parameters to identity providers during the authorization flow. Changes: - Add providerQueryParams to SSOAuthorizationURLOptions interface - Update getAuthorizationUrl to accept and handle providerQueryParams - Refactor toQueryString to use qs.stringify for consistent serialization - Add comprehensive tests for provider query params functionality - Fix empty providerScopes array handling to maintain backward compatibility
f6c24e2 to
0dc0a49
Compare
## Summary Version bump to 7.69.1 ## Changes - Bump version to 7.69.1 in package.json, package-lock.json, and src/workos.ts - Update snapshot tests with new version ## Recent additions in this version - Add `provider_query_params` to SSO `getAuthorizationUrl` method (#1347)
Summary
provider_query_paramsparameter to SSOgetAuthorizationUrlmethodChanges
providerQueryParamstoSSOAuthorizationURLOptionsqs.stringifyproviderScopesarray handling to maintain backward compatibilityTest plan
Resolves ENT-3776