updateSession + checkboxes checked

This commit is contained in:
Xavier Guimard 2010-09-29 10:09:04 +00:00
parent 431a809a90
commit a406d79d2f
2 changed files with 27 additions and 10 deletions

View File

@ -19,13 +19,18 @@ sub sregHook {
# Refuse federation if rejected by user # Refuse federation if rejected by user
return 0 if ( $self->param('confirm') == -1 ); return 0 if ( $self->param('confirm') == -1 );
# If identity is not trusted, does nothing
return ( 0, $prm ) unless ($is_id); return ( 0, $prm ) unless ($is_id);
$self->lmLog( "SREG start", 'debug' ); $self->lmLog( "SREG start", 'debug' );
# TODO: verify that request has been accepted
my $accepted = 1; my $accepted = 1;
# Check all parameters
while ( my ( $k, $v ) = each %$prm ) { while ( my ( $k, $v ) = each %$prm ) {
# Store policy if provided
if ( $k eq 'policy_url' ) { if ( $k eq 'policy_url' ) {
if ( $v =~ Lemonldap::NG::Common::Regexp::HTTP_URI ) { if ( $v =~ Lemonldap::NG::Common::Regexp::HTTP_URI ) {
$self->{_openIdTrustExtMsg} .= $self->{_openIdTrustExtMsg} .=
@ -33,7 +38,8 @@ sub sregHook {
. &Lemonldap::NG::Portal::_i18n::msg(PM_OPENID_PA) . &Lemonldap::NG::Portal::_i18n::msg(PM_OPENID_PA)
. "&nbsp;:</dt><dd><a href=\"$v\">$v</a></dd></dl>"; . "&nbsp;:</dt><dd><a href=\"$v\">$v</a></dd></dl>";
# TODO: is it important to notify policy changes ? # Question: is it important to notify policy changes ?
# if yes, uncomment this
#my $p = #my $p =
# $self->{sessionInfo}->{"_openidTrust$trust_root\_Policy"}; # $self->{sessionInfo}->{"_openidTrust$trust_root\_Policy"};
#$accepted = 0 unless ( $p and $p eq $v ); #$accepted = 0 unless ( $p and $p eq $v );
@ -42,10 +48,14 @@ sub sregHook {
$self->lmLog( "Bad policy url", 'error' ); $self->lmLog( "Bad policy url", 'error' );
} }
} }
# Parse required attributes
elsif ( $k eq 'required' ) { elsif ( $k eq 'required' ) {
$self->lmLog( "Required attr $v", 'debug' ); $self->lmLog( "Required attr $v", 'debug' );
push @req, split( /,/, $v ); push @req, split( /,/, $v );
} }
# Parse optional attributes
elsif ( $k eq 'optional' ) { elsif ( $k eq 'optional' ) {
$self->lmLog( "Optional attr $v", 'debug' ); $self->lmLog( "Optional attr $v", 'debug' );
push @opt, push @opt,
@ -57,7 +67,7 @@ sub sregHook {
} }
# Check if required keys are valid SREG requests # Check if required keys are valid SREG requests
# TODO: reject bad SREG request ? # Question: reject bad SREG request ? Not done yet
@req = sregfilter( $self, @req ); @req = sregfilter( $self, @req );
@opt = sregfilter( $self, @opt ); @opt = sregfilter( $self, @opt );
@ -125,7 +135,6 @@ sub sregHook {
# Store the value returned # Store the value returned
if ( !defined($agree) or $agree != $ck ) { if ( !defined($agree) or $agree != $ck ) {
$self->{sessionInfo}->{"_openidTrust$trust_root\_$k"} = 1;
$self->updateSession( $self->updateSession(
{ "_openidTrust$trust_root\_$k" => $ck } ); { "_openidTrust$trust_root\_$k" => $ck } );
$agree = $ck; $agree = $ck;
@ -142,6 +151,9 @@ sub sregHook {
$r{$k} = $msg{opt}->{$k}; $r{$k} = $msg{opt}->{$k};
$ag{$k} = 1; $ag{$k} = 1;
} }
elsif ( !defined($agree) ) {
$ag{$k} = 1;
}
else { else {
$ag{$k} = 0; $ag{$k} = 0;
} }
@ -178,6 +190,10 @@ sub sregHook {
} }
} }
## @method private array sregfilter(array attr)
# Filter the arguments passed as parameters by checking their compliance with
# SREG.
# @return fitered datas
sub sregfilter { sub sregfilter {
my ( $self, @attr ) = splice @_; my ( $self, @attr ) = splice @_;
my ( @ret, @rej ); my ( @ret, @rej );

View File

@ -781,11 +781,13 @@ sub updateSession {
my ( $self, $infos, $id ) = splice @_; my ( $self, $infos, $id ) = splice @_;
my %cookies = fetch CGI::Cookie; my %cookies = fetch CGI::Cookie;
# Session ID # Update sessionInfo datas
unless ($id) { $self->{sessionInfo}->{$_} = $infos->{$_} unless ($id);
$id = $cookies{ $self->{cookieName} }->value
if defined $cookies{ $self->{cookieName} }; # Recover session ID unless given
} $id ||= $self->{id};
$id ||= $cookies{ $self->{cookieName} }->value
if ( defined $cookies{ $self->{cookieName} } );
if ($id) { if ($id) {
my $h = $self->getApacheSession( $id, 1 ) or return undef; my $h = $self->getApacheSession( $id, 1 ) or return undef;
@ -800,7 +802,6 @@ sub updateSession {
untie %$h; untie %$h;
} }
} }
## @method void addSessionValue(string key, string value, string id) ## @method void addSessionValue(string key, string value, string id)