Skip to content

[server] Enforce state presence and validation on the /api/authorize endoint #20969

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

geropl
Copy link
Member

@geropl geropl commented Jul 23, 2025

Description

Feature flag: enforce_authorize_state_validation

Related Issue(s)

Fixes CLC-1592

How to test

Documentation

Preview status

gitpod:summary

Build Options

Build
  • /werft with-werft
    Run the build with werft instead of GHA
  • leeway-no-cache
  • /werft no-test
    Run Leeway with --dont-test
Publish
  • /werft publish-to-npm
  • /werft publish-to-jb-marketplace
Installer
  • analytics=segment
  • with-dedicated-emulation
  • workspace-feature-flags
    Add desired feature flags to the end of the line above, space separated
Preview Environment / Integration Tests
  • /werft with-local-preview
    If enabled this will build install/preview
  • /werft with-preview
  • /werft with-large-vm
  • /werft with-gce-vm
    If enabled this will create the environment on GCE infra
  • /werft preemptible
    Saves cost. Untick this only if you're really sure you need a non-preemtible machine.
  • with-integration-tests=all
    Valid options are all, workspace, webapp, ide, jetbrains, vscode, ssh. If enabled, with-preview and with-large-vm will be enabled.
  • with-monitoring

/hold

geropl and others added 3 commits July 24, 2025 16:35
- Add comprehensive feature branch naming convention to systemPatterns.md
- Include initials extraction rules and 24-character limit
- Add workflow steps with git config user.name requirement
- Add reference to branch naming guidelines in CLAUDE.md
- Ensure all future AI sessions follow consistent branch naming

Co-authored-by: Ona <[email protected]>
- Add URL validation in authenticator to reject returnTo URLs pointing to /api paths or api. subdomains
- Move isApiPath method into validateAuthorizeReturnToUrl for better encapsulation
- Maintain existing prefix-based domain validation in getReturnToParamWithSafeBaseDomain
- Add comprehensive tests for validation functions
- Covers edge cases: case insensitivity, malformed URLs, query params

Co-authored-by: Ona <[email protected]>
- Add feature flag check in authenticator.authorize() method
- Add validation in GenericAuthProvider.callback() for authFlow.returnTo
- Only validate when getFeatureFlagEnforceAuthorizeStateValidation is true
- Handle cases where user may not be available (new user flow)
- Maintain backward compatibility with feature flag disabled by default

Co-authored-by: Ona <[email protected]>
@geropl geropl force-pushed the gpl/1592-oauth-fix branch from 89dc9c8 to 7547ba0 Compare July 24, 2025 16:35
@geropl
Copy link
Member Author

geropl commented Jul 24, 2025

@AlexTugarev Can you reserve some time tomorrow to review this? 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants