Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

jhorwitz (4227)

jhorwitz
  reversethis-{gro.gnihsams} {ta} {ffej}
http://www.smashing.org/

System administrator, Perl hacker, author of "Unix System Management Primer Plus" (SAMS 2003), mod_parrot, extproc_perl, Authen::Krb4, Authen::Krb5.

Journal of jhorwitz (4227)

Wednesday October 20, 2004
01:11 PM

Parrot authentication handlers

[ #21436 ]
You can now write Apache authentication handlers in Parrot (release pending). Behold, a handler that accepts any basic authentication with a password of 'squawk':

In handler.imc:

.namespace [ 'MyAuthHandler' ]

.sub _handler
    .local pmc r
    .local pmc ap_const
    .local string pw
    .local int status

    find_global ap_const, 'Apache::Constants', 'ap_constants'

    # get the request_rec object
    find_type $I0, 'Apache::RequestRec'
    r = new $I0

    # decline if not the initial request
    $I1 = r.'is_initial_req'( )
    if $I1 != 1 goto auth_declined

    (status, pw) = r.'get_basic_auth_pw'( )

    if pw != 'squawk' goto auth_failure
    $I0 = ap_const['OK']
    goto auth_return_status

auth_failure:
    $I0 = ap_const['HTTP_UNAUTHORIZED']
    goto auth_return_status

auth_declined:
    $I0 = ap_const['DECLINED']
    goto auth_return_status

auth_return_status:
    .pcc_begin_return
        .return $I0
    .pcc_end_return
.end

In httpd.conf:

ParrotLoad /tmp/handler.pbc
<Directory /usr/local/apache2/htdocs/parrot/private>
    ParrotAuthenHandler MyAuthHandler
    AuthType Basic
    AuthName "Parrot Test"
    Require valid-user
</Directory>

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.