catalyst / moodle-auth_saml2

SAML done 100% in Moodle, fast, simple, secure
https://moodle.org/plugins/auth_saml2
70 stars 132 forks source link

What is the best way to filter user attributes? #743

Open jderriks opened 1 year ago

jderriks commented 1 year ago

Hi there,

Simple saml question:

I added three lines to classes/auth.php to change the schacPersonalUniqueCode to a student number:

        if (isset($attributes["schacPersonalUniqueCode"][0])){
                $studid = $attributes["schacPersonalUniqueCode"][0];
                $attributes["schacPersonalUniqueCode"][0] = preg_replace("/.*:/", "", $studid);
        }

So that urn:schac:personalUniqueCode:nl:local:diy.surfconext.nl:studentid:123456 becomes the number after the last colon.

But every time the plugin is updated, changes to the auth.php are gone of course.

What is the best way to filter non-standard attributes without creating extra plugins so that changes will remain intact after a Moodle update?

We need the last part of schacPersonalUniqueCode as the Moodle ID number field:

afbeelding

But now the ID number is the complete raw attribute name as: afbeelding

Current workaround in auth.php works until the next plugin update. There must be an easier way using a config that doesn't change on updates.

jderriks commented 1 year ago

Note: The example code in readme.md contains 2 syntax errors.