Advertisement

08.02.2006 at 10:07PM PDT, ID: 21941615
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.6

Authentication - Help with mod_perl (Apache-AuthCookie)

Asked by vanfleet in CGI Scripting

Tags: ,

I want to be able to authenticate users without the user having to go through a login page (the user will have already logged into another server before getting to the pages that I want to protect). The login information will be sent with the url string:

      http://my.server.com?user=userName&password=password

I then want Apache to authenticate based on that information. The Apache configuration looks something like the following:

  PerlSetVar WhatEverLoginScript /LOGIN
  :
  :

  # This is the action of the LOGIN script above.
  <Files LOGIN>
   AuthType Sample::AuthCookieHandler
   AuthName WhatEver
   SetHandler perl-script
   PerlResponseHandler Sample::AuthCookieHandler->login
  </Files>

Notice that the login script is going directly to AuthCookieHandler rather than to a login page where the user might manually enter a userName and password. I have this mostly doing what I want except I can't get the original html page to load, even after the authentication cookie is set, the "Forbidden" page is still being displayed in the browser window. If I then refresh the page it then loads as it should (being authenticated). My login handler looks like the following:

  sub login {
    my ($self, $r) = @_;
    my $debug = $r->dir_config("AuthCookieDebug") || 0;

    my $auth_type = $r->auth_type;
    my $auth_name = $r->auth_name;
   
    # Get the args that are sent with the page containing
    # the username and password.
    my $args = $r->prev->args;
    my @argArray=split("\&",$args);

    # Get the credentials from the data posted by the client
    my @credentials;
    my $userName=(split("=",$argArray[0]))[1];
    my $passWord=(split("=",$argArray[1]))[1];
    push @credentials, $userName;
    push @credentials, $passWord;

    # save creds in pnotes so login form script can use them if it wants to
    $r->pnotes("${auth_name}Creds", \@credentials);

    # Exchange the credentials for a session key.
    my $ses_key = $self->authen_cred($r, @credentials);

    unless ($ses_key) {
        $r->server->log_error("Bad credentials") if $debug >= 2;
        $r->subprocess_env('AuthCookieReason', 'bad_credentials');
        $r->uri($r->prev->unparsed_uri);
        return $auth_type->login_form($r);
    }

    $self->send_cookie($r, $ses_key);
    $self->handle_cache($r);
   
    # Get the page and load it after authentication has
    # taken place.
    my $theURI=$r->prev->unparsed_uri;

    # The following line is not loading the page correctly.
    $r->headers_out->set('Location' => $theURI);

    return HTTP_MOVED_TEMPORARILY;
  }

So, my question is what can I do here to get the correct page to load after the authentication has taken place? I can't seem to get past the "Forbidden" page. Also, am I going about this the right way, or is there a better way to do this?

Any help here would be greatly appreciated.

Thanks,
dv
Start Free Trial
[+][-]08.03.2006 at 04:51AM PDT, ID: 17240752

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.03.2006 at 06:05AM PDT, ID: 17241226

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.26.2006 at 08:46AM PDT, ID: 17396225

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.28.2006 at 09:44AM PDT, ID: 17405178

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.26.2006 at 08:26AM PDT, ID: 17602167

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]09.30.2006 at 01:50AM PDT, ID: 17633990

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: CGI Scripting
Tags: login, mod_perl
Sign Up Now!
Solution Provided By: CetusMOD
Participating Experts: 2
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32