Dear Omeka S community,
We have a use case where we want to have a site’s content available to ( LDAP-)authenticated users only.
I found the module RestricedSites module that seems useful for this scenario.
With the RestrictedSites module, one should authorize users in the Site Settings - User permissions, giving them at least Viewer
permission.
What I would like to achieve is that a LDAP-authenticated user is automatically authorized for the site.
In other words, I would like to make use of the ‘ldap.user.create.pre’ event and attach a listener that assigns the respective user the site’s Viewer role.
This is my current code in Module.php
:
public function attachListeners(SharedEventManagerInterface $sharedEventManager) {
$sharedEventManager->attach(
//The class identifier that triggers the event:
'Ldap\Authentication\Adapter\LdapAdapter',
// The named event identifier to listen to:
'ldap.user.create.pre',
// Any callback for the event (= action to take when the event occurs)
function () {
$logger = $this->getServiceLocator()->get('Omeka\Logger');
$logger->info("Successfully attached to the event 'ldap.user.create.pre'");
// TODO: Give the current user Viewer role on the site permissions
}
);
}
At this stage I am not sure how to proceed. Is there already a class-method that I can use at this place? Should I create my own function?
Any help is appreciated.
Thank you very much.
Best regards,
Maarten Coonen, Maastricht University Library