Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

status code: 403, reason phrase: Forbidden #469

Open
ToShared opened this issue Aug 31, 2020 · 9 comments
Open

status code: 403, reason phrase: Forbidden #469

ToShared opened this issue Aug 31, 2020 · 9 comments

Comments

@ToShared
Copy link

ToShared commented Aug 31, 2020

JenkinsServer jenkins = new JenkinsServer(new URI("url"), JENKINS_USERNAME, JENKINS_PASSWORD);
if (jenkins.isRunning()) { jenkins.getJob(JENKINS_JOB).build(); System.out.println(jenkins.getJob(JENKINS_JOB).getLastBuild().details().getResult()); }
i set the correct username and password. but still status code: 403, reason phrase: Forbidden

the jenkins user is super admin

@ToShared
Copy link
Author

I solved this problem
The higher version of Jenkins opens CRFS by default
run this shell hudson.security.csrf.GlobalCrumbIssuerConfiguration.DISABLE_CSRF_PROTECTION = true

@Master-An
Copy link

@ToShared Where should I run that shell command?

@cmoulliard
Copy link

Where should I run that shell command?

Here http://localhost:8080/script

@pinguo-zhouwei
Copy link

To disable CSRF, it can be done with groovy, open "Manage Jenkins" / "Script Console"

import jenkins.model.Jenkins
def instance = Jenkins.instance
instance.setCrumbIssuer(null)

Source: https://stackoverflow.com/a/57869141

@Likqez
Copy link

Likqez commented Feb 20, 2021

Problem persists after executing both scripts on 2,280. Any updates?

@WilliamChen-luckbob
Copy link

New feedback, I'm using Jenkins version 2.289.1, met the same issue and solved by running shell
hudson.security.csrf.GlobalCrumbIssuerConfiguration.DISABLE_CSRF_PROTECTION = true
thanks a lot!

@phene
Copy link

phene commented Feb 16, 2022

Why do people think disabling CSRF protection is an acceptable workaround? We should not have to reduce our security posture just to use this API client.

@szylmzs
Copy link

szylmzs commented Nov 9, 2022

will this project update for CSRF?
I meet same issue when build job

@szylmzs
Copy link

szylmzs commented Nov 9, 2022

resolved
generate a user token from jenkins panel and new JenkinsServer() with username and token

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

No branches or pull requests

8 participants