Migrate LinkedIn auth to official OAuth2 library#466
Conversation
- Rewrite linkedin.py to use requests_oauthlib.OAuth2Session - Use LinkedIn's OpenID Connect userinfo endpoint for user data - Add CSRF protection with OAuth state parameter validation - Update settings to use LINKEDIN_CLIENT_ID and LINKEDIN_CLIENT_SECRET - Remove custom oauthclient directory (no longer needed) The custom OAuth 1.0a client was used solely for LinkedIn. Now that LinkedIn supports OAuth 2.0, we can use the same pattern as GitHub and other OAuth2 providers.
There was a problem hiding this comment.
Pull request overview
This PR migrates LinkedIn authentication from a custom OAuth 1.0a implementation to OAuth 2.0 using the official requests_oauthlib library, bringing it in line with GitHub and GitLab authentication patterns.
Changes:
- Rewrote
linkedin.pyto use OAuth2Session and LinkedIn's OpenID Connect userinfo endpoint - Added CSRF protection with OAuth state parameter validation
- Updated configuration settings from
LINKEDIN_API_KEY/LINKEDIN_API_SECRETtoLINKEDIN_CLIENT_ID/LINKEDIN_CLIENT_SECRET - Removed the entire
oauthclientdirectory containing custom OAuth 1.0a implementation
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| settings.py | Updated LinkedIn configuration to use CLIENT_ID and CLIENT_SECRET naming convention, consistent with other OAuth2 providers |
| helios_auth/auth_systems/linkedin.py | Complete rewrite to use OAuth2Session, implement CSRF protection, and use OpenID Connect userinfo endpoint |
| helios_auth/auth_systems/oauthclient/oauth/init.py | Removed legacy OAuth 1.0a client library (522 lines) |
| helios_auth/auth_systems/oauthclient/oauth/rsa.py | Removed RSA signature methods for OAuth 1.0a (120 lines) |
| helios_auth/auth_systems/oauthclient/oauth/CHANGES.txt | Removed changelog for legacy OAuth library |
| helios_auth/auth_systems/oauthclient/client.py | Removed custom OAuth client wrapper (147 lines) |
| helios_auth/auth_systems/oauthclient/README | Removed documentation for legacy OAuth library |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def get_oauth_session(redirect_url=None): | ||
| return OAuth2Session( | ||
| settings.LINKEDIN_CLIENT_ID, | ||
| redirect_uri=redirect_url, | ||
| scope='openid profile email', | ||
| ) |
There was a problem hiding this comment.
The LinkedIn authentication system is missing from the OAuth integration tests. The existing tests in helios_auth/tests.py verify OAuth state validation and interface compliance for 'google', 'github', and 'gitlab', but 'linkedin' should be included in these test cases now that it also uses OAuth2.
Include LinkedIn in the existing OAuth test suite now that it uses OAuth 2.0, testing: - Required interface methods - State verification for CSRF protection - Returns None without authorization code
The custom OAuth 1.0a client was used solely for LinkedIn. Now that LinkedIn supports OAuth 2.0, we can use the same pattern as GitHub and other OAuth2 providers.