Conversation
📝 WalkthroughWalkthroughThe changes modify the OAuth2 callback URL construction in the API account controller to use a protocol-aware base URL instead of directly using a platform endpoint. The new implementation dynamically builds the callback base from the request's protocol, hostname, and port, then constructs the full callback URL by appending the standard OAuth2 path pattern Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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 |
Security Scan Results for PRDocker Image Scan Results
Source Code Scan Results🎉 No vulnerabilities found! |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
app/controllers/api/account.php (1)
1956-1965: Consider extracting the callback URL construction logic into a helper function.This exact pattern for building a protocol-aware base URL with port handling is duplicated across multiple OAuth2 endpoints (lines 1294-1303, 1371-1378, 1407-1414, 1457-1465, 1990-1998). Extracting this into a helper function would improve maintainability and reduce the risk of inconsistencies.
Example refactor:
private function buildCallbackBase(Request $request): string { $protocol = System::getEnv('_APP_OPTIONS_FORCE_HTTPS') === 'disabled' ? 'http' : 'https'; $port = $request->getPort(); $callbackBase = $protocol . '://' . $request->getHostname(); if ($protocol === 'https' && $port !== '443') { $callbackBase .= ':' . $port; } elseif ($protocol === 'http' && $port !== '80') { $callbackBase .= ':' . $port; } return $callbackBase; }Then use:
$callbackBase = $this->buildCallbackBase($request); $callback = $callbackBase . '/v1/account/sessions/oauth2/callback/' . $provider . '/' . $project->getId();Note: There's also an inconsistency at line 1991 where a similar check uses
==instead of===for the FORCE_HTTPS comparison. Consider standardizing to===across the file.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
app/controllers/api/account.php(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: moderate
- GitHub Check: Setup & Build Appwrite Image
- GitHub Check: Setup & Build Appwrite Image
- GitHub Check: scan
✨ Benchmark results
⚡ Benchmark Comparison
|
What does this PR do?
(Provide a description of what this PR does and why it's needed.)
Test Plan
(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work. Screenshots may also be helpful.)
Related PRs and Issues
Checklist