The user login block has an unusual behavior, in that it's #action is not fixed. Rather, it POSTs the password to URLs like /node/1?destination=node/1. As a result it can't currently be matched by a securepages pattern. The usual workaround is to disable the login block, and instead provide a secure link to example.com/user.
This simple patch uses hook_form_alter to fix the login block.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | securepages_login_block.patch-new.txt | 547 bytes | tolimar |
| #2 | secure_login_block_securepages.module.patch | 593 bytes | ñull |
| securepages_login_block.patch.txt | 618 bytes | grendzy |
Comments
Comment #1
ñull commentedThis patch is not sufficient for certain circumstances. I noticed that the login block is still "unsafe" on access denied.
Comment #2
ñull commentedAttached a modification the seems to correct the problem.
Comment #3
ñull commentedComment #4
mcgyver5 commentedthe patch does a search for "http" and replaces it with "https" I suspect most people will have relative paths and so the patch will fail as it did for us.
Comment #5
shap commentedOn the site that I am currently assembling, I adopted the following approach:
1. Restrict the login block to the main page.
2. Add "user" (as opposed to "user/*") to the list of protected pages.
The latter was good enough to catch attempts to go to site/user and site/. In the default setup, those both offer a login page. Obviously I'm going to change the front page, but I will probably have a login link that simply links to [site]/user.
This approach made it unnecessary to protect the login form specifically, since the default "post" action posts to the "current" site.
One thing I have not (yet) checked. My current site does not have base_url set. If that is set, it may get placed in the post action for the user-login form, and then I'll have to do something about it.
Comment #6
drdrup commentedshap: What do you mean by "1. Restrict the login block to the main page."?
Is it by setting the "User login" block to "Show on only the listed pages" and adding "" to the list of Pages?
[BTW: by doing so, I thought that the "User login" block WILL show in the home (main) page, but I see that it is not so. The blcok does not show at all; Why?]
Or did you mean "Restrict the login block so it will ot show on the main page"?
[This thread was marked as 4.7.x-1.x-dev; I am now using 5.x-1.x-dev (2007.06.18) so I changed the version in the project info. If it is indeed for 4.7.x, please change it back, and I am sorry for my confusion]
Comment #7
tolimar commentedHi!
Many thanks for the patch; solved the problem for me. However, to get it to work with 5.x-1.7 I needed to adopt it a bit. It's attached; maybe it's usefull for someone else?
Best regards,
Alexander
Comment #8
grendzy commentedsecurepages_prevent_hijack is now available for D5, which provides this enhancement as a module.
Comment #10
gittosj commentedI had a custom login block which I'd patched together from the work of several other users and wanted to keep so I tweaked it to submit via https - i"m sure purists won't like the fact that users are unaware that its submitted via a secure connection - I'm just happy its a bit more secure. Let me know if you can spot any flaws but it works for me and does use SSL as well as being (IMHO) prettier and easier than the default login block:
Comment #11
AlexisWilke commentedThank you tolimar!
Adding 3 lines of code to the Secure Pages is more sensible than adding yet another module!
Alexis