feat(github): support redirect flow for github link#2291
Conversation
📝 WalkthroughSummary by CodeRabbit
WalkthroughAdded an optional Changes
Possibly related PRs
🚥 Pre-merge checks | ✅ 1 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@rust/cloud-storage/authentication_service/src/api/oauth2/github.rs`:
- Around line 105-108: The callback handler uses state.original_url directly in
Redirect::temporary (returning GithubOAuthSuccess::Login) which opens an
unvalidated open-redirect; fix by validating state.original_url against an
allowlist or by parsing and ensuring it is a same-origin or permitted absolute
path before using it, and if validation fails fall back to a safe internal URL
(e.g., homepage or dashboard) and log the rejection; update the code paths that
construct Redirect::temporary(original_url) to perform this validation
(referencing state.original_url, Redirect::temporary, and
GithubOAuthSuccess::Login) and return the safe fallback redirect when the check
does not pass.
🪄 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: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 533cbe17-5295-4296-bfec-f8191d510ce2
📒 Files selected for processing (2)
rust/cloud-storage/authentication_service/src/api/link/github.rsrust/cloud-storage/authentication_service/src/api/oauth2/github.rs
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@js/app/packages/service-clients/service-auth/openapi.json`:
- Around line 373-379: The OpenAPI parameter "original_url" is marked required
but the description and generated TypeScript type should be optional; update the
OpenAPI parameter entry in openapi.json (the parameter named "original_url"
under the relevant operation) to remove or set "required": false (and/or adjust
"nullable" if intended) so the contract reflects optionality, then regenerate
the client so the generated type InitGithubLinkParams
(generated/schemas/initGithubLinkParams.ts) uses original_url?: string instead
of original_url: string.
- Around line 375-381: The OpenAPI schema exposes the query parameter
"original_url" as an unconstrained string and the backend consumes a Url type
then calls Redirect::temporary(original_url), enabling open-redirects and
custom-scheme redirects; fix by constraining "original_url" to same-origin
relative paths or an explicit allowlist: update the OpenAPI schema for parameter
original_url to require a path-only pattern (e.g. begins with "/") or enum of
allowed schemes/hosts, and add server-side validation where Url is parsed (the
code calling Redirect::temporary) to reject absolute URLs or validate against a
whitelist of allowed origins/schemes (including any mobile custom-schemes)
before performing Redirect::temporary.
🪄 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: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 906bcb6d-55de-4125-9ac3-cb62aa6db607
⛔ Files ignored due to path filters (3)
js/app/packages/service-clients/service-auth/generated/client.tsis excluded by!**/generated/**js/app/packages/service-clients/service-auth/generated/schemas/index.tsis excluded by!**/generated/**js/app/packages/service-clients/service-auth/generated/schemas/initGithubLinkParams.tsis excluded by!**/generated/**
📒 Files selected for processing (1)
js/app/packages/service-clients/service-auth/openapi.json
No description provided.