Issue Details (XML | Word | Printable)

Key: JRA-7250
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Answered
Priority: Major Major
Assignee: Unassigned
Reporter: Jeff Turner [Atlassian]
Votes: 4
Watchers: 8
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
JIRA

Support for redirecting from HTTPS to HTTP

Created: 07/Jul/05 03:07 AM   Updated: 18/May/09 10:59 PM
Component/s: None
Affects Version/s: None
Fix Version/s: None

Time Tracking:
Not Specified

Issue Links:
Reference
 

Participants: Aine O'Riordan, Bernard Durfee, Bill Dennen, Brenden Bain [Atlassian], Erik S, Ian Daniel [Atlassian], Jeff Turner [Atlassian], Luis Herrera, Mark Chaimungkalanont [Atlassian], Reddy Duggempudi, Shalini Sharma, T Marshall and Torge Schmidt
Since last comment: 6 weeks, 4 days ago
Resolution Date: 24/May/06 01:09 AM
Labels:


 Description  « Hide
Often one wants some pages (eg. login page) to be protected via HTTPS, but then revert to plain HTTP for most pages, to avoid killing the server. The process of requiring HTTPS for some pages is described at:

http://confluence.atlassian.com/display/JIRA/Running+JIRA+over+SSL+or+HTTPS

however there doesn't seem to be a clean declarative way to force access of non-protected pages to revert to HTTP.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Bill Dennen added a comment - 10/Nov/05 07:43 PM
Does this same issue affect Confluence? Seems like it.

Is there any workaround?


Mark Chaimungkalanont [Atlassian] added a comment - 10/Nov/05 09:26 PM
Bill,

maybe I'm missing something but the solution at http://confluence.atlassian.com/display/JIRA/Running+JIRA+over+SSL+or+HTTPS doesn't work for you? Confluence should work the same way

Cheers

Mark C


Bill Dennen added a comment - 10/Nov/05 09:34 PM
There is a comment at the bottom of that page that says: "!)There does not seem to be an easy way to make subsequent pages revert to HTTP after logging in via HTTPS - see JRA-7250"

Basically, here's what I want:

1. user goes to wiki homepage (http)
2. user clicks "log in" (http)
3. user get redirected to secure version of login page (http->https)
4. user logs in over https
5. user goes on his or her merry way over http... doing everything else.

I followed the directions on that page and it actually broke our wiki completely. Backing out of those specific changes restored everything. I'll need to dig into this some more. But, from the comment on that page, it seems as though confluence won't work the way I want? should it? Thanks!


Bill Dennen added a comment - 11/Nov/05 09:03 AM
I just downloaded a clean version of Confluence (standalone) and followed all of the following steps:

1. install and check to make sure it works. OK!
2. enable SSL access on port 8443 following these instructions:
http://confluence.atlassian.com/display/JIRA/Running+JIRA+over+SSL+or+HTTPS

3. check to make sure it works – it does. OK! Both http (8080) and http (8443) work.

4. follow steps under the heading: "Requiring HTTPS for certain pages"

This kills the server. Neither 8080 or 8443 work. Both report: HTTP Status 404 - /

?


Jeff Turner [Atlassian] added a comment - 13/Nov/05 09:42 PM
Bill,

Works for me with JIRA Standalone. Please could you create a new issue on https://support.atlassian.com and attach your web.xml. Also please list your environment (eg. are you running behind Apache?) and attach the Tomcat/Apache log file, so we can see what's going on behind that 404 error.

Cheers,
Jeff


Erik S added a comment - 06/Jan/06 04:00 PM
I've been looking into how to do this for our installation, as we want SSL for login but don't like the performance hit for viewing other pages. We are running behind apache, so I'd like a solution that works in that configuration.

Some interesting sites regarding this:
http://www.rollerweblogger.org/wiki/Wiki.jsp?page=RollerSecureLogins

and the "How can I switch between HTTP and HTTPS in relative hyperlinks?" question on
http://httpd.apache.org/docs/2.0/ssl/ssl_faq.html


