jenkins-control-plugin icon indicating copy to clipboard operation
jenkins-control-plugin copied to clipboard

How to add API token without credentials

Open luis-alves opened this issue 4 years ago • 13 comments

Hi, Jenkins is hosted in my company VPN, I don't need credentials to have access to the pipelines, so I don't have any to login. To get an API Token to place on the plugin setup, I need to login, but since I don't have the credentials I'm not able to do it. How can I solve this issue. Thanks

luis-alves avatar Dec 21 '20 22:12 luis-alves

I can have take a look in new year. You have no authentification in jenkins server configuration right?

MCMicS avatar Dec 22 '20 11:12 MCMicS

Yes, that is correct. I have no way to login my self into Jenkins or access to any other means of configuration. I can had that, Hudson in Netbeans adds all projects automatically in the Services tab, so there is a way to do it without the api token or data crumb.

luis-alves avatar Dec 22 '20 11:12 luis-alves

I can try it it in new year because im on holiday at this time. But i will look to it to use without given credentials

MCMicS avatar Dec 22 '20 11:12 MCMicS

I managed to make the plugin retrieve the data by simply replacing the post method by a simple get method. Unfortunately "Build on Jenkins" command does not work because it requires a post method and then it returns an error related with the Crumb data.

luis-alves avatar Jan 07 '21 09:01 luis-alves

Sorry for delay. I will look at this as soon as possible

MCMicS avatar Jan 07 '21 10:01 MCMicS

Sorry for the delay: Which Jenkins Version to you use?

Because Jenkins says:

Beginning with Jenkins 2.214 and Jenkins LTS 2.222.1, the "Enable Security" checkbox has been removed. Jenkins own user database is used as the default security realm.

So you also know which security settings is used? grafik

MCMicS avatar Jan 18 '21 18:01 MCMicS

@luis-alves It is not possible to use an authentification provider within jenkins? For security reason it is bette to use authetificated users. API token are currently available for users. There is an open feature to support Token for Jobs (https://issues.jenkins.io/browse/JENKINS-56465)

But for now I suggest to create user in jenkins and use the API Token instead because else you provide a crumb data which is changed often and not recommend more for API calls.

MCMicS avatar Jan 18 '21 19:01 MCMicS

@MCMicS I can't login because I don't have an account. I access Jenkins through a VPN, so the authentication is made in it, and Jenkins is totally opened. The version is Jenkins 2.263.1, and I don't have admin privileges to tell you which settings are currently set.

luis-alves avatar Jan 18 '21 22:01 luis-alves

Hi @luis-alves Can you provide a screenshot from you Jenkins landing page? Is there a logged-in user after you redirected from you VPN and proxy to jenkins?

It is possible to grant me temporary access to the server? Or can you share more details on your setup of proxy and jenkins

I can try to provide a build to test if still needed where I allow anonymous access to API id possible

But I think this will not work. But I investigate it currently. If not possible I close this in favor to use accounts for security reasons.

MCMicS avatar Aug 11 '23 16:08 MCMicS

Hi @luis-alves Jenkins recommend to use Token based for script (see https://www.jenkins.io/doc/book/security/csrf-protection/).

I've not found any solution except following:

  1. Allow only GET calls to list project. But then some features are missing (disabled) like Build and so on
  2. Ask for Crumb Issuer for anonymous access and use this
  3. Usage of ' https://github.com/jenkinsci/build-token-root-plugin' on Jenkins server and try to build with the created access token

In my opionion the secure way is the first. A dedicaterd userr for script access. If this is still not possible then try out the crumb way

Is the given setup still valid in your environment?

MCMicS avatar Aug 13 '23 16:08 MCMicS

Hello

How to configure the Jenkins plugin in IntelliJ IDEA to connect with a local Jenkins server?

what are the params for :

  • Servers address
  • Jenkins URL
  • Username
  • API-Token

doukhahmed avatar Oct 31 '23 09:10 doukhahmed

@doukhahmed Please do not post same questions twice; Answer found at: https://github.com/MCMicS/jenkins-control-plugin/discussions/529

MCMicS avatar Oct 31 '23 10:10 MCMicS

@MCMicS, sorry and thanks for the answer! :)

doukhahmed avatar Oct 31 '23 10:10 doukhahmed