![]() |
Basic 401 Authentication Library - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: Basic 401 Authentication Library (/showthread.php?tid=14247) |
Basic 401 Authentication Library - El Forum - 12-24-2008 [eluser]Unknown[/eluser] I just finished up a portfolio site for a friend, and could not find an uber simple codeigniter library or helper that just leveraged basic authentication. I didn't want to manage users, registrations, and so forth when all we needed was to make sure only he and I could access the control panel. Here's the code. Suggestions are welcome, this site is my first CI project and one of my first PHP projects. Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); Basic 401 Authentication Library - El Forum - 12-24-2008 [eluser]Unknown[/eluser] Just a quick add on, as I didn't spell it out in the comment block at the top. Add: Code: $config['admin_user'] = 'yourusername'; to config.php. Basic 401 Authentication Library - El Forum - 12-24-2008 [eluser]cfraz[/eluser] Nice and simple - I'm doing something similar for Windows Integrated Authentication on an intranet application that runs on IIS. Take a look at the CI input library. Code: $this->input->server('PHP_AUTH_USER'); filters input, returns false if it's not set, and optionally screens xss content. I'm not sure but that might be a vulnerability for PHP_AUTH_USER? Also, I think that parameter is only returned for Apache running PHP module, so it limits applicability. Basic 401 Authentication Library - El Forum - 01-06-2009 [eluser]Iverson[/eluser] Nice. I added this...This way the realm isn't hardcoded. Code: if(! $this->ci->config->item('realm')) Basic 401 Authentication Library - El Forum - 01-06-2009 [eluser]BeingDefined[/eluser] very nice! Will be using this in my future project(s). Thanks! Basic 401 Authentication Library - El Forum - 02-05-2009 [eluser]Nathan Pitman (Nine Four)[/eluser] Thanks for this, just what I've been looking for. ![]() Basic 401 Authentication Library - El Forum - 03-04-2009 [eluser]Iverson[/eluser] Does this go in controllers or views? Basic 401 Authentication Library - El Forum - 03-04-2009 [eluser]Nathan Pitman (Nine Four)[/eluser] In the controller. ![]() Basic 401 Authentication Library - El Forum - 02-01-2011 [eluser]Unknown[/eluser] Nice library. But I think better to change below. if ( !isset($_SERVER['PHP_AUTH_USER']) ) ↓ if ( !isset($_SERVER['PHP_AUTH_USER']) || !$_SERVER['PHP_AUTH_USER'] ) Please see below. Code: $ diff -u a/basic401auth.php b/basic401auth.php |