Skip to content
Snippets Groups Projects
Commit a5e53a5d authored by Guillaume ROUSSE's avatar Guillaume ROUSSE
Browse files

replace contacts on the fly if needed

parent f02f2ee9
Branches
Tags
No related merge requests found
...@@ -270,7 +270,7 @@ sub req_select_sp { ...@@ -270,7 +270,7 @@ sub req_select_sp {
if (!@$sps) { if (!@$sps) {
push @{ $self->{out}->{errors} }, "no_such_entity"; push @{ $self->{out}->{errors} }, "no_such_entity";
$self->{logger}->errorf( $self->{logger}->errorf(
"No such entity %s in metadata", $self->{in}->{sp_entityid} "No such SP '%s' in metadata", $self->{in}->{sp_entityid}
); );
return undef; return undef;
} }
...@@ -319,22 +319,26 @@ sub req_generate_token { ...@@ -319,22 +319,26 @@ sub req_generate_token {
return undef; return undef;
} }
## Create a serviceprovider object to load parameters for this SP from DB my $provider = IdPAccountManager::Data::ServiceProvider->new(
my $service_provider = IdPAccountManager::Data::ServiceProvider->new( db => $self->{db},
db => $self->{db}, entityid => $self->{in}->{sp_entityid},
entityid => $self->{in}->{sp_entityid},
dev_sp_contact => $self->{configuration}->{dev_sp_contact}
); );
# Try loading DB object first unless ($provider->load(speculative => 1)) {
unless ($service_provider->load(speculative => 1)) { push @{ $self->{out}->{errors} }, "no_such_entity";
push @{ $self->{out}->{errors} }, "internal"; $self->{logger}->errorf("No such SP '%s' in database", $self->{in}->{sp_entityid});
$self->{logger}->errorf("Failed to load SP with entityid '%s'", $self->{in}->{sp_entityid});
return undef; return undef;
} }
if ($self->{configuration}->{dev_sp_contact}) {
# replace SP contacts
$provider->contacts(
split(/, */, $self->{configuration}->{dev_sp_contact})
);
}
## Check that email_address is a known contact for this SP ## Check that email_address is a known contact for this SP
unless ($service_provider->is_contact($self->{in}->{email_address})) unless ($provider->is_contact($self->{in}->{email_address}))
{ {
push @{ $self->{out}->{errors} }, "internal"; push @{ $self->{out}->{errors} }, "internal";
$self->{logger}->errorf( $self->{logger}->errorf(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment