Skip to content

Conversation

@henkka
Copy link
Contributor

@henkka henkka commented Nov 28, 2025

Problem

Currently, the repository permission synchronization process is effective only for adding access, not removing it. When a user loses access to a repository on the forge, the system fails to remove the corresponding entry from the perms table. This results in stale permissions persisting in the database, allowing users to retain CI access to repositories they should no longer be able to view or interact with.

Solution

Reworked the updateRepoPermissions logic to perform a full reconciliation of user permissions. In addition to upserting new permissions, it now compares the fetch results against stored data and actively deletes permissions for repositories that are no longer present on the forge. This ensures that local access rights accurately reflect the current state of the user's permissions on the forge.

@henkka henkka force-pushed the repo-permissions-cleanup-old branch from 5b64bab to 9d95a1b Compare November 28, 2025 12:10
@qwerty287 qwerty287 added bug Something isn't working server security labels Nov 28, 2025
@woodpecker-bot
Copy link
Contributor

woodpecker-bot commented Nov 28, 2025

Surge PR preview deployment succeeded. View it at https://woodpecker-ci-woodpecker-pr-5790.surge.sh

@qwerty287
Copy link
Contributor

Looks good to me - but it will likely take even more time when you login (#5665)… Can you check the tests?

@henkka
Copy link
Contributor Author

henkka commented Nov 28, 2025

Looks good to me - but it will likely take even more time when you login (#5665)…

I'd say really marginally as we're only doing DB calls. I wasn't aware of the mentioned PR, but I really like the async feature flag implemented there👍

Can you check the tests?

Oops, fixed tests and added new test for this case.

@qwerty287
Copy link
Contributor

Is it actually necessary to get the current repos? Couldn't you do a NOT IN?

@henkka henkka force-pushed the repo-permissions-cleanup-old branch from df16671 to 47c0784 Compare November 28, 2025 16:48
@henkka
Copy link
Contributor Author

henkka commented Nov 28, 2025

Couldn't you do a NOT IN?

good point! Refactored the whole implementation with that in mind

@henkka henkka force-pushed the repo-permissions-cleanup-old branch 3 times, most recently from 1fc9a65 to be10cff Compare November 28, 2025 17:06
@henkka henkka force-pushed the repo-permissions-cleanup-old branch from be10cff to 238e52d Compare November 28, 2025 18:56
@qwerty287
Copy link
Contributor

The test still seems to fail. Otherwise it looks good to me

@henkka
Copy link
Contributor Author

henkka commented Nov 29, 2025

Great! The mock expectation has been updated now

@qwerty287 qwerty287 merged commit 87ec6ce into woodpecker-ci:main Nov 29, 2025
6 of 7 checks passed
@woodpecker-bot woodpecker-bot mentioned this pull request Nov 29, 2025
1 task
@henkka henkka deleted the repo-permissions-cleanup-old branch November 30, 2025 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working security server

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants