feat: Add ParseWeibo authentication helper#466
Conversation
|
🚀 Thanks for opening this pull request! We appreciate your effort in improving the project. Please let us know once your pull request is ready for review. Tip
Note Please respond to review comments from AI agents just like you would to comments from a human reviewer. Let the reviewer resolve their own comments, unless they have reviewed and accepted your commit, or agreed with your explanation for why the feedback was incorrect. Caution Pull requests must be written using an AI agent with human supervision. Pull requests written entirely by a human will likely be rejected, because of lower code quality, higher review effort and the higher risk of introducing bugs. Please note that AI review comments on this pull request alone do not satisfy this requirement. Our CI and AI review are safeguards, not development tools. If many issues are flagged, rethink your development approach. Invest more effort in planning and design rather than using review cycles to fix low-quality code. |
📝 WalkthroughWalkthroughThis PR introduces complete Weibo OAuth authentication to the Parse-Swift SDK, adding a new ChangesWeibo OAuth Authentication Support
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 6 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (6 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
I will reformat the title to use the proper commit message syntax. |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
Sources/ParseSwift/Authentication/3rd Party/ParseWeibo/ParseWeibo.swift (1)
89-107: ⚡ Quick winConsider adding deprecation attributes to insecure auth methods.
The documentation describes these methods as "deprecated insecure" (lines 90, 152), but they lack
@availabledeprecation attributes. Adding deprecation attributes would provide compile-time warnings to guide developers toward the securecode/redirectURIflow.💡 Proposed addition of deprecation attributes
For the insecure login method:
/** Login a `ParseUser` *asynchronously* using deprecated insecure Weibo authentication. - parameter id: The id from Weibo. - parameter accessToken: The access token from Weibo. - parameter options: A set of header options sent to the server. Defaults to an empty set. - parameter callbackQueue: The queue to return to after completion. Default value of .main. - parameter completion: The block to execute. */ + `@available`(*, deprecated, message: "Use secure login(code:redirectURI:...) instead. This method sends credentials directly and is less secure.") func login(id: String, accessToken: String, options: API.Options = [],Apply the same pattern to the insecure
linkmethod at line 151.Also applies to: 151-169
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Sources/ParseSwift/Authentication/3rd` Party/ParseWeibo/ParseWeibo.swift around lines 89 - 107, Add a deprecation attribute to the insecure Weibo auth methods to surface compile-time warnings: annotate the login(id:accessToken:options:callbackQueue:completion:) function and the corresponding link(...) method (the insecure id/accessToken overloads) with `@available`(*, deprecated, message: "Use the secure code/redirectURI OAuth flow instead; the id/accessToken method is insecure and deprecated."). Ensure both methods carry the same deprecation message so callers are directed to the secure flow.Tests/ParseSwiftTests/ParseWeiboTests.swift (1)
16-274: ⚡ Quick winConsider adding test coverage for async/await and Combine variants.
The test suite provides comprehensive coverage for the callback-based APIs. While the async and Combine variants in
ParseWeibo+async.swiftandParseWeibo+combine.swiftare thin wrappers using standard patterns (withCheckedThrowingContinuationandFuture), adding at least one test per variant would increase confidence and catch potential integration issues.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Tests/ParseSwiftTests/ParseWeiboTests.swift` around lines 16 - 274, Add tests exercising the async/await and Combine wrappers for ParseWeibo to mirror the existing callback tests: create async versions of testLogin, testLoginWithInsecureAuthData, and one linking test that call the async methods (e.g., User.weibo.login(code:redirectURI:) async) using mocked network responses, and add Combine tests that subscribe to the publisher variants (e.g., User.weibo.loginPublisher(...)) asserting success/failure and state changes; reference the wrapper files ParseWeibo+async.swift and ParseWeibo+combine.swift and the wrapper entry points (async login/link methods and publisher methods) when adding these new test cases so they use the same mocked MockURLProtocol responses and expectations as the callback tests.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@Sources/ParseSwift/Authentication/3rd` Party/ParseWeibo/ParseWeibo.swift:
- Around line 31-56: The helper methods makeDictionary(code:redirectURI:),
makeDictionary(id:accessToken:), and verifyMandatoryKeys(authData:) on
AuthenticationKeys should be converted from instance methods to static methods
on the AuthenticationKeys type because they don't use self; change their
declarations to static and update all call sites that currently call them on an
enum case (e.g., AuthenticationKeys.code.makeDictionary(...),
AuthenticationKeys.id.verifyMandatoryKeys(...)) to call them as static functions
(e.g., AuthenticationKeys.makeDictionary(...),
AuthenticationKeys.verifyMandatoryKeys(...)) so usage is clear and idiomatic.
---
Nitpick comments:
In `@Sources/ParseSwift/Authentication/3rd` Party/ParseWeibo/ParseWeibo.swift:
- Around line 89-107: Add a deprecation attribute to the insecure Weibo auth
methods to surface compile-time warnings: annotate the
login(id:accessToken:options:callbackQueue:completion:) function and the
corresponding link(...) method (the insecure id/accessToken overloads) with
`@available`(*, deprecated, message: "Use the secure code/redirectURI OAuth flow
instead; the id/accessToken method is insecure and deprecated."). Ensure both
methods carry the same deprecation message so callers are directed to the secure
flow.
In `@Tests/ParseSwiftTests/ParseWeiboTests.swift`:
- Around line 16-274: Add tests exercising the async/await and Combine wrappers
for ParseWeibo to mirror the existing callback tests: create async versions of
testLogin, testLoginWithInsecureAuthData, and one linking test that call the
async methods (e.g., User.weibo.login(code:redirectURI:) async) using mocked
network responses, and add Combine tests that subscribe to the publisher
variants (e.g., User.weibo.loginPublisher(...)) asserting success/failure and
state changes; reference the wrapper files ParseWeibo+async.swift and
ParseWeibo+combine.swift and the wrapper entry points (async login/link methods
and publisher methods) when adding these new test cases so they use the same
mocked MockURLProtocol responses and expectations as the callback tests.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 77f3e097-a09d-470a-8910-6c6d5efc0424
📒 Files selected for processing (4)
Sources/ParseSwift/Authentication/3rd Party/ParseWeibo/ParseWeibo+async.swiftSources/ParseSwift/Authentication/3rd Party/ParseWeibo/ParseWeibo+combine.swiftSources/ParseSwift/Authentication/3rd Party/ParseWeibo/ParseWeibo.swiftTests/ParseSwiftTests/ParseWeiboTests.swift
New Pull Request Checklist
Issue Description
Closes: #55
Adds a
ParseWeibohelper for Parse Server's Weibo auth adapter so Parse-Swift users can log in and link users with Weibo credentials.Approach
ParseWeibowith securecodeandredirect_uriauth data support.idandaccess_tokenauth data shape.TODOs before merging
Tests
swift test --filter ParseWeiboTests