-
Notifications
You must be signed in to change notification settings - Fork 13
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
Access to folder (multi-branch) name #22
Access to folder (multi-branch) name #22
Comments
hey @jglick i'd be happy to have a look at this if you could give any pointers on how to go about implementing this. |
I do not exactly follow what sorts of claims you are looking to define and why you cannot already create them given https://github.com/jenkinsci/branch-api-plugin/blob/32f0861d6b50a9cbf39789f1d713e6979d412e4e/src/main/resources/jenkins/branch/BranchNameContributor/buildEnv.properties#L23-L37. |
hi @jglick, thanks for getting back, I have two problems ultimately around multi-branch projects: 1Given say I have 3 branches "sub": "job:random-branch-test/master"
"sub": "job:random-branch-test/example1"
"sub": "job:random-branch-test/example1" Whats more if I create a branch called "sub": "job:random-branch-test/PR-2", None of these would be deterministic within AzureAD as it requires full qualified subject identifiers, i'd need to define every possible branch that would ever exist. 2The pull-request side could be game'd by a bad actor, if you are using AWS for example with a condition policy like:
This would pick up any branch called PR, which is why I was interested to see if we could potentially configure the oidc provider to allow pull requests to have a specific |
What I am not following is what
I am not following this concern either. The “bad actor” would need to have write access to your repository (not a fork).
Well, |
I'd like to be able to access the actual multibranch folder name:
Effectively I haven't found any environment variables for this But having some sort of programmable logic in the claim templates would mean I could potentially do something like:
|
That seems like something that should be added to
Something I would prefer to avoid. Given a standard environment variable for repository name or at least multibranch folder name (which I think would be broadly useful), then I think the proposed logic could be handled by a more declarative format. My previous proposal
would not handle the first clause if you do not actually want the value of
Your config could be something like
|
Thanks, I'll take a look at that see, if its simple enough to impl. The folder name is what I need for this particular use-case, and we actually have two multibranch projects using the same GH repo (with different config/pipelines) so the GITHUB_REPO for that would the same and I dont wont both jobs being able to get tokens (if the sub is
Yes, i think this would work 👍 |
You would probably want to define |
hey @jglick had a quick go at what this might look like, its rough currently but does the basics of allowing precedence based on environment variables. |
fix feedback :+1 switch @DataBoundConstructor back to original constructor Update src/main/java/io/jenkins/plugins/oidc_provider/IdTokenCredentials.java Co-authored-by: Francisco Javier Fernandez <[email protected]> fix missing import revert StringUtils.isNotBlank change pr feedback fix jelly template
hey @jglick if you get a chance could you take a look at the supporting PR jenkinsci/branch-api-plugin#344 many thanks! |
What feature do you want to see added?
When using build scoped claims on a multi-branch pipeline the
JOB_BASE_NAME
will always be present which makes the sub always unique per branch.Given the following template:
job:${JOB_NAME}
Would produce a sub like:
However depending on your target system this can or cannot be handled, for example AWS iam conditions are flexible enough:
However azuread federated credentials are not, it needs to be an explicit match meaning id need to configure the name of every branch (and pull request) ahead of it running.
Proposal
Can we allow the claims template to utilise some groovy scripts to do much deeper configuration.
This would allow us todo things like determine if the multi-branch job is triggered from a pull request where would could create similar subjects to githubs pull_request events, e.g:
repo:<orgName/repoName>:pull_request
but job bound likejob:random-branch-test:pull_request
.Given that the build templates are secured at the Jenkins administrator security level would this be acceptable?
Upstream changes
No response
The text was updated successfully, but these errors were encountered: