|
NAMEApache::AuthTicket - Cookie Based Access and Authorization ModuleVERSIONversion 0.94SYNOPSIS# in httpd.conf PerlModule Apache::AuthTicket PerlSetVar FooTicketDB DBI:mysql:database=mschout;host=testbed PerlSetVar FooTicketDBUser test PerlSetVar FooTicketDBPassword secret PerlSetVar FooTicketTable tickets:ticket_hash:ts PerlSetVar FooTicketUserTable myusers:usename:passwd PerlSetVar FooTicketPasswordStyle cleartext PerlSetVar FooTicketSecretTable ticket_secrets:sec_data:sec_version PerlSetVar FooTicketExpires 15 PerlSetVar FooTicketLogoutURI /foo/index.html PerlSetVar FooTicketLoginHandler /foologin PerlSetVar FooTicketIdleTimeout 1 PerlSetVar FooPath / PerlSetVar FooDomain .foo.com PerlSetVar FooSecure 1 PerlSetVar FooLoginScript /foologinform <Location /foo> AuthType Apache::AuthTicket AuthName Foo PerlAuthenHandler Apache::AuthTicket->authenticate PerlAuthzHandler Apache::AuthTicket->authorize require valid-user </Location> <Location /foologinform> AuthType Apache::AuthTicket AuthName Foo SetHandler perl-script Perlhandler Apache::AuthTicket->login_screen </Location> <Location /foologin> AuthType Apache::AuthTicket AuthName Foo SetHandler perl-script PerlHandler Apache::AuthTicket->login </Location> <Location /foo/logout> AuthType Apache::AuthTicket AuthName Foo SetHandler perl-script PerlHandler Apache::AuthTicket->logout </Location> DESCRIPTIONThis module provides ticket based access control. The theory behind this is similar to the system described in the eagle book.This module works using HTTP cookies to check if a user is authorized to view a page. Apache::AuthCookie is used as the underlying mechanism for managing cookies. This module was designed to be as extensible as possible. Its quite likely that you will want to create your own subclass of Apache::AuthTicket in order to customize various aspects of this module (show your own versions of the forms, override database methods etc). This system uses cookies to authenticate users. When a user is authenticated through this system, they are issued a cookie consisting of the time, the username of the user, the expriation time of the cookie, a "secret" version (described later), and a cryptographic signature. The cryptographic signature is generated using the MD5 algorithm on the cookie data and a "secret" key that is read from a database. Each secret key also has a version number associated with it. This allows the site administrator to issue a new secret periodically without invalidating the current valid tickets. For example, the site administrator might periodically insert a new secret key into the databse periodically, and flush secrets that are more than 2 days old. Since the ticket issued to the user contains the secret version, the authentication process will still allow tickets to be authorized as long as the corresponding secrets exist in the ticket secrets table. The actual contents and length of secret data is left to the site administrator. A good choice might be to read data from /dev/random, unpack it into a hex string and save that. This system should be reasonably secure becuase the IP address of the end user is incorporated into the cryptographic signature. If the ticket were intercepted, then an attacker would have to steal the user's IP address in order to be able to use the ticket. Plus, since the tickets can expire automatically, we can be sure that the ticket is not valid for a long period of time. Finally, by using the Secure mode of Apache::AuthCookie, the ticket is not passed over unencrypted connections. In order to attack this system, an attacker would have to exploit both the MD5 algorightm as well as SSL. Chances are, by the time the user could break both of these, the ticket would no longer be valid. CONFIGURATIONThere are two things you must do in order to configure this module:1) configure your mod_perl apache server 2) create the necessary database tables. Apache Configuration - httpd.confThere are two ways that this module could be configured. Either by using a function call in startup.pl, or by configuring each handler explicitly in httpd.conf. If you decide to mix and match using calls to Apache::AuthTicket->configure() with directives in httpd.conf, then remember that the following precedence applies:o If a directive is specified in httpd.conf, it will be used. o else if a directive is specified by configure(), then the configure() value will be used. o else a default value will be used. Default values are subject to change in later versions, so you are better of explicitly configuring all values and not relying on any defaults. There are four blocks that need to be entered into httpd.conf. The first of these is the block specifying your access restrictions. This block should look somrthing like this: <Location /foo> AuthType Apache::AuthTicket AuthName Foo PerlAuthenHandler Apache::AuthTicket->authenticate PerlAuthzHandler Apache::AuthTicket->authorize require valid-user </Location> The remaining blocks control how to display the login form, and the login and logout urls. These blocks should look similar to this: <Location /foologinform> AuthType Apache::AuthTicket AuthName Foo SetHandler perl-script Perlhandler Apache::AuthTicket->login_screen </Location> <Location /foologin> AuthType Apache::AuthTicket AuthName Foo SetHandler perl-script PerlHandler Apache::AuthTicket->login </Location> <Location /foo/logout> AuthType Apache::AuthTicket AuthName Foo SetHandler perl-script PerlHandler Apache::AuthTicket->logout </Location> Apache Configuration - startup.plAny Apache::AuthTicket configuration items can be set in startup.pl. You can configure an AuthName like this:Apache::AuthTicket->configure(String auth_name, *Hash config) Note that when configuring this way you dont prefix the configuration items with the AuthName value like you do when using PerlSetVar directives. Note: You must still include Apache::AuthCookie configuration directives in httpd.conf when configuring the server this way. These items include: PerlSetVar FooPath / PerlSetVar FooDomain .foo.com PerlSetVar FooSecure 1 PerlSetVar FooLoginScript /foologinform example: Apache::AuthTicket->configure('Foo', { TicketDB => 'DBI:mysql:database=test;host=foo', TicketDBUser => 'mschout', TicketDBPassword => 'secret', TicketTable => 'tickets:ticket_hash:ts', TicketUserTable => 'myusers:usename:passwd', TicketPasswordStyle => 'cleartext', TicketSecretTable => 'ticket_secrets:sec_data:sec_version', TicketExpires => '15', TicketLogoutURI => '/foo/index.html', TicketLoginHandler => '/foologin', TicketIdleTimeout => 5 }); Valid configuration items are:
Database ConfigurationThree database tables are needed for this module:
METHODSThis is not a complete listing of methods contained in Apache::AuthTicket. Rather, it is a listing of methods that you might want to overload if you were subclassing this module. Other methods that exist in the module are probably not useful to you.Feel free to examine the source code for other methods that you might choose to overload.
You can use these values in your make_login_screen() method to display a message stating why the user must login (e.g.: "you have exceeded 5 minutes of inactivity and you must re-login").
CREDITSThe idea for this module came from the Ticket Access system in the eagle book, along with several ideas discussed on the mod_perl mailing list.Thanks to Ken Williams for his wonderful Apache::AuthCookie module, and for putting in the necessary changes to Apache::AuthCookie to make this module work! SEE ALSOperl, mod_perl, Apache, Apache::AuthCookieSOURCEThe development version is on github at <http://github.com/mschout/apache-authticket> and may be cloned from <git://github.com/mschout/apache-authticket.git>BUGSPlease report any bugs or feature requests to bug-apache-authticket@rt.cpan.org or through the web interface at: http://rt.cpan.org/Public/Dist/Display.html?Name=Apache-AuthTicketAUTHORMichael Schout <mschout@cpan.org>COPYRIGHT AND LICENSEThis software is copyright (c) 2000 by Michael Schout.This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Visit the GSP FreeBSD Man Page Interface. |