WordPress.org

Ready to get started?Download WordPress

Forums

Using SSL for login only (3 posts)

  1. Bill Dennen
    Member
    Posted 3 years ago #

    WordPress offers ways to enforce SSL on the login and backend.

    http://codex.wordpress.org/Administration_Over_SSL

    However, I've run into problems when trying to secure just the login, not the whole backend. That is:

    define('FORCE_SSL_ADMIN', false);
    define('FORCE_SSL_LOGIN', true);

    First, when using wp_loginout(), the link to the login page is HTTP, not HTTPS. That is, it links to: http://somesite.com/wp-login.php. The actual form on that page has a secure "action" parameter. So, the data is submitted securely. But, from the user's perspective, the login page is not secure, since wp-login.php is loaded via http and not https.

    Second, if you try to log in on wp-login.php and fail (incorrect username or password), the link at the top "Return to site..." links to HTTPS. I think it's reasonable to expect that link to go to HTTP.

    Is this working as designed?

    If you run with

    define('FORCE_SSL_ADMIN', true);

    these are not issues. That is, it seems to work as expected.

    Perhaps the problem is in wp-login.php. There is code in there to redirect from HTTP to HTTPS only if FORCE_SSL_ADMIN is true.

    // Redirect to https login if forced to use SSL
    if ( force_ssl_admin() && !is_ssl() ) {
            if ( 0 === strpos($_SERVER['REQUEST_URI'], 'http') ) {
                    wp_redirect(preg_replace('|^http://|', 'https://', $_SERVER['REQUEST_URI']));
                    exit();
            } else {
                    wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                    exit();
            }
    }
  2. Mvied
    Member
    Posted 3 years ago #

    I believe this is working as intended. You should only be using one or the other.

    From: http://codex.wordpress.org/Administration_Over_SSL

    FORCE_SSL_LOGIN is for when you want to secure logins so that passwords are not sent in the clear, but you still want to allow non-SSL admin sessions (since SSL can be slow).

    FORCE_SSL_ADMIN is for when you want to secure logins and the admin area so that both passwords and cookies are never sent in the clear. This is the most secure option.

  3. Bill Dennen
    Member
    Posted 3 years ago #

    Thanks for replying. I guess one problem is that using

    define('FORCE_SSL_LOGIN', true);

    doesn't work in the most secure way. The login page is still insecure, even though the form action is secure. So, the user does not get a "secure page" lock on the login page.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags