rlb3 has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks,

I think I just need someone to smack me on the head and tell me this is a bad idea so I can move on. What I've been thinking about is an Attribute::Handler that controls user access to a subroutine or method. It would look some thing like this:

read_log('failed'); slurp_shadow(); sub read_log :access_list('rlb3','root') { ... } sub slurp_shadow :access_root { ... }

Is this as dumb an idea as I think or is there some hope?

Thanks,

Replies are listed 'Best First'.
Re: User access controlled by subroutine attribute.
by chromatic (Archbishop) on Aug 14, 2006 at 21:25 UTC

    Perl Hacks has an example of that. I used a similar method to add access control to objects accessible through web services. It worked wonderfully.

      Thanks for replying.

      It's funny, I was listening to your talk on PDX.pm that got me thinking about Attribute::Handler. And I agree that your access control to objects works but I'm having this nagging feeling that using it for user access will have weird problems for users. Like a user getting so far into a program before they get an access denied. That may not be a bad thing. I'm just not sure.

        You could check permissions up front, and check it again at the function level as a failsafe. That way, your users won't normally get "far into a program" before getting an error.