oidc-provider-plugin icon indicating copy to clipboard operation
oidc-provider-plugin copied to clipboard

add regex replace support to ClaimTemplate

Open LeoQuote opened this issue 1 year ago • 2 comments

Add regex replace support in claim template, introducing more possibility to claims, like extract repo and org name from it

fix #34

This could be a good supplement for #6 , allowing users to replace and recreate claims using existing environments.

Known issues, I'm still figuring out how to fix:

  • [x] 1. I dont know what should I do to make regex optional, since the signature of the ClaimTemplate Constructor is fixed and cannot create a second constructor
  • [x] 2. The default value did not show in the settings box.

Any suggestions are welcomed!

Testing done

  • unit test has been added
  • tried using the plugin in my jenkins 图片

it can replace the claim correctly, presenting jwt like

{
  "iss": "https://sa-jenkins.intra.xxx.com/oidc",
  "exp": 1703501635,
  "iat": 1703498035,
  "sub": "https://sa-jenkins.intra.xxx.com/",
  "build_number": 5,
  "org": "SA",
  "repo": "opa-policies"
}

it can fulfill my requirements.

Submitter checklist

  • [x] Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • [x] Ensure that the pull request title represents the desired changelog entry
  • [x] Please describe what you did
  • [x] Link to relevant issues in GitHub or Jira
  • [x] Link to relevant pull requests, esp. upstream and downstream changes
  • [x] Ensure you have provided tests - that demonstrates feature works or fixes the issue

LeoQuote avatar Dec 25 '23 09:12 LeoQuote