Slash Boxes
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)

  reversethis-{gro.gnihsams} {ta} {ffej}

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

    $I0 = ap_const['HTTP_UNAUTHORIZED']
    goto auth_return_status

    $I0 = ap_const['DECLINED']
    goto auth_return_status

        .return $I0

In httpd.conf:

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

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