From owner-freebsd-questions@FreeBSD.ORG Thu Sep 23 11:37:13 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id ED4DF16A4CE for ; Thu, 23 Sep 2004 11:37:13 +0000 (GMT) Received: from smtp.infracaninophile.co.uk (smtp.infracaninophile.co.uk [81.2.69.218]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1A5B943D1F for ; Thu, 23 Sep 2004 11:37:13 +0000 (GMT) (envelope-from m.seaman@infracaninophile.co.uk) Received: from happy-idiot-talk.infracaninophile.co.uk (localhost.infracaninophile.co.uk [IPv6:::1])i8NBbAOW031001 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 23 Sep 2004 12:37:10 +0100 (BST) (envelope-from matthew@happy-idiot-talk.infracaninophile.co.uk) Received: (from matthew@localhost)i8NBb9A8031000; Thu, 23 Sep 2004 12:37:09 +0100 (BST) (envelope-from matthew) Date: Thu, 23 Sep 2004 12:37:09 +0100 From: Matthew Seaman To: Andy Holyer Message-ID: <20040923113709.GB30497@happy-idiot-talk.infracaninophile.co.uk> Mail-Followup-To: Matthew Seaman , Andy Holyer , freebsd-questions@freebsd.org References: Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="kXdP64Ggrk/fb43R" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.1i X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-1.5.6 (smtp.infracaninophile.co.uk [IPv6:::1]); Thu, 23 Sep 2004 12:37:10 +0100 (BST) X-Virus-Scanned: clamd / ClamAV version devel-20040904, clamav-milter version 0.75l on smtp.infracaninophile.co.uk X-Virus-Status: Clean X-Spam-Status: No, hits=-4.8 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=2.64 X-Spam-Checker-Version: SpamAssassin 2.64 (2004-01-11) on happy-idiot-talk.infracaninophile.co.uk cc: freebsd-questions@freebsd.org Subject: Re: Advice: "The Right" authentication method X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Sep 2004 11:37:14 -0000 --kXdP64Ggrk/fb43R Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Sep 23, 2004 at 11:53:40AM +0100, Andy Holyer wrote: > I'm working on writing the "Control Panel" scripts which subscribers to= =20 > our ISP will use to set up their eMail accounts and web space. >=20 > Here's the Server spec: >=20 > FreeBSD-Current; > Perl 5.6.1, no problem installing any needed modules; > Apache 2; > I'm keeping ordinary customers off the machine, so I run Postfix and=20 > Cyus and use sasl2 for customer passwords. I'd like to use these ID to=20 > arrange access to the control panel system. >=20 > I'm stuck at the very start of my design process. I have two tasks to=20 > do: >=20 > Verify that users have supplied the correct password; and let the perl=20 > scripts know who that visitor is, so that we can select the correct=20 > accounts to show. >=20 > Do I use SASL directly? or LDAP? or do I implement an Apache module to=20 > handle access and let Apache do the work? >=20 > I want to do "The right thing" - that is, the most general and correct=20 > thing possible, I've got years of experience in perl scripting, but at=20 > the moment I wandering around in a twisty litte maze of standards, all=20 > different. >=20 > Clue, please? You're basically writing a web application. For which you need access control. You've got two choices: either use the HTTP basic or HTTP digest auth mechanisms built into HTTP, and supported by Apache, or (and this is by far the most popular choice) write your own authentication mechanism as part of your application[1]. The second choice gives you a lot more flexibility about how you customise things and how you make the login screen look, which is probably why it's more popular. You can also arrange things to avoid sending passwords across the net in cleartext if you're cunning enough. However you do it, the authentication process is essentially that the client sends you two pieces of information: their username (ie. who they claim to be) and some form of secret. The secret is usually a password, but it can be something more complicated like an Opie one-time password or whatever. Then in your application you compare the secret to your stored version of it, and if they match you believe that the client is who they say they are and that they should have access. Of course, you don't want to keep the secret values lying around in plain text: the standard Unix response to all that is to generate a password hash using DES or MD5 to store, and to try and recreate that hash using the password supplied by the user. That's where SASL comes in: instead of having to code up all that stuff your self, SASL is a library of authentication methods that you can just plug into your application. Yes, you will need some sort of user account database -- often implemented using a RDBMS, but could with little extra effort be made to operate against an LDAP or RADIUS server. Or whatever the database type you're already using for your Postfix+Cyrus setup. There are several examples of doing this sort of thing within the ports system -- most are written in PHP, but check out devel/bugzilla and www/rt3 for perl based examples. Cheers, Matthew [1] Actually, if you were using mod_perl you could write your own authentication and authorization handlers that would get called by apache during the normal page serving transaction, effectively giving you the best of both worlds. But that requires you to be an expert mod_perl programmer and to have a lot of experience at writing web applications. Save that sort of thing for version 2.0... --=20 Dr Matthew J Seaman MA, D.Phil. 26 The Paddocks Savill Way PGP: http://www.infracaninophile.co.uk/pgpkey Marlow Tel: +44 1628 476614 Bucks., SL7 1TH UK --kXdP64Ggrk/fb43R Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.6 (FreeBSD) iD8DBQFBUrVliD657aJF7eIRAsDfAKCnGC5o2P/nSt3F4wt9Nl54g4txZQCfd7qT cWdZQAKF6xcCQNSrEvfVcpg= =h8GC -----END PGP SIGNATURE----- --kXdP64Ggrk/fb43R--