Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3420986
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:03:52+00:00 2026-05-18T06:03:52+00:00

I’m working to add a better authentication system to a mature backend site. I’ve

  • 0

I’m working to add a better authentication system to a mature backend site. I’ve been using HTTP Authentication just because it’s so easy to setup. But as the site has grown, the downsides to this method have become more and more pronounced; specifically, the lack of security over standard HTTP connections, and the lack of a standard mechanism to log users out.

I’ve read over every PHP authentication question I can find on SO, but I still haven’t found a satisfactory solution for upgrading a large existing codebase to use a session-based system. The takeaway from most answers seems to be:

  1. Don’t roll your own if you don’t know exactly what you’re doing
  2. Session-based authentication is a really involved subject

I have rolled my own user registration system before, and indeed, it seems woefully insecure looking at it now. I can see it taking months to polish, when all I really want to be doing is working on the backend itself.

I imagine this is a very common problem. Pretty much every website I’ve built has required at least a very minimal backend, and I think very few developers have the chops (“expertise”) to build an airtight system.

I’ve looked at solutions using Zend Framework, CodeIgniter, and CakePHP — but they all presume a specific coding style (or so it seems), and the prospect of reorganizing all of my code is, in a word, deflating. (And beyond that, the inefficiency of including one of these massive frameworks just for authentication really rubs me the wrong way.)

Is there a better solution? Can I isolate the authentication class from one of these frameworks? (Because this is just a backend site (closed), I don’t need to worry about registration, or CAPTCHAS — or really any of the ancillary features of an authorization system.)

Thanks so much for your consideration.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T06:03:52+00:00Added an answer on May 18, 2026 at 6:03 am

    Inspired by Hamish’s comment on my question, I learned that it’s very easy to use the Zend_Auth class without having to use the rest of the framework, and without having created my project the “ZF way” — i.e., with the zf command line tool and the MVC pattern.

    In the end, I only used Zend_Auth and Zend_Db. I haven’t integrated my proof of concept into my actual site yet, but I think it captures the basic functionality I was looking for. All it does at the moment is cycle between the logged-in and logged-out states when the page is refreshed:

    require_once('Zend/Db.php');
    require_once('Zend/Auth.php');
    require_once('Zend/Auth/Adapter/DbTable.php');
    require_once('PasswordHash.php');
    require_once('PasswordHash_Auth_Adapter_DbTable.php');
    
    $auth = Zend_Auth::getInstance();
    if ($auth->hasIdentity()) {
        echo 'Logged in...';
        $auth->clearIdentity();
        echo 'logged out.';
    } else {
        // authenticate
        echo 'Authenticating...';
        $db_options = parse_ini_file('../zend_db.ini');
        $db = Zend_Db::factory('PDO_MYSQL', $db_options);
        $authAdapter = new PasswordHash_Auth_Adapter_DbTable($db);
        $authAdapter->setIdentity('test')->setCredential('test');
        $result = $auth->authenticate($authAdapter);
        if (!$result->isValid()) {
            echo 'invalid.';
        } else {
            echo 'valid.';
        }
    }
    

    PasswordHash_Auth_Adapter_DbTable.php is a custom Auth_Adapter_DbTable that uses phpass to obfuscate passwords, mostly copied from an article by Jonathan Street. I also found an article by Alexander Peslyak (who I think is the creator of phpass) that was very helpful to understanding user/password storage broadly.

    The users table is extremely bare-bones for the moment:

    CREATE TABLE `users` (
      `id` int(3) unsigned zerofill NOT NULL AUTO_INCREMENT,
      `user` varchar(60) NOT NULL,
      `pass` varchar(60) NOT NULL,
      PRIMARY KEY (`id`),
      UNIQUE KEY `user` (`user`)
    ) ENGINE=MyISAM
    

    I inserted the one “test” user, with a phpass-generated hash for the password. Ultimately I plan to have a login form that POSTs the user/password for authentication. On the surface, this method (plain old POST form) seems insecure, but I looked at how Facebook’s login form works, and indeed I can see my password in plaintext as part of the form data after logging in — so it can’t be that insecure (right?).

    Overall I’m very happy how simple this solution is… in a way it scares me how little I understand the actual nuts & bolts of Zend_Auth, but on the same token I’m glad it’s tried & tested code (vs. rolling my own).

    If I’ve made any egregious errors, please let me know!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.