Skip to content

EuropeanUniversityFoundation/myacademicid_user_fields

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MyAcademicID user fields

This module adds funcionality related to MyAcademicID data points that can be leveraged in Drupal applications.

Installation

Include the repository in your project's composer.json file:

"repositories": [
    ...
    {
        "type": "vcs",
        "url": "https://github.com/EuropeanUniversityFoundation/myacademicid_user_fields"
    }
],

Then you can require the package as usual:

composer require euf/myacademicid_user_fields

Finally, install the module:

drush en myacademicid_user_fields

Features and usage

Base fields for the User entity

This module adds new base fields to the User entity that match OpenID Connect claims from MyAcademicID:

  • schac_home_organization;
  • schac_personal_unique_code;
  • voperson_external_affiliation.

The field names follow the convention maid_{claim}.

Event based functionality

This module defines two groups of Events and corresponding EventSubscribers to handle the main use cases:

  • User{Claim}ChangeEvents are dispatched when the corresponding User fields change;
  • the built-in MyacademicidUserFieldsSubscriber logs messages accordingly;
  • SetUser{Claim}Events are dispatched when the corresponding user fields should be set to a given value;
  • the built-in SetUser{Claim}EventSubscribers set the field values if the User entity passes validation.

Access to user fields

This module adds one permission: Administer MyAcademicID user fields.

Users with this permission can edit MyAcademicID user fields (their own or any user's, depending on other core permissions).

Users without this permission will see their MyAcademicID claims printed as plain text in their user account form.

Populating MyAcademicID user fields

For applications relying on the OpenID Connect protocol, the MyAcademicID claims should be mapped to the new base fields, so that any change upon login will propagate across the system.

For applications implementing an OAuth2 Server or similar, this module can be used to set the claims based on the relevant business logic.

Tests

Assuming there is a properly configured phpunit.xml at the project root, run the tests with the following command:

vendor/bin/phpunit web/modules/contrib/myacademicid_user_fields/tests

About

Drupal 9/10 module providing base fields for the User entity to store MyAcademicID data.

Topics

Resources

License

Stars

Watchers

Forks

Languages