we are developing an Indico plugin for automatic group assignmed for SSO logins based on this idea which should be generic, e.g. allow to configure the identity provider it is acting on and the domain / realm it is filtering for (so it can be re-used by others, and maybe also upstreamed). It’ll include full coverage by tests and optional automatic cleanup of old group assignments (e.g. in case users change their organisation and use a different EduGain IdP to log in).
The plugin is mostly ready, but I have a problem populating a
SelectField with the
multipass.identity_providers list. Here’s what I’m doing right now:
class SettingsForm(IndicoForm): identity_provider = SelectField(_('Provider'), [InputRequired()], description=_('The identity provider accounts need to be ' 'associated with to be added to the group.')) class SSOGroupMappingPlugin(IndicoPlugin): ... def init(self): identity_providers = multipass.identity_providers.values() if not identity_providers: del self.settings_form.identity_provider idp_choices = [(p.name, p.title) for p in sorted(identity_providers, key=attrgetter('title'))] self.settings_form.identity_provider.choices = idp_choices super().init()
(you can find the full code here)
I have a
pytest which confirms the
choices variable is filled with the expected tuple:
Running this in an actual installation and adding a
However, when actually installing the plugin in a real instance and then entering plugin configuration, the
SelectField remains empty.
Am I missing something in terms of execution order? Is there a different way to dynamically populate a
Thanks in advance and cheers,