Jeff Turner [Atlassian] added a comment - 08/Jan/06 11:58 PM
Protecting only the login page is not a huge security gain if cookies are use to automatically log one in. I've added some thoughts to a related issue, "Restrict cookie-based login to SSL users":

http://jira.atlassian.com/browse/JRA-8974


Erik S added a comment - 11/Jan/06 11:18 AM
I'm having a hard time remembering any SSL site that has a "remember me" function. To me it is a completely acceptable solution to have an administrative option to disable the "remember me" function if one wants to use SSL just for the login. Furthermore, the modern web browsers will all auto remember the login and password fields for you, so if you don't have the "remember me" function it is only one "extra" click for a user to gain access.

Jeff Turner [Atlassian] added a comment - 11/Jan/06 07:11 PM
In JIRA 3.4.x there is a 'jira.option.allowcookies' property that can be set in jira-application.properties.

Assuming JIRA had a cookie handling option:

Cookie-based login: Allow ( ) Only for SSL ( ) Disable

Would that keep people happy? Is anyone actually after the original subject of this issue, redirecting from https to http?


Erik S added a comment - 12/Jan/06 09:04 AM
Yes, I am after the redirection from https to http.

In an ideal setup (for me) I'd like to see this:

  1. All login pages force the use of HTTPS
  2. After a user has logged in, all other pages are HTTP
  3. Once a user logs out, or is logged out via the activity timeout, they would have to log back in via HTTPS

What I meant by my prior comment is that as long as the above can happen I don't care whether or not the user gets to use a cookie for login (if they do then great, but if not it isn't a big deal).

In addition to the above setup, I can imagine there are clients who would like all pages to served via HTTPS.


Jeff Turner [Atlassian] added a comment - 12/Jan/06 10:16 PM
This may be possible with the UrlRewriteFilter in JIRA (configured in WEB-INF/urlrewrite.xml).

Reddy Duggempudi added a comment - 01/Feb/06 08:05 PM
I am interesting in this option of "Force only login pages to HTTPS and then revert everything back to HTTP".
Can you look into this and suggest a workaround until an elegant solution s found.

Bernard Durfee added a comment - 03/Feb/06 12:24 PM
This seems like it should be an important thing to resolve. I too would like SSL on just the login screen to protect the password.

Bernard Durfee added a comment - 03/Feb/06 04:11 PM
I haven't fully tested this yet, but here is a possible workaround:
  1. Make sure the user's password is encrypted by modifying loginform.jsp and changing the action in the login form to...
    action="https://<%= request.getServerName() %><%= request.getContextPath() %>/redirect-to-http.jsp"
  2. Then, once the filter is finished authenticating, use a simple JSP to redirect users back to HTTP...
    redirect-to-http.jsp
    <html>
    <head>
        <meta http-equiv="refresh" content="0; url=http://<%= request.getServerName() %><%= request.getContextPath() %>">
    </head>
    <body>
    Logging in... <a href="http://<%= request.getServerName() %><%= request.getContextPath() %>">Please, click here if not redirected</a>
    </body>
    </html>

The above will at least ensure that the user's password is sent using HTTPS. All other communication between the browser and server are unencrypted, including session cookies, login cookies, password change forms, etc. So this workaround only represents a small solution to the large problem of improving JIRA/Confluence security without simply requiring full SSL for all URLs.

This is the way lot's of sites work. The reason for the client redirect is to prevent the browser from warning the user about the redirect from HTTPS to HTTP. The other alternative, which Amazon seems to use, is to make sure that when the login is complete, all of the links on the next page are absolute, so any click will bring the user back to HTTP.


Mark Chaimungkalanont [Atlassian] added a comment - 06/Feb/06 11:25 PM
Thanks for the input. We'll take a look if we can do something about it

Bernard Durfee added a comment - 31/Mar/06 12:58 PM
Also, in the loginfform.jsp file the os_destination hidden input needs to be modified to redirect the user over HTTPS to the redirect-to-http.jsp page. This will keep the os_destination functioning while keep the browser mostly happy. The problem with the line below is that it acts strange when the user mistypes their password. I haven't had time to fix it.

<input type="hidden" name="os_destination" value="https://<%= request.getServerName() %><%= request.getContextPath() %>/redirect-to-http.jsp?os_destination=<%= (request.getParameter("os_destination") == null ? "/secure/" : TextUtils.htmlEncode(request.getParameter("os_destination"))) %>">

The Yahoo way, which is I think a pretty good solution is to...

  1. The 'action' on the login form should submit to HTTPS to send the password over SSL.
  2. The server can't send a redirect to HTTP because the browser will complain. So the server needs to redirect the user to a page, over HTTPS, that contains a meta-refresh or JavaScript, that redirects the user back to HTTP.

Bernard Durfee added a comment - 14/Apr/06 08:29 AM
Thanks to Andrew over on the Confluence side of this issue http://jira.atlassian.com/browse/CONF-4116 here is a clean method using mod_rewrite...

1) Change the action URL in /includes/loginform.jsp to send the password over HTTPS.

https://jira.sln.suny.edu<%= request.getContextPath() %>/login.jsp

2) Create a file /redirect-to-http.jsp, that redirects the user to HTTP via JavaScript, so browser won't complain about the HTTPS to HTTP switch.

<%
  final String redirectURL = request.getParameter("redirect-to");
%>

<html>
  <head>
    <script language="JavaScript">
      window.location.replace("<%= redirectURL %>");
    </script>

    <meta http-equiv="Refresh" content="0; url=<%= redirectURL %>">
  </head>
  <body>
    <a href="<%= redirectURL %>">Please, click here if not automatically redirected within a few seconds...</a>
  </body>
</html>

3) Create a mod_rewrite rule to send users to the redirect page when they shouldn't be using HTTPS.

<VirtualHost 12.34.56.78:443>
ServerName jira.myserver.com

RewriteEngine On

# Force all non-login pages back to non-SSL
RewriteCond %{REQUEST_URI} !^/redirect-to-http.jsp
RewriteCond %{REQUEST_URI} !^/login.jsp
RewriteCond %{REQUEST_URI} !^/images/
RewriteCond %{REQUEST_URI} !^/download/userResources/logo
RewriteCond %{REQUEST_URI} !\.(css|js)$
RewriteRule (.*) https://jira.myserver.com/redirect-to-http.jsp?redirect-to=http://jira.myserver.com$1 [R,L]

...
</VirtualHost>

...that should keep all interactions with login.jsp under HTTPS, while bouncing the user back to HTTP for other pages, without an annoying browser warning.


Jeff Turner [Atlassian] added a comment - 24/May/06 01:09 AM
I think Bernard's answer pretty much covers this.

Aine O'Riordan added a comment - 30/May/06 11:35 PM
Can you provide a solution for tomcat? I believe the mod_rewrite rule above can only be applied to Apache. Thanks.

Torge Schmidt added a comment - 14/Jun/06 05:16 AM
Not resolved IMHO! The solution in http://jira.atlassian.com/browse/CONF-4116 requires apache to handle confluence requests, which is not what one should want.

Luis Herrera added a comment - 13/Nov/06 01:17 PM
Here's what I did without apache:

Modified WEB-INF/urlrewrite.xml by adding the following rule:

<urlrewrite>
    <rule>
        <name>Force all non-login pages back to non-SSL</name>
        <note>Assumes JIRA is running under context /jira</note>
        <condition type="scheme" operator="equal">https</condition>
        <condition type="request-uri" operator="notequal">/jira/redirect-to-http.jsp</condition>
        <condition type="request-uri" operator="notequal">/jira/login.jsp</condition>
        <condition type="request-uri" operator="notequal">/jira/images/.*</condition>
        <condition type="request-uri" operator="notequal">.*\.css</condition>
        <condition type="request-uri" operator="notequal">.*\.js</condition>
        <!-- 'from' url's are relative to the context. -->
        <from>(.*)</from>
        <to type="redirect" last="true">/jira/redirect-to-http.jsp?redirect-to=$1</to>
    </rule>
