Redirect to a custom page after successful login in jenkins using plugin

1,838 views
Skip to first unread message

swastb

unread,
Oct 30, 2013, 9:18:42 AM10/30/13
to jenkin...@googlegroups.com
Hi all,

Im badly looking for this answer. Is it possible to redirect to a custom page after successful login in jenkins. Im able to write a custom authorization plugin. But after successful authentication there has to be an intermediate page between login page and views. Is it possible to achieve this using plugin?

Sandell, Robert

unread,
Oct 30, 2013, 10:42:44 AM10/30/13
to jenkin...@googlegroups.com

I guess you could do a semi hack and implement a PluginServletFilter [1] that looks at the referrer field of the http request and if that is the login form redirect the request to your custom page.

The normal case for Jenkins is to redirect the user to whatever page it came from before going to the login form, so you’d loose that unless the filter also took a look at where the request was going.

 

[1] https://wiki.jenkins-ci.org/display/JENKINS/Extension+points#Extensionpoints-hudson.util.PluginServletFilter

 

 

Robert Sandell

Software Tools Engineer - SW Environment and Product Configuration

Sony Mobile Communications

 

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Jesse Glick

unread,
Oct 30, 2013, 10:52:23 AM10/30/13
to jenkin...@googlegroups.com
On Wed, Oct 30, 2013 at 9:18 AM, swastb <swast...@gmail.com> wrote:
> after successful authentication there has to be an intermediate page between login page and views.

Did you try overriding SecurityRealm.getAuthenticationGatewayUrl?
Would not be straightforward, since you would need to provide an
alternate POST destination URL that would handle ‘j_username’,
‘j_password’, and optionally ‘remember_me’ and ‘from’, but in
principle it could work.

swastika basu

unread,
Oct 30, 2013, 12:28:31 PM10/30/13
to jenkin...@googlegroups.com
Thanks a lot Robert and Jesse.. I will try with both of the options. I will update once done.. 


--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-dev/Tr1Ln3VK2g0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-de...@googlegroups.com.

swastb

unread,
Dec 4, 2013, 6:49:31 AM12/4/13
to jenkin...@googlegroups.com
Was able to resolve this issue with jenkins deployed in jetty or in tomcat as ROOT.war . Sorry for updating so late. Thanks a lot to Robert and Jesse. I did the following

1.  overridden getAuthenticationGatewayUrl
  @Override
public String getAuthenticationGatewayUrl() {
return "securityRealm/selectValues";
}
2. Added a new method as 
    doSelectValues(StaplerRequest req, StaplerResponse rsp,@Header("Referer") final String referer)
  {
      here redirected to my login page.. 
          // save the login userid and password in session
          if (req.getUserPrincipal() == null) {
rsp.sendRedirect("login");
return;
}
  }

3. Added own custom login.jelly where added own j_username,j_password,from as hidden variable which im populating in my Realm code with the values which came from original login page. The login.jelly post is being redirected to j_acegi_security_check. 

Is there any wrong with this approach? Because facing one issue, i,e when i deploy the jenkins.war in tomcat without renaming to ROOT.war, the browser fails with 404 error after login, it tries to reach jenkins/securityRealm/j_acegi_security_check without going to authentication. I couldn't do much on  PluginServletFilter , since not much confident on groovy script.

On Wednesday, 30 October 2013 21:58:31 UTC+5:30, swastb wrote:
Thanks a lot Robert and Jesse.. I will try with both of the options. I will update once done.. 
On Wed, Oct 30, 2013 at 8:12 PM, Sandell, Robert <Robert....@sonymobile.com> wrote:

I guess you could do a semi hack and implement a PluginServletFilter [1] that looks at the referrer field of the http request and if that is the login form redirect the request to your custom page.

The normal case for Jenkins is to redirect the user to whatever page it came from before going to the login form, so you’d loose that unless the filter also took a look at where the request was going.

 

[1] https://wiki.jenkins-ci.org/display/JENKINS/Extension+points#Extensionpoints-hudson.util.PluginServletFilter

 

 

Robert Sandell

Software Tools Engineer - SW Environment and Product Configuration

Sony Mobile Communications

 

From: jenkin...@googlegroups.com [mailto:jenkinsci-dev@googlegroups.com] On Behalf Of swastb
Sent: den 30 oktober 2013 14:19
To: jenkin...@googlegroups.com
Subject: Redirect to a custom page after successful login in jenkins using plugin

 

Hi all,

Im badly looking for this answer. Is it possible to redirect to a custom page after successful login in jenkins. Im able to write a custom authorization plugin. But after successful authentication there has to be an intermediate page between login page and views. Is it possible to achieve this using plugin?

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.

To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-dev+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-dev/Tr1Ln3VK2g0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-dev+unsubscribe@googlegroups.com.

swastb

unread,
Dec 5, 2013, 11:01:24 AM12/5/13
to jenkin...@googlegroups.com
It was my mistake in the login page because of which issue was occurring. Resolved it. The authentication and authorization plugin is working fine. Thanks a lot !!!
Reply all
Reply to author
Forward
0 new messages