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

add multi-valued federations column

parent 05bdbbce
No related branches found
No related tags found
No related merge requests found
...@@ -86,25 +86,35 @@ foreach my $id (split(/, */, $configuration->{groups}->{list})) { ...@@ -86,25 +86,35 @@ foreach my $id (split(/, */, $configuration->{groups}->{list})) {
} }
foreach my $entry (@$entities) { foreach my $entry (@$entities) {
# skip duplicates
next if $seen{$entry->{entityid}}++;
# skip entities different from SP or IdP # skip entities different from SP or IdP
next if !$entry->{type}; next if !$entry->{type};
my $entity = AccountManager::Entity->new( my $entity;
db => $db, if ($seen{$entry->{entityid}}++) {
type => $entry->{type}, $entity = AccountManager::Entity->new(
entityid => $entry->{entityid}, db => $db,
displayname => $entry->{display_name}, entityid => $entry->{entityid},
information_url => $entry->{information_url}, );
organization_url => $entry->{organization_url}, $entity->load();
); $entity->federations(
$entity->federations(), $id
$entity->contacts(uniq map { $_->{EmailAddress} } @{$entry->{contacts}}) );
if $entry->{contacts}; $entity->update();
} else {
$entity = AccountManager::Entity->new(
db => $db,
type => $entry->{type},
entityid => $entry->{entityid},
displayname => $entry->{display_name},
information_url => $entry->{information_url},
organization_url => $entry->{organization_url},
);
$entity->contacts(uniq map { $_->{EmailAddress} } @{$entry->{contacts}})
if $entry->{contacts};
$entity->federations($id);
$entity->save();
}
$entity->save();
} }
} }
......
...@@ -19,8 +19,9 @@ CREATE TABLE entities ( ...@@ -19,8 +19,9 @@ CREATE TABLE entities (
organization_url varchar(200) DEFAULT NULL, organization_url varchar(200) DEFAULT NULL,
displayname varchar(500) DEFAULT NULL, displayname varchar(500) DEFAULT NULL,
contacts varchar(2000) DEFAULT NULL, contacts varchar(2000) DEFAULT NULL,
federations varchar(50) DEFAULT NULL,
PRIMARY KEY (id), PRIMARY KEY (id),
UNIQUE KEY entityid (entityid) KEY entityid (entityid)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ; ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ;
CREATE TABLE accounts ( CREATE TABLE accounts (
......
...@@ -19,6 +19,7 @@ __PACKAGE__->meta->setup( ...@@ -19,6 +19,7 @@ __PACKAGE__->meta->setup(
information_url => { type => 'varchar', length => 200 }, information_url => { type => 'varchar', length => 200 },
organization_url => { type => 'varchar', length => 200 }, organization_url => { type => 'varchar', length => 200 },
contacts => { type => 'array' }, contacts => { type => 'array' },
federations => { type => 'array' },
], ],
primary_key_columns => [ 'id' ], primary_key_columns => [ 'id' ],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment