Created
September 21, 2025 11:47
-
-
Save jimklimov/f379805ffc02ae8d9f853b446e4bbf37 to your computer and use it in GitHub Desktop.
Jenkins CSRF config check
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // From https://community.jenkins.io/t/random-403-invalid-crumb-messages-through-out-jenkins/35619/4 | |
| // by @poddingue - Bruno Verachten, GSoC Mentors | |
| import jenkins.model.Jenkins | |
| import hudson.security.csrf.CrumbIssuer | |
| import jenkins.security.s2m.AdminWhitelistRule | |
| def j = Jenkins.instance | |
| println "=== Jenkins Security & CSRF Diagnostics ===" | |
| println "Jenkins URL: ${j.getRootUrl() ?: '(not set)'}" | |
| println "Security Realm: ${j.getSecurityRealm()?.class?.name ?: 'none'}" | |
| println "Authorization Strategy: ${j.getAuthorizationStrategy()?.class?.name ?: 'none'}" | |
| CrumbIssuer ci = j.getCrumbIssuer() | |
| if (ci) { | |
| println "Crumb issuer: ${ci.class.name}" | |
| println " - Crumb request field: ${ci.getCrumbRequestField()}" | |
| println " - Sample crumb: ${ci.getCrumb()}" | |
| } else { | |
| println "Crumb issuer: NONE (CSRF protection is disabled)" | |
| } | |
| def whitelist = j.getInjector().getInstance(AdminWhitelistRule) | |
| println "Master-to-Agent Access Control: ${whitelist.getMasterKillSwitch() ? 'DISABLED' : 'ENABLED'}" | |
| println "=== End ===" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment