latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Remote Auth Not Accepting Username / Password

Home Forums Community Forum Remote Auth Not Accepting Username / Password

This topic contains 10 replies, has 3 voices. Last updated by  Cristián Lávaque 3 years, 7 months ago.

Topic Author Topic
Posted: Saturday May 18th, 2013 at 11:14 am #50168

I’ve followed the instructions on setting up Remote Auth files/downloads but for some reason, when the login-box appears, it will not accept my username and password.

This happens in iTunes (where I have set up an xml file in the protected directory) and when I simply enter a URL to protected file in the browser. For instance something like:

http://www.site.com/?s2member_file_remote=yes&s2member_file_inline=yes&s2member_file_download=testshow1.mp3

I am able to log in with my user name and password to my site, so I know that is OK. It’s just a probilem when it comes to Remote Auth.

List Of Topic Replies

Viewing 10 replies - 1 through 10 (of 10 total)
Author Replies
Author Replies
Posted: Saturday May 18th, 2013 at 4:27 pm #50188

Also, I download the s2Member® Server Scanner and everything is coming up OK. Not sure where I’ve gone wrong here. :(

Posted: Monday May 20th, 2013 at 1:12 pm #50230

Sorry to keep bumping these thread but really need some help. The whole reason I purchased S2member pro was because of its ability to work with protected files for a membership podcast.

Posted: Tuesday May 21st, 2013 at 5:09 am #50274
Bruce
Username: Bruce
Staff Member

Thank you for reporting this important issue.

I’m very sorry for the delay in response.

Could you send us a Dashboard login so we can take a look at your setup?

See: s2Member® » Private Contact Form

Let us know here when you’ve done that.

Posted: Tuesday May 21st, 2013 at 1:40 pm #50301

Thanks for the reply!

I have submitted the form.

Posted: Wednesday May 22nd, 2013 at 4:25 am #50334
Bruce
Username: Bruce
Staff Member

Details Received.

I logged in and I see the problem. I’ll see if I can find the solution.

Posted: Wednesday May 22nd, 2013 at 5:45 am #50335
Bruce
Username: Bruce
Staff Member

Investigation Completed.

I talked with Jason (lead developer) about this and we came to the realization that this is an issue with the certain setup you have on your server. For some reason your PHP_AUTH_USER and PHP_AUTH_PW server varibles (which should be set when a User puts in their Username/Password on the prompt) is not being set in PHP. It is, however, being set in Apache, and we found a way to use this to add the values to the $_SERVER array.

To do this I added these two lines to your WordPress .htaccess file:

RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

This gives us a PHP $_SERVER variable that contains the information from the prompt. Right now s2Member is not capable of using this variable, so I also added the following code to your s2-hacks.php file to make the use of this variable possible:

function s2hack_remote_auth_write_server_vars() {
	if (isset($_SERVER['HTTP_AUTHORIZATION']) && preg_match('/Basic\s+(.*)$/i', $_SERVER['HTTP_AUTHORIZATION'], $matches)) {
		list($name, $password) = explode(':', base64_decode($matches[1]));
		$_SERVER['PHP_AUTH_USER'] = esc_html($name);
		$_SERVER['PHP_AUTH_PW'] = esc_html($password);
	}
	if (isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION']) && preg_match('/Basic\s+(.*)$/i', $_SERVER['REDIRECT_HTTP_AUTHORIZATION'], $matches)) {
		list($name, $password) = explode(':', base64_decode($matches[1]));
		$_SERVER['PHP_AUTH_USER'] = esc_html($name);
		$_SERVER['PHP_AUTH_PW'] = esc_html($password);
	}
}

add_action('ws_plugin__s2member_during_check_file_remote_authorization_before', 's2hack_remote_auth_write_server_vars');
We will be adding a check for this variable in the next maintenance release of s2Member, at which point you can remove this code from your s2-hacks.php file. You will, however, need to leave the code in your .htaccess file for s2Member to work correctly.
In the future, if another User has this problem as well, you need to put the two lines I put in this User’s main .htaccess file into yours as well.

You are now good-to-go.

Posted: Thursday May 23rd, 2013 at 4:59 pm #50463

Thank you so much! It appears to be working! You guys rock!

Posted: Monday Jun 3rd, 2013 at 12:09 am #51204

Not sure what happened, because everything was working and now I’m having the same problem! I can’t remotely download files (it keeps rejecting my username and password)

Posted: Monday Jun 3rd, 2013 at 12:52 am #51206

Doh! Please disregard. I’ve been messing around trying to get the RSS feed working with various podatchers and I locked myself out for failed login attempts.

Posted: Tuesday Jun 4th, 2013 at 7:22 pm #51380

Heh, it can happen to anyone. Thanks for the update. :)

Viewing 10 replies - 1 through 10 (of 10 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.