3

I want to create a custom authentication module for my SimpleSamlPHP installation, but each time I try to test the module I get this error:

SimpleSAML\Error\Error: UNHANDLEDEXCEPTION

Backtrace:
1 www/_include.php:17 (SimpleSAML_exception_handler)
0 [builtin] (N/A)
Caused by: Exception: Could not resolve 'mymodule:MyAuth': no class named 'SimpleSAML\Module\mymodule\Auth\Source\MyAuth' or 'sspmod_mymodule_Auth_Source_MyAuth'.
Backtrace:
7 lib/SimpleSAML/Module.php:437 (SimpleSAML\Module::resolveClass)
6 lib/SimpleSAML/Auth/Source.php:336 (SimpleSAML\Auth\Source::parseAuthSource)
5 lib/SimpleSAML/Auth/Source.php:382 (SimpleSAML\Auth\Source::getById)
4 lib/SimpleSAML/Auth/Simple.php:66 (SimpleSAML\Auth\Simple::getAuthSource)
3 lib/SimpleSAML/Auth/Simple.php:166 (SimpleSAML\Auth\Simple::login)
2 modules/core/www/authenticate.php:38 (require)
1 lib/SimpleSAML/Module.php:254 (SimpleSAML\Module::process)
0 www/module.php:10 (N/A)

I have followed SimpleSAML's tutorial down to step four where I need to test the module. In my config.php file I am enabling the module like so:

'myauth' => [
    'mymodule:MyAuth'
],

If I change the module name in the config file to one of SimpleSaml's pre-installed modules eg.

'myauth' => [
    'sqlauth:MyAuth'
],

then it works just fine. In fact, if I change the name of my custom module folder to be the same as one of the pre-installed modules and change the namespace path in my module file to reflect that, my module code works just fine. I believe that it has something to do with the namespace in my module file, but I cannot figure it out. I am using SimpleSaml version 1.18.5 and php version 7.2.24 on Ubuntu 18.04.

Ixonstater
  • 33
  • 4
  • What is your module folder name? – Patrick Apr 15 '20 at 14:34
  • simplesamlphp/modules/mymodule – Ixonstater Apr 15 '20 at 15:51
  • You really called you module `mymodule`? – Patrick Apr 15 '20 at 18:04
  • Yes, as per the simplesaml custom module tutorial. The code that I am currently developling is just a proof of concept and once I get it working I will change the names to more sensible values. – Ixonstater Apr 16 '20 at 16:46
  • Normally I would assume your module is missing an `enable` file or had something weird in the name (`-` or mixed case) but that doesn't seem to be the case if a rename it works. `ls simplesamlphp/modules/mymodule/lib/Auth/Source/MyAuth.php` exists? I'd suggest editing `_autoload_modules.php`, and edit `sspmodAutoloadPSR4` to output some debug info to track where it can't find your class. – Patrick Apr 16 '20 at 17:00
  • I did copy the default-enable file from the core directory into my module folder. Would I need to ```require()``` my file somewhere? – Ixonstater Apr 16 '20 at 17:34
  • No, the autoloader (which is in `_autoload_modules.php`) should look for it. Do you happen have a `default-disable` as well? – Patrick Apr 16 '20 at 22:37
  • Not in my custom module, but I do see the ```default-disable``` file in the ```core``` directory. – Ixonstater Apr 17 '20 at 20:33
  • At the risk of sounding patronising, if you cut and paste the code to get it working, did you miss the leading – Adam Sargant Apr 21 '20 at 10:51
  • No, I didn't miss either of those things. Since posting this question my company has decided to move past SimpleSaml and instead use a different library for SAML IDP assertions. – Ixonstater Apr 29 '20 at 21:16

3 Answers3

6

I came across this issue myself; I spent hours on this issue...

To fix your issue; depending on your version of SimpleSAMLphp (as of the latest), the 'default_enable' or 'enable' file in the root of your module will not work. You have to enable your module manually, by adding the following to the config.php file:

<?php
$config = [
  module.enable = [
    'core' => null,
    'saml' => true,
    'customAuth' => true,
  ],
],

This will make your customAuth module work.

For some reason, psr4 autoloaded modules work out-of-the-box (the modules you install using composer etc.).

If you can, avoid simpleSAMLphp and go for something more serious.

Andrew Hardiman
  • 929
  • 1
  • 15
  • 30
Mark
  • 76
  • 1
  • 2
1

Just ran into this myself. The documentation is unclear, but you need to add an "enable" file at the root of your module folder as suggested by Patrick in the comments. It can be a completely empty file just with the name "enable" and nothing in it. On the command line in a Linux/Unix system, you could do this:

touch enable
Paul Burney
  • 1,020
  • 11
  • 16
0

go to your config.php file and enable the module as mark said

<?php
$config = [
module.enable = [
'core' => true,
'saml' => true,
'customauth' => true,
'sqlauth' => true,
],
],

just add sqlauth= true with mark's answer. I had the same issue, I got help from mark's answer and just added this line and my issue was solved. Thanks Mark.

Mesbah
  • 11
  • 3