Adding authentication to PEAR channels

A client of mine is taking the proactive approach of packaging all of their software using PEAR and distributing it via a custom PEAR channel. I can’t recommend this enough for people that are distributing their PHP code to a number of clients/users.

The problem is that, by default, PEAR channels are consumable by anyone with an internet connection. I sent an email to Greg asking him if there was a way to restrict this and how to go about doing it. As it turns out it’s not only available, but detailed in the free excerpt from his new book The PEAR Installer Manifesto.

There are a number of ways to restrict access. The more complicated approach involves coding a script that handles the authentication and then restricts packages on a per client basis. This is a great way to say client X can install packages A, C and F, while client Y can only install packages B and D.

The route I ended up taking involved simply setting up HTTP-Auth using and .htaccess and .htpasswd file. Once you have that set up and working you can log in with the following commands.

$ pear -d "pear.mychannel.com" login

Follow the instructions by entering your username and password and you should see a confirmation that you’re logged in. After that you’re allowed to download and install.

Year in Review

  1. I started the year by telling everyone that Lauren and I were ending our marriage.
  2. I visited Dana down in San Diego, CA. The first of two trips to see my good friend and eat copious amounts of burritos.
  3. In February I released Framework and DB_Virtual unto the world. Not much rejoicing ensued, but many people are using the software and apparently quite happy with it.
  4. I found out that I have a herniated L5 disc in my back, which has happily escalated into full blown Sciatica.
  5. On March 14th Lauren and I were officially divorced. On March 15th I celebrated my 26th birthday.
  6. In April I attended MySQL UC and blogged the whole thing.
  7. I bought a road bike and started riding a lot.
  8. I ran in my very first 5k logging a time of 0:27:29.0.
  9. In July I declared Operation Fat Ass a success and started training for my first sprint triathlon.
  10. I bought the love of my life.
  11. Towards the end of August I ran in another 5k in Lynnwood logging a time of 23:44, which was good enough for 3rd place in my age division (20-29 Males) and 12th out of a field of 77.
  12. On September 17th, 2006 I participated in the Kirkland Tri-It Sprint Triathlon. I ended up taking first place out of the beginner’s heat with a time of 1:19:40.
  13. I pulled double duty and flew down to San Diego a scant two weeks later to participate in the Jamba Juice Sprint Triathlon. This time I placed 450th out of 1,480 participants with a time of 1:06:30.
  14. In late October I flew back to Michigan to attend Eastern Michigan University’s homecoming festivities.
  15. In early November my employment at Enotes.com came to a close. I haven’t mentioned this until now, but I’m no longer working for Enotes.com and am currently doing consulting for a number of clients.
  16. I spent Christmas and rang in the New Year with Rebecca in Seattle, WA.
  17. Towards the end of December my Sciatica found its stride and now keeps me from doing the most minimal of tasks.