Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SimpleSamlPHP not resolving custom authentication module

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.

like image 973
Ixonstater Avatar asked Nov 08 '25 09:11

Ixonstater


1 Answers

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.

like image 129
Mark Avatar answered Nov 12 '25 16:11

Mark



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!