Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

parrot authentication handlers

0 views
Skip to first unread message

Jeff Horwitz

unread,
Oct 20, 2004, 2:27:45 PM10/20/04
to perl6-i...@perl.org
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

Jeff Horwitz

unread,
Oct 20, 2004, 3:38:57 PM10/20/04
to Dan Sugalski, perl6-i...@perl.org
> You will, I trust, keep us up to date on all the places where we're
> making life difficult? :)

for sure. but it's actually been quite a smooth ride so far. i have a
short list of problems i've had to deal with, and i'll forward them to the
list when i get the chance.

what i'd really like to see is a language that utilizes parrot objects
(AFAIK there isn't one right now). once we have this, we can start
writing handlers in a high level language and REALLY have something to
show off. ;-)

-jeff

On Wed, 20 Oct 2004, Dan Sugalski wrote:

> At 2:27 PM -0400 10/20/04, Jeff Horwitz wrote:
> >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.
>

> Wow. That's... cool. And a bit scary. But definitely cool. I could
> have an excessive amount of fun with this.
>
> --
> Dan
>
> --------------------------------------it's like this-------------------
> Dan Sugalski even samurai
> d...@sidhe.org have teddy bears and even
> teddy bears get drunk
>

Leopold Toetsch

unread,
Oct 20, 2004, 2:51:51 PM10/20/04
to Jeff Horwitz, perl6-i...@perl.org
Jeff Horwitz <je...@smashing.org> wrote:
> mod_parrot now supports authentication handlers.

awesome

> -jeff

leo

Dan Sugalski

unread,
Oct 20, 2004, 3:47:19 PM10/20/04
to Jeff Horwitz, perl6-i...@perl.org
At 3:38 PM -0400 10/20/04, Jeff Horwitz wrote:
> > You will, I trust, keep us up to date on all the places where we're
>> making life difficult? :)
>
>for sure. but it's actually been quite a smooth ride so far. i have a
>short list of problems i've had to deal with, and i'll forward them to the
>list when i get the chance.

Great.

>what i'd really like to see is a language that utilizes parrot objects
>(AFAIK there isn't one right now). once we have this, we can start
>writing handlers in a high level language and REALLY have something to
>show off. ;-)

Well, actually.... scary though it may be, my Work Project uses
parrot objects for everything. Whether this is a useful thing or
not's an open question (the language lacks subroutines, for example)
but...

Jeff Horwitz

unread,
Oct 20, 2004, 3:55:11 PM10/20/04
to Dan Sugalski, perl6-i...@perl.org
On Wed, 20 Oct 2004, Dan Sugalski wrote:
> Well, actually.... scary though it may be, my Work Project uses
> parrot objects for everything. Whether this is a useful thing or
> not's an open question (the language lacks subroutines, for example)
> but...

in general, anything that can generate bytecode/PIR/PASM containing a
_handler subroutine in a parrot namespace would fit the bill.

-jeff

Dan Sugalski

unread,
Oct 20, 2004, 4:00:27 PM10/20/04
to Jeff Horwitz, perl6-i...@perl.org

Hrm. I may have to introduce subs into the grammar for the language
just so I can make this work.

0 new messages