| 1 | package Lemonldap::Handlers::RowPolicy; | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | our $VERSION = '3.1.1'; | ||
| 5 | our $VERSION_LEMONLDAP = "3.1"; | ||
| 6 | our $VERSION_INTERNAL = "1.0"; | ||
| 7 | |||
| 8 | sub get | ||
| 9 | { | ||
| 10 | my $class= shift; | ||
| 11 | my %_param= @_; | ||
| 12 | |||
| 13 | my $self; | ||
| 14 | my $config =$_param{parameters}->{'config'}; | ||
| 15 | my $session= $_param{'session'}; | ||
| 16 | unless ($session) { | ||
| 17 | $self->{response} = 0; #0 time out | ||
| 18 | bless $self,$class; | ||
| 19 | return $self; | ||
| 20 | } | ||
| 21 | my $complement; | ||
| 22 | my $dn = $session->{dn}; | ||
| 23 | $dn =~ s/ //g; | ||
| 24 | # my $major = $config->{ORGANIZATION}; | ||
| 25 | # if( !defined($major) ){ | ||
| 26 | # $major = "authz_headers"; | ||
| 27 | # } | ||
| 28 | # my $minor = lc($config->{APPLCODE}); | ||
| 29 | my $minor = $config->{APPLCODE}; | ||
| 30 | if ( defined($minor) && exists($session->{$minor})) | ||
| 31 | { | ||
| 32 | $complement = $session->{$minor}; | ||
| 33 | #### begin: here for he compatibility with older lemonldap | ||
| 34 | $complement =~ s/#.*//; | ||
| 35 | ### end : here for he compatibility with older lemonldap | ||
| 36 | if ( defined($config->{REGEXPMATRIXPOLICY}) && $complement !~ $config->{REGEXPMATRIXPOLICY} ){ | ||
| 37 | undef $complement; | ||
| 38 | }else{ | ||
| 39 | $self->{response} = 200; | ||
| 40 | } | ||
| 41 | } | ||
| 42 | |||
| 43 | unless (defined $complement) { | ||
| 44 | $complement = '_DENY_'; | ||
| 45 | $self->{response} = 403; #403 = FORBIDDEN 200 = OK | ||
| 46 | $complement = '_ALLOW_' && $self->{response} = '200' if lc($config->{ALLOW}) eq 'all'; | ||
| 47 | undef $complement if ($self->{response} == '403' or $self->{response} == '503' ); | ||
| 48 | } | ||
| 49 | |||
| 50 | $self->{response} = 503 if lc($config->{ALLOW}) eq 'disabled'; | ||
| 51 | undef $complement if ($self->{response} == '403' or $self->{response} == '503' ); | ||
| 52 | $self->{profil} = $complement ; | ||
| 53 | bless $self,$class; | ||
| 54 | return $self; | ||
| 55 | } | ||
| 56 | |||
| 57 | 1; |