gitpod/components/gitpod-protocol
Gero Posmyk-Leinemann d42b06d3b0
[CLC-2032] Block login and workspace operations for Classic PAYG sunset (#21100)
* [CLC-2032] Block login and workspace operations for Classic PAYG sunset

Implement feature flag-based blocking for Gitpod Classic PAYG users:

Backend:
- Add utility functions to check if user is blocked by sunset
- Block login attempts in /login route handler, redirect to app.ona.com
- Block workspace creation and start operations in workspace-service-api
- Exempt users with roles/permissions and users in exempted organizations

Frontend:
- Update login page to show 'Login with Ona' button when sunset is enabled
- Keep SSO login form visible for exempted organizations
- Hide sunset notice banner when flag is enabled
- Update heading to 'Gitpod Classic has sunset'

Feature flag: classic_payg_sunset_enabled (JSON with enabled boolean and exemptedOrganizations array)

Co-authored-by: Ona <no-reply@ona.com>

* Add oldLogin parameter to show full login UI for exempted orgs

When sunset is enabled on gitpod.io, users now see a simplified UI:
- 'Continue with Ona' button (default)
- Link to show all login options (?oldLogin=true)

With ?oldLogin=true parameter:
- Shows all OAuth provider buttons
- Shows SSO login form
- Full functionality for exempted organizations

The link preserves returnToPath parameter if present.

Co-authored-by: Ona <no-reply@ona.com>

* Refactor backend sunset checks into separate functions

Split sunset blocking logic into two functions:
- isUserLoginBlockedBySunset: checks roles/permissions exemption for login
- isWorkspaceStartBlockedBySunset: checks org-level exemption for workspace ops

Move ClassicPaygSunsetConfig interface to gitpod-protocol for reusability.
Pass organizationId explicitly to workspace blocking checks.

Co-authored-by: Ona <no-reply@ona.com>

* Use typed ClassicPaygSunsetConfig in frontend feature flag

Import ClassicPaygSunsetConfig type from gitpod-protocol and use it
as the default value for classic_payg_sunset_enabled feature flag.

This leverages TypeScript's generic type inference in useFeatureFlag:
- useFeatureFlag<K extends keyof FeatureFlags> returns FeatureFlags[K]
- For classic_payg_sunset_enabled, it now returns ClassicPaygSunsetConfig
- Other flags continue to return their respective types (boolean, string, etc.)

Updated Login.tsx to access .enabled property with type guard to handle
the union type (ClassicPaygSunsetConfig | boolean) during loading state.

This ensures type safety and consistency between frontend and backend.

Co-authored-by: Ona <no-reply@ona.com>

* Parse JSON string for classic_payg_sunset_enabled feature flag

ConfigCat text flags return strings, so we need to parse JSON on both
frontend and backend.

Backend (featureflags.ts):
- Send JSON.stringify(defaultConfig) to ConfigCat
- Parse returned string with JSON.parse()
- Handle errors gracefully with fallback to default

Frontend (featureflag-query.ts):
- Add parseFeatureFlagValue() helper for JSON flags
- Send stringified default for classic_payg_sunset_enabled
- Parse returned string value
- Maintain type safety with generic return types

This allows ConfigCat to store the flag as text while maintaining
the typed object structure in our code.

Co-authored-by: Ona <no-reply@ona.com>

* Exempt dedicated installations from sunset blocking

Add isDedicatedInstallation parameter to sunset check functions.
Dedicated installations always return false (not blocked) regardless
of feature flag state.

Changes:
- isUserLoginBlockedBySunset: add isDedicatedInstallation param
- isWorkspaceStartBlockedBySunset: add isDedicatedInstallation param
- UserController: pass config.isDedicatedInstallation to login check
- WorkspaceServiceAPI: inject Config and pass isDedicatedInstallation

This ensures the sunset only affects gitpod.io (PAYG) and not
dedicated installations.

Co-authored-by: Ona <no-reply@ona.com>

* update login page for Gitpod classic `gitpod.io` users

* fix

* Improve sunset UI: use primary button and remove redundant subheading

Co-authored-by: Ona <no-reply@ona.com>

* Update sunset UI heading to focus on Ona value proposition

Co-authored-by: Ona <no-reply@ona.com>

---------

Co-authored-by: Ona <no-reply@ona.com>
Co-authored-by: Siddhant Khare <siddhant@gitpod.io>
Co-authored-by: Cornelius A. Ludmann <github@cornelius-ludmann.de>
2025-10-15 09:06:36 -04:00
..
2025-05-28 13:32:00 -04:00
2020-08-25 09:25:15 +00:00