...

Modified the following filter mapping in WEB-INF/web.xml :

<filter-mapping>
        <filter-name>UrlRewriteFilter</filter-name>
        <!-- <url-pattern>/secure/IssueNavigator.jspa</url-pattern> -->
        <url-pattern>/*</url-pattern>
    </filter-mapping>

My /redirect-to-http.jsp is a little different, but same idea. I did almost the same for Confluence, except I had to download urlrewrite-2.6.0.jar to WEB-INF\lib and create WEB-INF/urlrewrite.xml with one rule with similar settings. One catch though, the "from" pattern has to be ^(.*)$ because otherwise I got strange results.


T Marshall added a comment - 29/Oct/08 05:49 PM
The following seems to have stopped working in Jira 3.13:

1) Change the action URL in /includes/loginform.jsp to send the password over HTTPS.

https://jira.sln.suny.edu<%= request.getContextPath() %>/login.jsp

Can anyone suggest another method to redirect the login page (only) to HTTPS?


Ian Daniel [Atlassian] added a comment - 29/Oct/08 11:51 PM
Something to consider for anyone thinking that just using SSL on the login page will offer a reasonable level of security: Why you need https everywhere (from CONF-4116, the Confluence equivalent of this issue).

Brenden Bain [Atlassian] added a comment - 03/Nov/08 02:00 AM - edited
Hello T Marshall,

The following seems to have stopped working in Jira 3.13:

1) Change the action URL in /includes/loginform.jsp to send the password over HTTPS.

https://jira.sln.suny.edu<%= request.getContextPath() %>/login.jsp

Can anyone suggest another method to redirect the login page (only) to HTTPS?

The login page is now rendered in two different ways. In addition to the change above you will need to:

  1. Open WEB-INF/classes/templates/jira/dashboard/macros.vm
  2. In the #macro (loginform) macro, change the <form method="POST" action="${baseurl}/login.jsp" name="loginform"> to something like <form method="POST" action="https://jira.sln.suny.edu${baseurl}/login.jsp" name="loginform">.

This should get Jira redirecting to the correct login page. I am not sure if the URL rewriting still works. I'll leave this as an exercise for the reader.

Hope this helps,
Brenden.


Shalini Sharma added a comment - 18/May/09 10:59 PM
Hi ,

Did the below mentioned changes and were able to implement HTTPS for just login page for JIRA.This was implemented in 3.13

1) Create a JSP page named "redirect-to-http.jsp" that redirects the user to HTTP via JavaScript, so browser won't complain about the HTTPS to HTTP switch.

<%
final String redirectURL = request.getParameter("os_destination");
%>

<html>
<head>
<script language="JavaScript">
window.location.replace("<%= redirectURL %>");
</script>

<meta http-equiv="Refresh" content="0; url=<%= redirectURL %>">
</head>
<body>
<a href="<%= redirectURL %>">Please, click here if not automatically redirected within a few seconds...</a>
</body>
</html>

2.)Modify the following lines in the file "/atlassian-jira/includes/loginform.jsp" with the text as specified below:

<form method="POST" action="{https url}<%= request.getContextPath() %>/login.jsp" name="loginform">

  • - - - - -
  • - - - - -

<input type="hidden" name="os_destination" value="http://<%= request.getServerName() %>:{http port}<%= request.getContextPath() %>/redirect-to-http.jsp?os_destination=<%= (request.getParameter("os_destination") == null ? "/secure/Dashboard.jspa" : TextUtils.htmlEncode(request.getParameter("os_destination"))) %>">

3. Modify the following lines in the file "/atlassian-jira-enterprise-3.13-standalone/atlassian-jira//login.jsp" with the text as specified below:

if (request != null)

{ response.sendRedirect(request.getContextPath() + "login.jsp"); return; }