jenkins-rest
jenkins-rest copied to clipboard
Usage of Custom headers?
This is more of a question. Does the JenkinsClient support the ability to add custom headers? I'm not seeing that in the interface.
At my company, we require to have a specific header too authenticate for any traffic internally. So in order for me to talk to the jenkins server, I need to add a header.
Not currently supported but could certainly be added with not too much work if you wanted to knock things out.
Took a look at the JenkinsClient
return ContextBuilder
.newBuilder(new JenkinsApiMetadata.Builder().build())
.endpoint(endPoint)
.modules(allModules)
.overrides(overrides)
.buildApi(JenkinsApi.class);
I haven't really used jcloud before. How would you inject headers in this use case. Can you give some pointers on where this logic should live?
@darewreck54 I'd probably add something to the builder to take in a map of headers. Within that code path you can set those on the JenkinsAuthentication object. Then, within the JenkinsAuthenticationFilter, you can read any potential headers found within the JenkinsAuthentication object and apply them to the HttpRequest builder wtihin at the appropriate spot. Something like that should work. Keeping those headers in memory however, especially if they are holding creds, might not be the most secure thing in the world but if your use-case is secure enough then you will probably be alright.