jenkinsci / oidc-provider-plugin

OpenID Connect Provider Plugin for Jenkins
https://plugins.jenkins.io/oidc-provider/
MIT License
22 stars 13 forks source link

Support regex match and replace in claim template #34

Open LeoQuote opened 9 months ago

LeoQuote commented 9 months ago

What feature do you want to see added?

Currently only specific environment variables are available in claim template, users can join variables but cannot extract part of environment.

for example users can define aud claim as “Jenkins:${JOB_NAME}” but we cannot delete the tailing “main” and get pure org name and repo name in job_name like “Jenkins/foo/main”, which is typically in multi branch pipelines of GitHub repo.

my thought would be implementing a new claim template type , supporting following arguments:

  1. Original text like the other types, supporting macros just like other type
  2. Regex expression that used to match the original text, eg: “(\w+)/.*”
  3. Replacement that used to construct the final text, eg: “$1:jenkins” , $1 represents the first matched group.

Maybe related to #6

Upstream changes

No response

Are you interested in contributing this feature?

Yes