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

allow to link another eAC instance for a given federation

parent a8720b8a
No related branches found
No related tags found
No related merge requests found
......@@ -260,53 +260,60 @@ sub req_select_sp {
my %groups;
my @self_entities;
foreach my $federation (@federations) {
my $file = $self->get_metadata_file(federation => $federation);
my $metadata;
eval {
$metadata = AccountManager::Metadata->new(
file => $file
);
};
$self->abort(
log => "Failed to load federation metadata: $EVAL_ERROR",
user => "internal"
) if $EVAL_ERROR;
my $entities = $metadata->parse(type => 'sp');
$groups{$federation} = {
label => $self->{configuration}->{$federation}->{label},
entities => [
map { {
id => $_->{entityid},
name => $_->{display_name},
federation => $federation
} } @$entities
]
};
if ($self->{configuration}->{$federation}->{metadata}) {
my $file = $self->get_metadata_file(federation => $federation);
# if user is authenticated, and its IdP is found in metadata,
# push all entities with the same organization URL in a list
if ($ENV{HTTP_SHIB_IDENTITY_PROVIDER}) {
my $idps = $metadata->parse(id => $ENV{HTTP_SHIB_IDENTITY_PROVIDER});
my $idp = $idps->[0];
if ($idp) {
my $organization = $idp->{organization};
$self->{logger}->debugf(
"idp %s found in federation %s metadata with organization %s",
$ENV{HTTP_SHIB_IDENTITY_PROVIDER},
$federation,
$organization
my $metadata;
eval {
$metadata = AccountManager::Metadata->new(
file => $file
);
push @self_entities,
};
$self->abort(
log => "Failed to load federation metadata: $EVAL_ERROR",
user => "internal"
) if $EVAL_ERROR;
my $entities = $metadata->parse(type => 'sp');
$groups{$federation} = {
label => $self->{configuration}->{$federation}->{label},
entities => [
map { {
id => $_->{entityid},
name => $_->{display_name},
federation => $federation
} }
grep { $_->{organization} eq $organization }
@$entities;
} } @$entities
]
};
# if user is authenticated, and its IdP is found in metadata,
# push all entities with the same organization URL in a list
if ($ENV{HTTP_SHIB_IDENTITY_PROVIDER}) {
my $idps = $metadata->parse(id => $ENV{HTTP_SHIB_IDENTITY_PROVIDER});
my $idp = $idps->[0];
if ($idp) {
my $organization = $idp->{organization};
$self->{logger}->debugf(
"idp %s found in federation %s metadata with organization %s",
$ENV{HTTP_SHIB_IDENTITY_PROVIDER},
$federation,
$organization
);
push @self_entities,
map { {
id => $_->{entityid},
name => $_->{display_name},
federation => $federation
} }
grep { $_->{organization} eq $organization }
@$entities;
}
}
} elsif ($self->{configuration}->{$federation}->{link}) {
$groups{$federation} = {
label => $self->{configuration}->{$federation}->{label},
link => $self->{configuration}->{$federation}->{link},
};
}
}
......
......@@ -17,13 +17,18 @@
[% FOREACH group IN groups.keys.sort() %]
<fieldset>
[% IF groups.$group.entities %]
<legend>[% groups.$group.label %]</legend>
<select id="[% group %]" name="[% group %]">
<option value=""></option>
[% FOREACH entity IN groups.$group.entities.sort('name') %]
[% FOREACH entity IN groups.$group.entities.sort('name') %]
<option value="[% entity.id %]" data-federation="[% entity.federation %]">[% entity.name %]</option>
[% END %]
[% END %]
</select>
[% END %]
[% IF groups.$group.link %]
<a class="button" href="[% groups.$group.link %]">[% groups.$group.label %]</a>
[% END %]
</fieldset>
[% END %]
<input type="hidden" id="federation" name="federation"/>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment