[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cgiapp] Restrict access to certain run modes


On 8/16/05, Barry Moore <suppressed> wrote:
> If you're on Windows or something else without /tmp edit the line 16 of
> the cgiapp module to something like this:
> CGI_SESSION_OPTIONS => ["driver:File", $self->query, {Directory =>
> "C:\\"}],

I know this doesn't have anything to do with what your are writing
about, but I thought I'd throw out a little helpful hint for
portability sake.  If you want to make this work on all systems, use
the File::Spec library (comes standard with perl), and look for the
tmpdir method.  It will return a valid temporary directory for the
platform that you are running on.

File::Spec->tmpdir

And interestingly enough, the options for
CGI::Application::Plugin::Session that you are using in your code are
actually the same as the defaults it provides (except that the plugin
uses the File::Spec->tmpdir method to figure out the temporary
directory).  So you could have just configured your session like this:

$self->session_config(
    COOKIE_PARAMS     => {-expires => '+24h',},
    SEND_COOKIE         => 1
);

And since the latest release, CGI::Application::Plugin::Session can
automatically set the expiry date on the session for you, which then
also adds the same expiry date to the outgoing cookie.  So you could
use the DEFAULT_EXPIRY option instead of the COOKIE_PARAMS method. 
And SEND_COOKIE is on by default so you don't need it either :)

$self->session_config(
    DEFAULT_EXPIRY => '+24h',
);

That will create file based sessions in a temp dir consistent with the
platform you are running on, and it will set all new sessions to
expire in 24 hours, and automatically send a cookie that also expires
in 24 hours.

Cheers,

Cees

ps for what it is worth, I do authentication in a very similar way as
in your code, except that I do the authentication through
CGI::Session::Auth (for now).  But the structure (doing the checks in
prerun, etc...) is very similar.  There, that brings us back on topic
;)

---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.