[Catalyst] Login via IP address?

Jesse Sheidlower jester at panix.com
Thu Sep 20 15:20:27 GMT 2007

I have a Cat app with the usual Session and Authentication
stuff running, though I'm using my own Authz stuff instead of
any of the built-in Roles tools. It's a typical setup with
regular users who can just view things, some users with
add/edit privs, and superusers who can create new users etc.

In a previous, non-Cat version of this app I had a function so
that people using the app from the main company location would
automatically be logged in as a generic "regular" user, and
only if they tried to do any adding/editing would get
redirected to a login page. I forgot about this and didn't
build it into the Cat version, and now I've learned that the
reason people continue to use the clunky old version instead
of my shiny fast featureful Cat app is that they're too lazy
to log in, so I'd like to add this.

The way it looked, more or less, in the old one was:

  if ( !defined( $self->login_user() ) ) {
    if ( $ENV{REMOTE_ADDR} =~ m/hairyIPaddressRegEx/ ) {
       $self->redirect( $self->{target_uri} );
    } else {
      # redirect to login page

What's the Right Way to do this in Cat?


Jesse, still not programming much lately

More information about the Catalyst mailing list