Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passenger hangs on Request for ErrorDocument 401 with form authentication #2231

Open
CodeGuro opened this issue Nov 2, 2019 · 0 comments
Open

Comments

@CodeGuro
Copy link

CodeGuro commented Nov 2, 2019

I came across this issue when I was playing with phusion for a bit...

Consider the following configuration in apache...

		<Location "/secure">
			Require valid-user
			AuthName "top secret"
			AuthFormProvider wsgi
			AuthType form
			WSGIAuthUserScript /path/to/authenticator.py
			ErrorDocument 401 "/index"
			AuthFormMethod form_method
			AuthFormBody form_body
			AuthFormMimetype form_mimetype
			AuthFormUsername form_username
			AuthFormPassword form_passwd
			WSGIPassAuthorization On
		</Location>

The idea here being, I'm coupling apache-phusion form authentication from some custom script (authenticator.py) for an inline login, so that mod_auth_form handles authentication cookies for login sessions. When someone tries to access a sub-url www.example.com/secure/some_file, mod_auth_form would kick in and insert the 401 document for some other location (/index) served by passenger for an inline-login. The intent being that the authenticator script is run and, if successful, the previous request is forwarded to whatever secure sub location the client originally tried to access earlier.

Logging in with the correct credentials works fine - passenger forwards the request as expected. The issue happens with incorrect credentials. Namely, the POST request never returns and the browser/client just hangs on an eternal loading page (until phusion-passenger or apache is restarted). It's as if passenger connects to the socket but doesn't ever forward it to the WSGI application and instead hangs on to it forever. This behaviour does not happen when the ErrorDocument isn't served by passenger. This makes it quite annoying to work with because it'd mean I'd need to make at least 2 application groups... one served by passenger for general views and one served by plain WSGI for the inline login which serves the ErrorDocument views without going through passenger.

For reference (here are the docs), my authenticator script:

def check_password(environ, user, password):
    if user == 'tester':
        if password == 'tester':
            return True
        return False
    return None

...and the HTML served by the web-application, minimal example:

<html>
<body>
<form method="POST" action="" name="form_body">
User Name: <input name="form_username"><br>
Password: <input name="form_passwd" type="password"></br>
<input type="hidden" name="form_mimetype" value="application/x-www-form-urlencoded">
<input type="hidden" name="form_method" value="POST">
<input type="hidden" name="form_body" value="name1=value1&name2=value2">
<input type="submit" value="submit">
</form>
</body>
</html>

Also, this seems to be an issue exclusive to form authentication. The basic authentication doesn't cause the requests to hang.

@CodeGuro CodeGuro changed the title Passenger hangs on Request for ErrorDocument 401 with form_method Passenger hangs on Request for ErrorDocument 401 with form authentication Nov 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants