From 70e1977f21cb75d58647349905a128ffdd3ee550 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Fri, 19 Apr 2013 14:06:48 -0700 Subject: [PATCH] Call attention to the fact that the security isn't enabled. This is deemed important because we ship Jenkins without security setting by default. --- .../diagnostics/SecurityIsOffMonitor.java | 38 +++++++++++++++++++ .../SecurityIsOffMonitor/message.jelly | 36 ++++++++++++++++++ .../SecurityIsOffMonitor/message.properties | 2 + 3 files changed, 76 insertions(+) create mode 100644 core/src/main/java/jenkins/diagnostics/SecurityIsOffMonitor.java create mode 100644 core/src/main/resources/jenkins/diagnostics/SecurityIsOffMonitor/message.jelly create mode 100644 core/src/main/resources/jenkins/diagnostics/SecurityIsOffMonitor/message.properties diff --git a/core/src/main/java/jenkins/diagnostics/SecurityIsOffMonitor.java b/core/src/main/java/jenkins/diagnostics/SecurityIsOffMonitor.java new file mode 100644 index 0000000000..23148724b2 --- /dev/null +++ b/core/src/main/java/jenkins/diagnostics/SecurityIsOffMonitor.java @@ -0,0 +1,38 @@ +package jenkins.diagnostics; + +import hudson.Extension; +import hudson.model.AdministrativeMonitor; +import jenkins.model.Jenkins; +import org.kohsuke.stapler.StaplerRequest; +import org.kohsuke.stapler.StaplerResponse; + +import java.io.IOException; + +/** + * Unsecured Jenkins is, well, insecure. + * + *

+ * Call attention to the fact that Jenkins is not secured, and encourage the administrator + * to take an action. + * + * @author Kohsuke Kawaguchi + */ +@Extension +public class SecurityIsOffMonitor extends AdministrativeMonitor { + @Override + public boolean isActivated() { + return !Jenkins.getInstance().isUseSecurity(); + } + + /** + * Depending on whether the user said "yes" or "no", send him to the right place. + */ + public void doAct(StaplerRequest req, StaplerResponse rsp) throws IOException { + if(req.hasParameter("no")) { + disable(true); + rsp.sendRedirect(req.getContextPath()+"/manage"); + } else { + rsp.sendRedirect(req.getContextPath()+"/configureSecurity"); + } + } +} diff --git a/core/src/main/resources/jenkins/diagnostics/SecurityIsOffMonitor/message.jelly b/core/src/main/resources/jenkins/diagnostics/SecurityIsOffMonitor/message.jelly new file mode 100644 index 0000000000..d757f6e441 --- /dev/null +++ b/core/src/main/resources/jenkins/diagnostics/SecurityIsOffMonitor/message.jelly @@ -0,0 +1,36 @@ + + + + +

+
+
+ + +
+ ${%blurb} +
+
+ diff --git a/core/src/main/resources/jenkins/diagnostics/SecurityIsOffMonitor/message.properties b/core/src/main/resources/jenkins/diagnostics/SecurityIsOffMonitor/message.properties new file mode 100644 index 0000000000..1ba45df729 --- /dev/null +++ b/core/src/main/resources/jenkins/diagnostics/SecurityIsOffMonitor/message.properties @@ -0,0 +1,2 @@ +blurb=Unsecured Jenkins allows anyone on the network to launch processes on your behalf. \ + Consider at least enabling authentication to discourage misuse. \ No newline at end of file -- GitLab