From e04fb0f09b3580239842bddf1495bfa86b1c40e5 Mon Sep 17 00:00:00 2001 From: kohsuke Date: Mon, 17 Dec 2007 00:44:02 +0000 Subject: [PATCH] adding sign-up support. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@6323 71c3de6d-444a-0410-be80-ed276b4c234a --- core/src/main/java/hudson/model/Hudson.java | 7 +++++ .../java/hudson/security/SecurityRealm.java | 27 ++++++++++++++++++- .../resources/hudson/model/Hudson/login.jelly | 8 +++++- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/hudson/model/Hudson.java b/core/src/main/java/hudson/model/Hudson.java index 7b84977930..fc286489fc 100644 --- a/core/src/main/java/hudson/model/Hudson.java +++ b/core/src/main/java/hudson/model/Hudson.java @@ -1847,6 +1847,13 @@ public final class Hudson extends View implements ItemGroup, Node req.getView(this,"_script.jelly").forward(req,rsp); } + /** + * Sign up for the user account. + */ + public void doSignup( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException { + req.getView(getSecurityRealm(),"signup.jelly").forward(req,rsp); + } + /** * Changes the icon size by changing the cookie */ diff --git a/core/src/main/java/hudson/security/SecurityRealm.java b/core/src/main/java/hudson/security/SecurityRealm.java index e580826d3a..0380ba4724 100644 --- a/core/src/main/java/hudson/security/SecurityRealm.java +++ b/core/src/main/java/hudson/security/SecurityRealm.java @@ -3,10 +3,12 @@ package hudson.security; import hudson.ExtensionPoint; import hudson.model.Describable; import hudson.model.Descriptor; +import hudson.model.Hudson; import hudson.util.DescriptorList; import org.acegisecurity.Authentication; import org.acegisecurity.AuthenticationManager; import org.springframework.context.ApplicationContext; +import org.kohsuke.stapler.Stapler; import java.util.Map; @@ -16,6 +18,11 @@ import java.util.Map; *

* New implementations should be registered to {@link #LIST}. * + *

+ * If additional views/URLs need to be exposed, + * an active {@link SecurityRealm} is bound to CONTEXT_ROOT/securityRealm/ + * through {@link Hudson#getSecurityRealm()}. + * * @author Kohsuke Kawaguchi * @sicne 1.160 */ @@ -35,12 +42,30 @@ public abstract class SecurityRealm implements Describable, Exten /** * Returns the URL to submit a form for the authentication. - * Normally there's no need to override this. + * There's no need to override this, except for {@link LegacySecurityRealm}. */ public String getLoginUrl() { return "j_acegi_security_check"; } + /** + * Returns true if this {@link SecurityRealm} allows online sign-up. + * This creates a hyperlink that redirects users to CONTEXT_ROOT/signUp, + * which will be served by the signup.jelly view of this class. + * + *

+ * If the implementation needs to redirect the user to a different URL + * for signing up, use the following jelly script as signup.jelly + * + *


+     * <st:redirect url="http://www.sun.com/" xmlns:st="jelly:stapler"/>
+     * 
+ */ + public final boolean allowsSignup() { + Class clz = getClass(); + return clz.getClassLoader().getResource(clz.getName().replace('.','/')+"/signup.jelly")!=null; + } + /** * Picks up the instance of the given type from the spring context. * If there are multiple beans of the same type or if there are none, diff --git a/core/src/main/resources/hudson/model/Hudson/login.jelly b/core/src/main/resources/hudson/model/Hudson/login.jelly index c664cf04c9..a80372d7c7 100644 --- a/core/src/main/resources/hudson/model/Hudson/login.jelly +++ b/core/src/main/resources/hudson/model/Hudson/login.jelly @@ -11,7 +11,7 @@ - Password + Password: @@ -20,6 +20,12 @@ $('j_username').focus(); + + +
+ Create an account if you are not a member yet. +
+
-- GitLab