pitbulk / moodle_saml

SAML plugins for moodle (authentication and enrollment)
12 stars 24 forks source link

Allow for relative samlhookfile #33

Closed hcpss-banderson closed 7 years ago

hcpss-banderson commented 9 years ago

Right now, only absolute paths will work for the setting samlhookfile. That is because when the setting is used it's used from moodle/auth/saml directory, but when the input is validated, it's validated from moodle/admin. So, my value of "../../local/myplugin/auth_hooks.php" is valid and will work, but fails validation on the settings form.

I placed my hook file in a custom local plugin. The fact that I have to use an absolute path ties my hands in my development and staging environments. I have to install Moodle in the exact same place.

To fix this, maybe the plugin could assume that if the path does not begin with a "/" (or "\" on Windows?) then the path is relative to dirroot.

Or it could be more explicit and use a token. Like a valid value could be "[dirroot]/local/myplugin/auth_hooks.php" and that's expanded to $CFG->dirroot . '/local/myplugin/auth_hooks.php' for use and for validation.

What do you think?

pitbulk commented 9 years ago

I'm ok for the / or \ detection and assume this gonna be relative. Do you want to create a PR for that?

hcpss-banderson commented 9 years ago

Sure will. Thanks.