Free Code: Simple-Auth by Athletics
Saturday March 29, 2008 - 14 months ago
Posted by James Ellis / Filed under Code, Software
Today, a free snippet of PHP code. Simple-Auth by Athletics makes password-protecting web documents easy, and looks pro at the same time. After being asked about it a few times, we figured we’d share.
We regularly use this code to password-protect client work — design comps, wireframes, prototypes, dev sites, etc. Clients love password-protecting things, and for good reason: you never know what’s going to end up on some blog, message board, Digg, whatever. This is certainly a concern with some high profile clients, but even if no one in the world (other than you and your client) cares about what you’re up to, everyone enjoys a little professionalism and peace of mind.
For most, password-protecting a document or directory involves entering your web host’s control panel, clicking into the password-protect tool, navigating to the directory in question, and creating a new username:password combo. The control panel software will then generate an invisible .htaccess file and drop it into the directory. This whole process is somewhat cumbersome, isn’t very portable, and most people have no idea how .htaccess files work.
Simple-Auth makes it relatively easy to password protect any PHP file. It’s a snap to drop in once you get a sense of how it works. It’s easily configured and modified. You don’t need to mess with a hosting control panel. No hidden .htaccess files. And it’s more attractive than the standard http authentication dialogue box.
Demo
In the demo below we password-protected a very simple HTML document. Instead of using the .html file extension, we use .php. We do this because we need to add one line of PHP code at the start of the file in order to activate the Simple-Auth PHP brain. Now when visitors attempt to access this document, they will be required to provide an authenticating passcode before viewing.
View the demo here. The passcode is “passcode”.
Simple, right?
Download
Download the code along with a sample document. (ZIP, 5k)
Customizing
The simple-auth-by-athletics.php file is organized relatively well. Take a look around and you’ll see where you can set the passcode, modify commonly used bits of HTML, and dig into the HTML/CSS. A basic familiarity with code-noodlery required.
Enjoy.
Comments? Contact James via email - .
