Skip to content

Commit 816a3a1

Browse files
committed
Hide CSRF configuration UI when only DefaultCrumbIssuer is available
1 parent 5312d24 commit 816a3a1

File tree

1 file changed

+16
-4
lines changed
  • core/src/main/resources/hudson/security/csrf/GlobalCrumbIssuerConfiguration

1 file changed

+16
-4
lines changed
Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,31 @@
11
package hudson.security.csrf.GlobalCrumbIssuerConfiguration
22

33
import hudson.security.csrf.CrumbIssuer
4+
import hudson.security.csrf.DefaultCrumbIssuer
45

5-
def f=namespace(lib.FormTagLib)
6+
def f = namespace(lib.FormTagLib)
67
def all = CrumbIssuer.all()
8+
def disableCsrf =
9+
hudson.security.csrf.GlobalCrumbIssuerConfiguration.DISABLE_CSRF_PROTECTION
710

8-
if (!all.isEmpty()) {
11+
def onlyDefaultIssuer =
12+
all.size() == 1 && all[0].clazz == DefaultCrumbIssuer
13+
14+
def showCsrfConfig = !onlyDefaultIssuer || disableCsrf
15+
16+
if (showCsrfConfig) {
917
f.section(title: _("CSRF Protection")) {
10-
if (hudson.security.csrf.GlobalCrumbIssuerConfiguration.DISABLE_CSRF_PROTECTION) {
18+
if (disableCsrf) {
1119
f.entry {
1220
p(raw(_('disabled')))
1321
p(_('unsupported'))
1422
}
1523
} else {
16-
f.dropdownDescriptorSelector(title: _("Crumb Issuer"), descriptors: all, field: 'crumbIssuer')
24+
f.dropdownDescriptorSelector(
25+
title: _("Crumb Issuer"),
26+
descriptors: all,
27+
field: 'crumbIssuer'
28+
)
1729
}
1830
}
1931
}

0 commit comments

Comments
 (0)