mod_parrot now supports authentication handlers.  i'm planning a release
in the next few days, including a whitepaper on its architecture, but
here's an example of what you can now do.  the following handler accepts
any basic authentication with a password of 'squawk' (correpsonding
httpd.conf follows the code).

.namespace [ 'MyAuthHandler' ]

# handler.imc
.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

-----

# httpd.conf
ParrotInit /tmp/init.pbc
ParrotLoad /tmp/Constants.pbc
ParrotLoad /tmp/RequestRec.pbc
ParrotLoad /tmp/handler.pbc
<Directory /usr/local/apache2/htdocs/parrot/private>
    ParrotAuthenHandler MyAuthHandler
    AuthType Basic
    AuthName "Parrot Test"
    Require valid-user
</Directory>


-jeff

Reply via email to