Re: http authentication

Roberto Moral <[email protected]>
Newsgroups gmane.comp.apache.mod-ruby
Message-ID <[email protected]>
I had the same problem, move the r.auth_name and r.auth_type  before the 
if statement

John Long wrote:

>Hi,
>
>I've been working on an authentication handler for our web site. I can't get
>the following code to run:
>
>% cat handler.rb
>module Site
>    def Site.authenticate(r)
>        if r.get_basic_auth_pw.nil?
>            r.auth_name = 'Protected Area'
>            r.auth_type = 'basic'
>            r.note_auth_failure
>            return(Apache::DONE)
>        end
>
>        unless (user == 'jlong') and (password == 'blue74')
>            return(Apache::AUTH_REQUIRED)
>        else
>            return(Apache::OK)
>        end
>    end
>end
>
>% cat .htaccess
>RubyRequire '/path/to/handler.rb'
>Require valid-user
>RubyAuthenHandler
>
>Apache spits out the following error:
>% tail -f /apache/error_log
>. . .
>[Thu Dec 11 14:20:55 2003] [crit] [client 127.0.0.1] configuration error:
>couldn't perform authentication. AuthType not set! /~jlong/secure
>. . .
>
>My handler is nearly a direct copy of the authentication handler found in
>the documentation ( http://www.rubydoc.org/books/modruby/x711.htm#AEN736 )
>only I removed the DB related code.
>
>When I move the r.auth_type and r.auth_name setters above the if statement
>it works fine. Is this an error in the documentation or am I missing
>something?
>
>I'm running Apache/2.0.48, mod_ruby/1.0.7, and Ruby/1.8.0.
>
>--
>John Long
>
>
>
>  
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.