Skip to content

Use project read-only deploy-token to clone gitlab repos - #7590

Merged
6543 merged 4 commits into
woodpecker-ci:mainfrom
6543-forks:introduce-repo-token-clone
Nov 21, 2026
Merged

6543 merged 4 commits into
woodpecker-ci:mainfrom
6543-forks:introduce-repo-token-clone

Conversation

@6543

@6543 6543 commented Nov 17, 2026

Copy link
Copy Markdown
Member

Add option to store repo specific clone secrets.

So we can have scoped pinned down to repo read only secrets for each repo.

And do initial implementation for gitlab

Pipelines clone with the OAuth token of the repository user, which
often reaches every repository of that user with write access. A
leaked clone credential should reach only one repository, read-only.

Repo.CloneSecret stores credentials a forge created for one
repository, like a read-only deploy token. It is not part of the API.

Forges write it in Activate. Repair and move saved the repo before
Activate, so they now save it again afterwards. A deactivated repo
drops it.

No forge uses it yet.
GitLab pipelines cloned with the OAuth token of the repository user,
which has the api scope for everything that user can reach.

Activation now creates the project deploy token woodpecker-clone with
only the read_repository scope and stores it in the clone secret.
Repair replaces it and deactivation deletes it. Netrc hands it to the
clone step. The token does not expire, so a refreshed user token no
longer affects queued pipelines.

Creating a deploy token needs the Maintainer role. If it fails,
activation still works and pipelines clone with the user token as
before. Repositories activated earlier get the token on repair.
@6543 6543 added server forge/gitlab gitlab forge related enhancement improve existing features security labels Nov 17, 2026
@6543
6543 requested a review from a team November 17, 2026 18:03
@6543

6543 commented Nov 17, 2026

Copy link
Copy Markdown
Member Author

PS: gitea also supports it:

https://docs.gitea.com/api/operations/repo-create-deploy-token/
added via go-gitea/gitea#37306

I just want to start with one forge and then widen it ...

@6543 6543 changed the title Introduce repo CloneSecret Use project read-only deploy-token to clone gitlab repos Nov 17, 2026
@woodpecker-bot

woodpecker-bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Surge PR preview deployment was removed

@codecov

codecov Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.57143% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.96%. Comparing base (a3fb353) to head (c0bdb97).
⚠️ Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
server/api/repo.go 71.42% 2 Missing ⚠️
server/forge/gitlab/gitlab.go 92.85% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7590      +/-   ##
==========================================
+ Coverage   66.87%   66.96%   +0.08%     
==========================================
  Files         451      451              
  Lines       22646    22668      +22     
==========================================
+ Hits        15145    15180      +35     
+ Misses       7501     7488      -13     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread server/model/repo.go Resolved
@6543
6543 requested a review from qwerty287 November 20, 2026 11:54

@qwerty287 qwerty287 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

untested

@6543
6543 merged commit b0076a3 into woodpecker-ci:main Nov 21, 2026
9 checks passed
@6543
6543 deleted the introduce-repo-token-clone branch November 21, 2026 10:40
@woodpecker-bot woodpecker-bot mentioned this pull request Nov 21, 2026
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement improve existing features forge/gitlab gitlab forge related security server

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants