diff --git a/collections/committee.yml b/collections/committee.yml index 908370d2..2b7bd88a 100644 --- a/collections/committee.yml +++ b/collections/committee.yml @@ -15,6 +15,10 @@ fields: type: string unique: true restriction_mode: A + identity_key: + type: string + restriction_mode: A + description: Mainly used by idm matching. A committee is assigned when the users IDP identity value (see organization/idm_identity_key) starts with this string. meeting_ids: type: relation-list to: meeting/committee_id diff --git a/collections/idm_condition.yml b/collections/idm_condition.yml new file mode 100644 index 00000000..99d451da --- /dev/null +++ b/collections/idm_condition.yml @@ -0,0 +1,21 @@ +fields: + id: + type: number + restriction_mode: A + constant: true + required: true + idm_field: + type: string + required: true + restriction_mode: A + regex: + type: string + required: true + description: Assertation regex to match against the idm_fields value. + restriction_mode: A + mapper_id: + type: relation + to: idm_mapper/condition_ids + restriction_mode: A + required: true + reference: idm_mapper diff --git a/collections/idm_mapper.yml b/collections/idm_mapper.yml new file mode 100644 index 00000000..e402e721 --- /dev/null +++ b/collections/idm_mapper.yml @@ -0,0 +1,28 @@ +fields: + id: + type: number + restriction_mode: A + constant: true + required: true + group_external_ids: + type: string[] + required: true + restriction_mode: A + weight: + type: number + default: 10000 + restriction_mode: A + organization_id: + type: relation + to: organization/idm_mapper_ids + required: true + restriction_mode: A + reference: organization + condition_ids: + type: relation-list + to: idm_condition/mapper_id + restriction_mode: A + mapping_ids: + type: relation-list + to: idm_mapping/mapper_id + restriction_mode: A diff --git a/collections/idm_mapping.yml b/collections/idm_mapping.yml new file mode 100644 index 00000000..f51ef3a1 --- /dev/null +++ b/collections/idm_mapping.yml @@ -0,0 +1,36 @@ +fields: + id: + type: number + restriction_mode: A + constant: true + required: true + idm_field: + type: string + required: true + restriction_mode: A + os_field: + type: string + enum: + - groups + - structure_levels + - number + - vote_weight + - present + - comment + required: true + restriction_mode: A + default_value: + type: string + restriction_mode: A + allow_update: + type: boolean + restriction_mode: A + override_default: + type: boolean + restriction_mode: A + mapper_id: + type: relation + to: idm_mapper/mapping_ids + restriction_mode: A + required: true + reference: idm_mapper diff --git a/collections/meeting.yml b/collections/meeting.yml index b1c70d50..258c8a04 100644 --- a/collections/meeting.yml +++ b/collections/meeting.yml @@ -86,6 +86,10 @@ fields: custom_translations: type: JSON restriction_mode: B + enable_idm_matching: + type: boolean + default: false + restriction_mode: E # Jitsi/Livestream settings conference_show: type: boolean diff --git a/collections/organization.yml b/collections/organization.yml index 453022cd..3ed2d27e 100644 --- a/collections/organization.yml +++ b/collections/organization.yml @@ -90,6 +90,22 @@ fields: saml_private_key: type: text restriction_mode: D + idm_identity_key: + type: string + restriction_mode: C + description: Attribute in the idm data that identifies the user. Used to match against committees identity_key to determine membership. + idm_organization_managment_key: + type: string + restriction_mode: C + description: String attribute in the idm data that identifies the users organization management level. Accepted values are 'can_manage_organization' and 'can_manage_users'. All other values, including 'superadmin', are not accepted. + idm_committee_management_key: + type: string + restriction_mode: C + description: Attribute in the idm data that identifies the users committee management rights. Formatted as a list of exact committee identity_keys. + idm_mapper_ids: + type: relation-list + to: idm_mapper/organization_id + restriction_mode: C committee_ids: type: relation-list to: committee/organization_id diff --git a/dev/sql/schema_relational.sql b/dev/sql/schema_relational.sql index 4437d099..08ad759d 100644 --- a/dev/sql/schema_relational.sql +++ b/dev/sql/schema_relational.sql @@ -1,7 +1,7 @@ -- schema_relational.sql for initial database setup OpenSlides -- Code generated. DO NOT EDIT. --- MODELS_YML_CHECKSUM = '6d57fc1334aa53d0f1ff08b541766955' +-- MODELS_YML_CHECKSUM = '41a28b58c23d837b10c5bc9a3e899a19' -- ENUM definitions @@ -22,6 +22,8 @@ CREATE TYPE enum_assignment_phase AS ENUM ('search', 'voting', 'finished'); CREATE TYPE enum_group_permissions AS ENUM ('agenda_item.can_manage', 'agenda_item.can_see', 'agenda_item.can_see_internal', 'assignment.can_manage', 'assignment.can_manage_polls', 'assignment.can_nominate_other', 'assignment.can_nominate_self', 'assignment.can_see', 'chat.can_manage', 'list_of_speakers.can_be_speaker', 'list_of_speakers.can_manage', 'list_of_speakers.can_see', 'list_of_speakers.can_manage_moderator_notes', 'list_of_speakers.can_see_moderator_notes', 'mediafile.can_manage', 'mediafile.can_see', 'meeting.can_manage_logos_and_fonts', 'meeting.can_manage_settings', 'meeting.can_see_autopilot', 'meeting.can_see_frontpage', 'meeting.can_see_history', 'meeting.can_see_livestream', 'motion.can_create', 'motion.can_create_amendments', 'motion.can_forward', 'motion.can_manage', 'motion.can_manage_metadata', 'motion.can_manage_polls', 'motion.can_see', 'motion.can_see_internal', 'motion.can_see_origin', 'motion.can_support', 'poll.can_manage', 'poll.can_see_progress', 'projector.can_manage', 'projector.can_see', 'tag.can_manage', 'user.can_manage', 'user.can_manage_presence', 'user.can_see_sensitive_data', 'user.can_see', 'user.can_update', 'user.can_edit_own_delegation'); +CREATE TYPE enum_idm_mapping_os_field AS ENUM ('groups', 'structure_levels', 'number', 'vote_weight', 'present', 'comment'); + CREATE TYPE enum_import_preview_name AS ENUM ('account', 'participant', 'topic', 'committee', 'motion'); CREATE TYPE enum_import_preview_state AS ENUM ('warning', 'error', 'done'); @@ -1037,6 +1039,7 @@ CREATE TABLE committee_t ( description text, external_id varchar(256) CONSTRAINT unique_committee_external_id UNIQUE, + identity_key varchar(256), default_meeting_id integer CONSTRAINT unique_committee_default_meeting_id UNIQUE, parent_id integer, @@ -1047,6 +1050,8 @@ CREATE TABLE committee_t ( +comment on column committee_t.identity_key is 'Mainly used by idm matching. A committee is assigned when the users IDP identity value (see organization/idm_identity_key) starts with this string.'; + CREATE TABLE gender_t ( id integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY NOT NULL, @@ -1110,6 +1115,50 @@ CREATE TABLE history_position_t ( +CREATE TABLE idm_condition_t ( + id integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY NOT NULL, + idm_field varchar(256) + CONSTRAINT required_idm_condition_idm_field NOT NULL, + regex varchar(256) + CONSTRAINT required_idm_condition_regex NOT NULL, + mapper_id integer + CONSTRAINT required_idm_condition_mapper_id NOT NULL +); + + + +comment on column idm_condition_t.regex is 'Assertation regex to match against the idm_fields value.'; + + +CREATE TABLE idm_mapper_t ( + id integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY NOT NULL, + group_external_ids varchar(256)[] + CONSTRAINT required_idm_mapper_group_external_ids NOT NULL, + weight integer + CONSTRAINT default_idm_mapper_weight DEFAULT 10000, + organization_id integer + CONSTRAINT required_idm_mapper_organization_id NOT NULL +); + + + + +CREATE TABLE idm_mapping_t ( + id integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY NOT NULL, + idm_field varchar(256) + CONSTRAINT required_idm_mapping_idm_field NOT NULL, + os_field enum_idm_mapping_os_field + CONSTRAINT required_idm_mapping_os_field NOT NULL, + default_value varchar(256), + allow_update boolean, + override_default boolean, + mapper_id integer + CONSTRAINT required_idm_mapping_mapper_id NOT NULL +); + + + + CREATE TABLE import_preview_t ( id integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY NOT NULL, name enum_import_preview_name @@ -1220,6 +1269,8 @@ CREATE TABLE meeting_t ( enable_anonymous boolean CONSTRAINT default_meeting_enable_anonymous DEFAULT False, custom_translations jsonb, + enable_idm_matching boolean + CONSTRAINT default_meeting_enable_idm_matching DEFAULT False, conference_show boolean CONSTRAINT default_meeting_conference_show DEFAULT False, conference_auto_connect boolean @@ -1924,6 +1975,9 @@ CREATE TABLE organization_t ( saml_metadata_idp text, saml_metadata_sp text, saml_private_key text, + idm_identity_key varchar(256), + idm_organization_managment_key varchar(256), + idm_committee_management_key varchar(256), theme_id integer CONSTRAINT required_organization_theme_id NOT NULL CONSTRAINT unique_organization_theme_id UNIQUE, @@ -1951,6 +2005,9 @@ This email was generated automatically.', comment on column organization_t.limit_of_meetings is 'Maximum of active meetings for the whole organization. 0 means no limitation at all'; comment on column organization_t.limit_of_users is 'Maximum of active users for the whole organization. 0 means no limitation at all'; +comment on column organization_t.idm_identity_key is 'Attribute in the idm data that identifies the user. Used to match against committees identity_key to determine membership.'; +comment on column organization_t.idm_organization_managment_key is 'String attribute in the idm data that identifies the users organization management level. Accepted values are "can_manage_organization" and "can_manage_users". All other values, including "superadmin", are not accepted.'; +comment on column organization_t.idm_committee_management_key is 'Attribute in the idm data that identifies the users committee management rights. Formatted as a list of exact committee identity_keys.'; CREATE TABLE organization_tag_t ( @@ -3030,6 +3087,18 @@ CREATE VIEW "history_position" AS SELECT *, FROM history_position_t h; +CREATE VIEW "idm_condition" AS SELECT * FROM idm_condition_t i; + + +CREATE VIEW "idm_mapper" AS SELECT *, +(select array_agg(ic.id ORDER BY ic.id) from idm_condition_t ic where ic.mapper_id = i.id) as condition_ids, +(select array_agg(im.id ORDER BY im.id) from idm_mapping_t im where im.mapper_id = i.id) as mapping_ids +FROM idm_mapper_t i; + + +CREATE VIEW "idm_mapping" AS SELECT * FROM idm_mapping_t i; + + CREATE VIEW "import_preview" AS SELECT * FROM import_preview_t i; @@ -3253,6 +3322,7 @@ FROM option_t o; CREATE VIEW "organization" AS SELECT *, (select array_agg(g.id ORDER BY g.id) from gender_t g where g.organization_id = o.id) as gender_ids, +(select array_agg(i.id ORDER BY i.id) from idm_mapper_t i where i.organization_id = o.id) as idm_mapper_ids, (select array_agg(c.id ORDER BY c.id) from committee_t c where c.organization_id = o.id) as committee_ids, (select array_agg(m.id ORDER BY m.id) from meeting_t m where m.is_active_in_organization_id = o.id) as active_meeting_ids, (select array_agg(m.id ORDER BY m.id) from meeting_t m where m.is_archived_in_organization_id = o.id) as archived_meeting_ids, @@ -3471,6 +3541,15 @@ CREATE INDEX idx_history_entry_t_meeting_id ON history_entry_t (meeting_id); ALTER TABLE history_position_t ADD CONSTRAINT fk_history_position_t_user_id_user_t_id FOREIGN KEY(user_id) REFERENCES user_t(id) INITIALLY DEFERRED; CREATE INDEX idx_history_position_t_user_id ON history_position_t (user_id); +ALTER TABLE idm_condition_t ADD CONSTRAINT fk_idm_condition_t_mapper_id_idm_mapper_t_id FOREIGN KEY(mapper_id) REFERENCES idm_mapper_t(id) INITIALLY DEFERRED; +CREATE INDEX idx_idm_condition_t_mapper_id ON idm_condition_t (mapper_id); + +ALTER TABLE idm_mapper_t ADD CONSTRAINT fk_idm_mapper_t_organization_id_organization_t_id FOREIGN KEY(organization_id) REFERENCES organization_t(id) INITIALLY DEFERRED; +CREATE INDEX idx_idm_mapper_t_organization_id ON idm_mapper_t (organization_id); + +ALTER TABLE idm_mapping_t ADD CONSTRAINT fk_idm_mapping_t_mapper_id_idm_mapper_t_id FOREIGN KEY(mapper_id) REFERENCES idm_mapper_t(id) INITIALLY DEFERRED; +CREATE INDEX idx_idm_mapping_t_mapper_id ON idm_mapping_t (mapper_id); + ALTER TABLE list_of_speakers_t ADD CONSTRAINT fk_list_of_speakers_t_content_object_id_motion_id_motion_t_id FOREIGN KEY(content_object_id_motion_id) REFERENCES motion_t(id) INITIALLY DEFERRED; CREATE INDEX idx_list_of_speakers_t_content_object_id_motion_id ON list_of_speakers_t (content_object_id_motion_id); ALTER TABLE list_of_speakers_t ADD CONSTRAINT fk_list_of_speakers_t_content_object_id_motion_block_id_62f90e7 FOREIGN KEY(content_object_id_motion_block_id) REFERENCES motion_block_t(id) INITIALLY DEFERRED; @@ -4677,6 +4756,36 @@ DEFERRABLE INITIALLY DEFERRED FOR EACH ROW EXECUTE FUNCTION notify_transaction_e CREATE TRIGGER tr_log_history_position_user_id AFTER INSERT OR UPDATE OF user_id OR DELETE ON history_position_t FOR EACH ROW EXECUTE FUNCTION log_modified_related_models('user', 'user_id', 'history_position_ids'); +-- notify triggers for idm_condition_t fields +CREATE TRIGGER tr_log_idm_condition AFTER INSERT OR UPDATE OR DELETE ON idm_condition_t +FOR EACH ROW EXECUTE FUNCTION log_modified_models('idm_condition'); +CREATE CONSTRAINT TRIGGER notify_transaction_end AFTER INSERT OR UPDATE OR DELETE ON idm_condition_t +DEFERRABLE INITIALLY DEFERRED FOR EACH ROW EXECUTE FUNCTION notify_transaction_end(); + +-- notify trigger for idm_condition_t.mapper_id +CREATE TRIGGER tr_log_idm_condition_mapper_id AFTER INSERT OR UPDATE OF mapper_id OR DELETE ON idm_condition_t +FOR EACH ROW EXECUTE FUNCTION log_modified_related_models('idm_mapper', 'mapper_id', 'condition_ids'); + +-- notify triggers for idm_mapper_t fields +CREATE TRIGGER tr_log_idm_mapper AFTER INSERT OR UPDATE OR DELETE ON idm_mapper_t +FOR EACH ROW EXECUTE FUNCTION log_modified_models('idm_mapper'); +CREATE CONSTRAINT TRIGGER notify_transaction_end AFTER INSERT OR UPDATE OR DELETE ON idm_mapper_t +DEFERRABLE INITIALLY DEFERRED FOR EACH ROW EXECUTE FUNCTION notify_transaction_end(); + +-- notify trigger for idm_mapper_t.organization_id +CREATE TRIGGER tr_log_idm_mapper_organization_id AFTER INSERT OR UPDATE OF organization_id OR DELETE ON idm_mapper_t +FOR EACH ROW EXECUTE FUNCTION log_modified_related_models('organization', 'organization_id', 'idm_mapper_ids'); + +-- notify triggers for idm_mapping_t fields +CREATE TRIGGER tr_log_idm_mapping AFTER INSERT OR UPDATE OR DELETE ON idm_mapping_t +FOR EACH ROW EXECUTE FUNCTION log_modified_models('idm_mapping'); +CREATE CONSTRAINT TRIGGER notify_transaction_end AFTER INSERT OR UPDATE OR DELETE ON idm_mapping_t +DEFERRABLE INITIALLY DEFERRED FOR EACH ROW EXECUTE FUNCTION notify_transaction_end(); + +-- notify trigger for idm_mapping_t.mapper_id +CREATE TRIGGER tr_log_idm_mapping_mapper_id AFTER INSERT OR UPDATE OF mapper_id OR DELETE ON idm_mapping_t +FOR EACH ROW EXECUTE FUNCTION log_modified_related_models('idm_mapper', 'mapper_id', 'mapping_ids'); + -- notify triggers for import_preview_t fields CREATE TRIGGER tr_log_import_preview AFTER INSERT OR UPDATE OR DELETE ON import_preview_t FOR EACH ROW EXECUTE FUNCTION log_modified_models('import_preview'); @@ -6208,6 +6317,14 @@ FIELD 1r:nt => history_entry/meeting_id:-> meeting/relevant_history_entry_ids FIELD 1r:nt => history_position/user_id:-> user/history_position_ids SQL nt:1rR => history_position/entry_ids:-> history_entry/position_id +FIELD 1rR:nt => idm_condition/mapper_id:-> idm_mapper/condition_ids + +FIELD 1rR:nt => idm_mapper/organization_id:-> organization/idm_mapper_ids +SQL nt:1rR => idm_mapper/condition_ids:-> idm_condition/mapper_id +SQL nt:1rR => idm_mapper/mapping_ids:-> idm_mapping/mapper_id + +FIELD 1rR:nt => idm_mapping/mapper_id:-> idm_mapper/mapping_ids + FIELD 1GrR:1tR,1tR,1tR,1tR,1t => list_of_speakers/content_object_id:-> motion/list_of_speakers_id,motion_block/list_of_speakers_id,assignment/list_of_speakers_id,topic/list_of_speakers_id,meeting_mediafile/list_of_speakers_id SQL nt:1rR => list_of_speakers/speaker_ids:-> speaker/list_of_speakers_id SQL nt:1rR => list_of_speakers/structure_level_list_of_speakers_ids:-> structure_level_list_of_speakers/list_of_speakers_id @@ -6448,6 +6565,7 @@ FIELD 1Gr:nr,nr,1tR => option/content_object_id:-> motion/option_ids,user/option FIELD 1rR:nr => option/meeting_id:-> meeting/option_ids SQL nr:1rR => organization/gender_ids:-> gender/organization_id +SQL nt:1rR => organization/idm_mapper_ids:-> idm_mapper/organization_id SQL nr:1rR => organization/committee_ids:-> committee/organization_id SQL nt:1r => organization/active_meeting_ids:-> meeting/is_active_in_organization_id SQL nt:1r => organization/archived_meeting_ids:-> meeting/is_archived_in_organization_id