Skip to content

OIDC provider #25664

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 7 commits into
base: main
Choose a base branch
from
Draft

OIDC provider #25664

wants to merge 7 commits into from

Conversation

sorenisanerd
Copy link

This adds support for a Github Actions compatible OIDC provider.

For more info, see:
https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect

It depends on a few changes in act and act_runner:
https://gitea.com/gitea/act_runner/pulls/272
https://gitea.com/gitea/act/pulls/73

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jul 4, 2023
@sorenisanerd
Copy link
Author

Still work-in-progress. I have a few more things I want to test before it's ready.

go.mod Outdated
@@ -300,7 +300,7 @@ replace github.com/hashicorp/go-version => github.com/6543/go-version v1.3.1

replace github.com/shurcooL/vfsgen => github.com/lunny/vfsgen v0.0.0-20220105142115-2c99e1ffdfa0

replace github.com/nektos/act => gitea.com/gitea/act v0.243.4
replace github.com/nektos/act => gitea.com/sorenisanerd/act v0.246.1-0.20230704003127-0ffa64475fd8
Copy link
Member

Choose a reason for hiding this comment

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

Please send PR to gitea.com/gitea/act first.

Copy link
Author

Choose a reason for hiding this comment

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

@sorenisanerd
Copy link
Author

I think this is ready for review, but obviously it's useless without the act and act_runner changes.

@wolfogre
Copy link
Member

wolfogre commented Jul 7, 2023

@sorenisanerd Thank you for your work, I have to say you did a great job, good idea, good code.

However, this featrue has been blocked some trivial things.

  • Where to keep the code for parsing permissions? Gitea, the forked act, the upstream act, or using actionlint indead?
  • The permissions field is only only for OIDC, but the permissions granted to the GITHUB_TOKEN/GITEA_TOKEN (probably more often), personally, I think the latter should be supported first.
  • Is it possible for contributors to send a PR that updates the permissions field and runs a malicious script?

You know, once permissions are involved, we need to be checked more carefully. Please give us some time to discuss and decide.

@sorenisanerd
Copy link
Author

Thank you for your kind comments :)

I'm very open to porting this to gitea or actionlinter or wherever. I don't have any strong opinions on it.

I agree it would have made more sense to first use permissions to adjust the capabilities of the GitHub token. I happened to need this oidc-provider functionality, so that's what I focused on. I included methods for merging permissions as well as definitions matching GitHub's defaults so I or someone else could add that later.

Great point about how permissions are affected when permissions apply for pull requests. Is that supposed to be safeguarded by the need to approve workflow runs for new contributors? I honestly don't know what GitHub does.

@sorenisanerd
Copy link
Author

I've pushed changes to the act and act_runner PR's on gitea.com. The resulting diffs are very modest. The rest of the functionality has been pulled into Gitea here.

Is this approach more agreeable? I'll add some tests once we're happy with the overall approach.

@sorenisanerd
Copy link
Author

I rebased this and reworked it into a set of more reviewable commits. If you like, I can submit them as individual PR's, but each one depends on the previous ones, which makes it a little awkward to manage as separate PR's.

@sorenisanerd sorenisanerd changed the title WIP: OIDC provider OIDC provider Aug 10, 2023
@github-actions github-actions bot added the modifies/api This PR adds API routes or modifies them label Sep 16, 2023
@sorenisanerd
Copy link
Author

Nothing new, just rebased and folded ded82c3 (the formatting changes based on the linting errors) into the relevant patches.

@@ -303,7 +303,7 @@ replace github.com/hashicorp/go-version => github.com/6543/go-version v1.3.1

replace github.com/shurcooL/vfsgen => github.com/lunny/vfsgen v0.0.0-20220105142115-2c99e1ffdfa0

replace github.com/nektos/act => gitea.com/gitea/act v0.243.4
replace github.com/nektos/act => gitea.com/sorenisanerd/act v0.246.2-0.20230806181409-a9e947b70bf6
Copy link
Member

Choose a reason for hiding this comment

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

Maybe a update on gitea/act side is better.

Copy link
Author

Choose a reason for hiding this comment

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

As mentioned in the PR description, there's a PR against gitea/act at https://gitea.com/gitea/act/pulls/73 since several months ago.


func AddPermissions(x *xorm.Engine) error {
type ActionRunJob struct {
Permissions actions_model.Permissions `xorm:"JSON TEXT"`
Copy link
Member

Choose a reason for hiding this comment

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

We need to copy the Permissions struct here because in future that struct maybe changed.

Copy link
Author

Choose a reason for hiding this comment

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

Excellent point. I'll make that change.

Copy link
Author

Choose a reason for hiding this comment

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

Wait, does it even matter, since it's stored as JSON? Should I just put interface{} instead of actions_model.Permissions?

@@ -103,6 +103,7 @@ func (o *OAuth2) userIDFromToken(ctx context.Context, tokenSHA string, store Dat

store.GetData()["IsActionsToken"] = true
store.GetData()["ActionsTaskID"] = task.ID
store.GetData()["ActionsTask"] = task
Copy link
Member

Choose a reason for hiding this comment

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

We can load the task from database when we need it but not store it in context?

Copy link
Author

Choose a reason for hiding this comment

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

I honestly don't remember why I did it this way. It's been a while. Let me take another look.

Referencing it could cause inconsistencies if it changes later.
@sorenisanerd
Copy link
Author

I took the liberty of renaming my migration to just permissions.go. At this point, I must have had to rename it 5-7 times locally and it's getting kinda annoying. Once this gets closer to being approved, I'll try to pick a number for it.

@sorenisanerd
Copy link
Author

I'm also working on a more complete permissions implementation that should probably be merged before this one, so I'm setting this one back to WIP. I expect the permissions patch to be ready some time this week.

@sorenisanerd sorenisanerd marked this pull request as draft September 19, 2023 23:38
@punmechanic
Copy link

Hello, are there any updates on this? is there something a contributor can help out with? Would love to see this move along

@NorNorLukas
Copy link

I am also very interested om seeing this moving along. Any updates on this?

@scubbo
Copy link

scubbo commented Mar 18, 2025

Also chiming in support of this - it would be great for Gitea Actions to be able to authenticate to Vault via JWT.

@sorenisanerd
Copy link
Author

sorenisanerd commented Mar 19, 2025 via email

@scubbo
Copy link

scubbo commented Mar 20, 2025

Understandable - thank you for your effort so far!

I haven't made any contributions to the gitea codebase, so I'd mostly just be replicating what you've done and trying my best to understand it as I go - but I'm certainly willing to try!

EDIT: Here's hoping that this will get more traction! I will of course give you full credit if this gets merged. Thanks again, @sorenisanerd!

@scubbo scubbo mentioned this pull request Mar 20, 2025
chhe pushed a commit to chhe/act that referenced this pull request Mar 26, 2025
Resurrecting [this PR](https://gitea.com/gitea/act/pulls/73) as the original author has [lost motivation](go-gitea/gitea#25664 (comment)) (though, to be clear - all credit belongs to them, all mistakes are mine and mine alone!)

Co-authored-by: Søren L. Hansen <[email protected]>
Reviewed-on: https://gitea.com/gitea/act/pulls/133
Reviewed-by: Lunny Xiao <[email protected]>
Co-authored-by: Jack Jackson <[email protected]>
Co-committed-by: Jack Jackson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. modifies/api This PR adds API routes or modifies them
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants