Repository navigation
Conversation
| extra="All workspaces in this project, including future workspaces, can read this workspace's state." | ||
| > | ||
| <Checkbox>{"Share this workspace's state with all workspaces in this project"}</Checkbox> |
There was a problem hiding this comment.
Projects are optional, so this checkbox also shows up (enabled) on a workspace that isn't in any project. Ticking it clears "Organization access" through onValuesChange, and saving sends globalRemoteState: false, projectRemoteState: true. The backend accepts that, but with getProject() == null neither StateService nor validateWorkspaceIdTokenCanAccessState grants anyone access, so every terraform_remote_state consumer that relied on org-wide sharing starts getting refused, with nothing in the UI saying why.
I'd disable it when there's no project, while still letting someone untick it if it's already on (e.g. the workspace was moved out of its project). !manageWorkspace has to stay in there because an explicit disabled on the Checkbox overrides the form-level disabled.
| extra="All workspaces in this project, including future workspaces, can read this workspace's state." | |
| > | |
| <Checkbox>{"Share this workspace's state with all workspaces in this project"}</Checkbox> | |
| extra={ | |
| projectId | |
| ? "All workspaces in this project, including future workspaces, can read this workspace's state." | |
| : "This workspace is not in a project. Add it to a project to share its state with the project." | |
| } | |
| > | |
| <Checkbox disabled={!manageWorkspace || (!projectId && !workspace.attributes.projectRemoteState)}> | |
| {"Share this workspace's state with all workspaces in this project"} | |
| </Checkbox> |
I checked this locally with a small jest test against the PR head. Without a project the checkbox is enabled (that's the bug). With the change it's disabled without a project, enabled inside one, disabled when manageWorkspace is false, and still enabled when it's already on without a project. yarn jest src/domain/Workspaces (18 suites / 158 tests) and prettier/eslint are clean once the fixture below is updated.
There was a problem hiding this comment.
Thanks for catching this. Fixed in 23e5274: project access is disabled when the workspace has no project, while an existing setting can still be turned off after project removal. The API also rejects new project-sharing enablement without a project. Added coverage for both paths and manage permissions, and included your co-author credit.
| render( | ||
| <WorkspaceStateShared | ||
| workspace={workspace({ globalRemoteState: true, projectRemoteState: false })} | ||
| manageWorkspace | ||
| /> | ||
| ); |
There was a problem hiding this comment.
This test toggles project access on a workspace with no project relationship, which is the exact case above. With that change applied, the fixture needs a project (same pattern as the current.relationships.project test further down):
| render( | |
| <WorkspaceStateShared | |
| workspace={workspace({ globalRemoteState: true, projectRemoteState: false })} | |
| manageWorkspace | |
| /> | |
| ); | |
| const current = workspace({ globalRemoteState: true, projectRemoteState: false }); | |
| current.relationships.project = { data: { id: "project-1" } }; | |
| render(<WorkspaceStateShared workspace={current} manageWorkspace />); |
There was a problem hiding this comment.
Updated the fixture to include a project in 23e5274. I also added UI coverage for workspaces without a project and for disabling an existing setting after project removal.
|
@ktella if the suggestion above looks good, applying it with "Commit suggestion" keeps the attribution automatically. If you'd rather write it your own way, could you add this trailer to that commit so I'm credited as co-author? |
43f9293 to
56190f7
Compare
|
@ktella thanks for taking the project check and adding the co-author credit, appreciate it! The no-project handling looks good from my side. |
|
@ktella this has some merge conflicts, can you help me fixing those? |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: dhananjay6561 <133662894+dhananjay6561@users.noreply.github.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
56190f7 to
78ce32d
Compare
@alfespa17 taken care. Please review now. |
What changed and why?
Fixes #3937.
Add an opt-in project-wide state-sharing setting and a Liquibase migration defaulting it to false, preserving existing workspace settings.
Authorize same-organization, same-project workspace runners in both direct state and Terraform-compatible read paths. Include project members in the effective consumer list and deduplicate existing individual grants.
Make project and organization sharing mutually exclusive. Individual grants remain additive and survive scope changes; reject newly added individual grants already covered by project access while preserving existing overlapping grants.
Add the project setting and scope switching to the workspace UI, disable already-covered picker options, and clarify removal behavior. Correct the workspace-to-project mapping to allow multiple workspaces in one project.
Add focused security, HTTP integration, and UI tests.
Disable project access for workspaces without a project and reject new project-sharing enablement without a project in the API. Workspaces can still leave a project and turn off an existing setting.
Testing
Review fix validation
docker exec -w /workspaces/terrakube kiran-tella-crdn-musical-telegram_devcontainer-terrakube-dev-1 mvn -q -pl api -am '-Dtest=NewSecurityChecksTest,ProjectStateSharingIntegrationTest' -Dsurefire.failIfNoSpecifiedTests=false test— PASS: 24 tests.docker exec -w /workspaces/terrakube/ui kiran-tella-crdn-musical-telegram_devcontainer-terrakube-dev-1 yarn test --runInBand src/domain/Workspaces/Settings/__tests__/SshKeyLockingStateShared.test.tsx— PASS: 17 tests.docker exec -w /workspaces/terrakube/ui kiran-tella-crdn-musical-telegram_devcontainer-terrakube-dev-1 yarn eslint src/domain/Workspaces/Settings/StateShared.tsx src/domain/Workspaces/Settings/__tests__/SshKeyLockingStateShared.test.tsx— PASS with one existing console warning.These tests cover enabling without a project, API and UI behavior, workspace reassignment, disabling an existing setting after project removal, and read-only users.
Terraform runs used normal executor-issued workspace credentials and an output-only source configuration; disposable workspaces and projects were removed after testing. A dedicated upgrade test against an existing production database was not run.
Visual changes (if applicable)
The State shared settings page adds a project-access checkbox and marks already-covered picker options.