Skip to content
This repository has been archived by the owner on Jan 21, 2024. It is now read-only.

Conversation

Constantin07
Copy link

This PR is to address the issue in jenkinsci/docker-agent#701 .

It's doesn't break existing functionality (use of only JENKINS_SECRET).

Copy link
Member

@oleg-nenashev oleg-nenashev left a comment

Choose a reason for hiding this comment

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

Thanks for the pull request @Constantin07 ! It would be a nice improvement. It will not work as is, because CRUMB is hardcoded. E.g. see https://support.cloudbees.com/hc/en-us/articles/219257077-CSRF-Protection-Explained which explains how to get it

I would also suggest using JENKINS_API_TOKEN as a variable name to encourage people to use it instead of the password. CC @Wadeck

README.md Outdated Show resolved Hide resolved
jenkins-slave Outdated Show resolved Hide resolved
jenkins-slave Outdated Show resolved Hide resolved
Copy link
Member

@oleg-nenashev oleg-nenashev left a comment

Choose a reason for hiding this comment

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

Wdyt about renaming JENKINS_PASSWORD to JENKINS_API_TOKEN ?

@Constantin07
Copy link
Author

Constantin07 commented Jan 7, 2019

@oleg-nenashev done.

Tested locally - slave successfully connects to master using username/password.

jenkins-slave    | Warning: JnlpProtocol3 is disabled by default, use JNLP_PROTOCOL_OPTS to alter the behavior
jenkins-slave    | Jan 07, 2019 10:19:11 AM hudson.remoting.jnlp.Main createEngine
jenkins-slave    | INFO: Setting up agent: jenkins-slave
jenkins-slave    | Jan 07, 2019 10:19:11 AM hudson.remoting.jnlp.Main$CuiListener <init>
jenkins-slave    | INFO: Jenkins agent is running in headless mode.
jenkins-slave    | Jan 07, 2019 10:19:11 AM hudson.remoting.Engine startEngine
jenkins-slave    | INFO: Using Remoting version: 3.27
jenkins-slave    | Jan 07, 2019 10:19:11 AM hudson.remoting.Engine startEngine
jenkins-slave    | WARNING: No Working Directory. Using the legacy JAR Cache location: /root/.jenkins/cache/jars
jenkins-slave    | Jan 07, 2019 10:19:12 AM hudson.remoting.jnlp.Main$CuiListener status
jenkins-slave    | INFO: Locating server among [http://jenkins_master:8080]
jenkins-slave    | Jan 07, 2019 10:19:12 AM org.jenkinsci.remoting.engine.JnlpAgentEndpointResolver resolve
jenkins-slave    | INFO: Remoting server accepts the following protocols: [JNLP4-connect, Ping]
jenkins-slave    | Jan 07, 2019 10:19:12 AM hudson.remoting.jnlp.Main$CuiListener status
jenkins-slave    | INFO: Agent discovery successful
jenkins-slave    |   Agent address: jenkins_master
jenkins-slave    |   Agent port:    50000
jenkins-slave    |   Identity:      bf:27:e3:8d:fb:89:a5:6d:19:1e:67:b0:92:5f:f5:11
jenkins-slave    | Jan 07, 2019 10:19:12 AM hudson.remoting.jnlp.Main$CuiListener status
jenkins-slave    | INFO: Handshaking
jenkins-slave    | Jan 07, 2019 10:19:12 AM hudson.remoting.jnlp.Main$CuiListener status
jenkins-slave    | INFO: Connecting to jenkins_master:50000
jenkins-slave    | Jan 07, 2019 10:19:12 AM hudson.remoting.jnlp.Main$CuiListener status
jenkins-slave    | INFO: Trying protocol: JNLP4-connect
jenkins-slave    | Jan 07, 2019 10:19:13 AM hudson.remoting.jnlp.Main$CuiListener status
jenkins-slave    | INFO: Remote identity confirmed: bf:27:e3:8d:fb:89:a5:6d:19:1e:67:b0:92:5f:f5:11
jenkins-slave    | Jan 07, 2019 10:19:15 AM hudson.remoting.jnlp.Main$CuiListener status
jenkins-slave    | INFO: Connected

@syndbg
Copy link

syndbg commented Mar 11, 2019

@Constantin07 Great work!

@oleg-nenashev It would be great if this gets merged and published in DockerHub.

@jglick
Copy link
Member

jglick commented Apr 22, 2019

This seems like a bad idea. You are replacing a limited token good only for connecting this agent with a general personal access token which, if compromised, could be abused in various ways. What exactly is the use case here?

@dduportal
Copy link
Contributor

I'm closing this PR for the following reasons:

  • Even if the fix is well explained, the use case is not clearly defined (what is the problem do you want to solve?)
  • This PR did not receive an answers since years
  • There are code conflicts: the PR uses a really old and outdated code.

Of course, feel free to reopen it if you feel it should be reviewed and merged (but you'll have to describe the initial problem and solve the merge conflicts).

@jglick
Copy link
Member

jglick commented Nov 28, 2022

The use case I can think of is that you are configuring the controller via JCasC including a static agent, and wish to be able to reconstruct the setup from scratch (with a freshly generated $JENKINS_HOME/secrets/ directory). But then I think you would still need to use custom scripting, at least pending jenkinsci/configuration-as-code-plugin#1830, in which case you may as well script the retrieval of the agent HMAC as well.

The better solution would be to deprecate the agent HMAC generally. Instead each newly created agent would get a randomly generated connection token persisted as a (Secret) field in the agent definition; from JCasC you could set a specific token value drawn from the usual sources (e.g., Vault). @daniel-beck @Wadeck do you know if this idea is tracked anywhere?

@Wadeck
Copy link

Wadeck commented Nov 29, 2022

=> https://issues.jenkins.io/browse/JENKINS-70168 just created
It was discussed inside SECURITY tracker but it should be public.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants