Changeset 479


Ignore:
Timestamp:
10/04/09 05:01:12 (15 years ago)
Author:
nanardon
Message:
  • create and delete keyword colapse with attribute name, prefixing action by an '@' in acls
Location:
LATMOS-Accounts
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • LATMOS-Accounts/MANIFEST

    r446 r479  
    77annexes/sql.schema.sql 
    88bin/la-acls 
     9bin/la-attributes 
    910bin/la-config 
    1011bin/la-create 
  • LATMOS-Accounts/lib/LATMOS/Accounts/Acls.pm

    r478 r479  
    3333enclose into bracket, either a '*' to match any attribute. 
    3434 
    35 Special keyword C<CREATE> and C<DELETE> can be used to allow or deny object 
     35Special keyword C<@CREATE> and C<@DELETE> can be used to allow or deny object 
    3636creation and deletion. In this case USER in form C<$...> and read permission 
    37 have no effect (see below). C<*> do not include C<CREATE> and C<DELETE> action. 
     37have no effect (see below). C<*> do not include C<@CREATE> and C<@DELETE> action. 
    3838 
    3939=item USER can be 
     
    127127sub check { 
    128128    my ($self, $obj, $attr, $perm, $who, $groups) = @_; 
     129    # Asking 'r' perm over create or delete has no sense: 
     130    $attr =~ /^@(CREATE|DELETE)$/ && $perm eq 'r' and return; 
     131 
    129132    foreach my $acl (@{$self->{_acls}}) { 
    130133        my $res = $acl->match($obj, $attr, $perm, $who, $groups); 
     
    188191    my $objtype = ref $obj ? lc($obj->type) : $obj; 
    189192    $attr = lc($attr); 
     193 
     194    # Does this ACL series concern this object: 
    190195    if (!($self->{obj} eq '*' || $self->{obj} eq $objtype)) { 
    191196        return 
    192197    } 
    193     grep { ($_ !~ /^(CREATE|DELETE)$/ && $_ eq '*') || $_ eq $attr } @{$self->{attr}} or return; 
    194  
     198    # Does this ACL series concern this attribute: 
     199    grep { ($_ !~ /^@(CREATE|DELETE)$/ && $_ eq '*') || $_ eq $attr } @{$self->{attr}} or return; 
     200 
     201    # Foreach user, testing if this permission match: 
    195202    foreach my $u (@{ $self->{users} }) { 
     203        # Obj have attr eq login user 
    196204        if (substr($u->{user}, 0, 1) eq '$') { # check attr content 
    197205            if (ref $obj) { 
     
    201209                return ($u->{$perm} || 0) if (grep { $_ eq $who } @vals); 
    202210            } 
     211        # user is in group 
    203212        } elsif (substr($u->{user}, 0, 1) eq '%') { # group 
    204213            my $group = substr($u->{user}, 1); 
    205214            return ($u->{$perm} || 0) if (grep { $group eq $_ } @{$groups ||[]}); 
     215        # any user 
    206216        } elsif ($u->{user} eq '*' || $u->{user} eq $who) { 
    207217            return $u->{$perm} || 0; 
     218        # any authenticated user 
    208219        } elsif (lc($u->{user}) eq '@authenticated' && $who) { 
    209220            return $u->{$perm} || 0; 
     221        # not login 
    210222        } elsif (lc($u->{user}) eq '@anonymous' && $who eq "") { 
    211223            return $u->{$perm} || 0; 
Note: See TracChangeset for help on using the changeset viewer.