سؤال

The scenario is I want to implement single sign on process in my web application, currently I have protected few folders using .htpasswd

Now when a user logs in to the system I want that they should get access to those protected folders as well without being asked for the username and password again by the broswer

Is there a way to achieve this

هل كانت مفيدة؟

المحلول

You wouldn't be able to give users direct access to the files in the protected folders unless all of your users exist in .htpasswd file, and your web application uses the same realm and auth type (basic || digest). Since when using http auth to protect the folders, the username/password is sent on each request.

You could write code that was outside of the protected folders handled the authentication and then used fpassthru to send the files back though.

نصائح أخرى

As far as I know, there is no such solution. You should use PHP's SESSIONS and a login interface to control user's access rather than .htpasswd .

Or you can make a file in a non-protected folder and do include protectedfolder/protected-file.php in that file and let users access it without getting prompted for password.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top