-
Notifications
You must be signed in to change notification settings - Fork 282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CustomUserBackend is loaded too late #5265
Comments
Hi Stevie ;)
Yep. Would be my suggestion as well, though.
Have you tried putting the registration of your own backend in |
Yes I tried |
ref/NC/830526 |
So testet it. And the result is the same like written above: Until there is no load order, you can only choose a name for the module that will ensure that it ranks first in an alphabetical list like the result of this call
|
Works, for me. 😁 I've put this in
Which refers to this class:
And last but not least, an entry in
Now everyone accessing my Web is an admin 🎉 |
Hmm... intersting .. Is there a diffrence between:
The last variant you told me month ago ... Back from vacation I will test it and give feedback BTW: I know this topic is more then entry level. But would this something for https://github.com/Icinga/icingaweb2-module-training, so it's documented for ohter interesting people? |
No. And by looking at your class path,
You already think that this is somewhat quirky to extend |
Thanks for clarification. Both ways works for me.
It was just a copy&paste mistake from your example. My class name in my module is correct - don't worry
I didn't meant to document to extend
My module is also working. That is not the problem. But did you check your |
🤦♂️ Clearly didn't read this. 🙄 Yes I have these messages. And I know why. It's because (in my case) businessprocess initiates authentication on its own during init. I knew, and I think I've told you this as well in 2022, that doing this is discouraged. I just didn't knew why until now. Now we're doing this ourselves 😭
You can always make a suggestion for https://github.com/Icinga/icingaweb2-module-training :D |
Yes I think you told me this 😉
I found this e.g. in
And if I'm correct for every module which is calling
Yes I know, but there is still the unresolved question with your CLA from our bosses 😥 |
I meant a suggestion in form of an issue, suggesting to add this to the training or introduce one. Not actually introducing this by yourself. ;) |
History
In the meantime, some time has passed as @nilmerg explained me how to create a own custom backend. The requirement was to call Icinga from an application portal (beside the possability via DbBackend) and use its authentication information for the login. Because it's a kind of external backend I should use as role model
icingaweb2/library/Icinga/Authentication/User/ExternalBackend.php
Line 13 in c4b6e4b
Now I have finally managed to do this, but I noticed a few things that I would like to describe here
Describe the bug
During the development I recognized that my module with the own backend is loaded too late and/or the authentifcation call was after putting the credentials into the LoginForm.
Depending on the situation icingaweb produces a lot of error messages like:
Can't create authentication backend "portal". An exception was thrown: <- Icinga\Exception\ConfigurationError in /usr/share/php/Icinga/Authentication/User/UserBackend.php with message: Authentication configuration for user backend "xxx" defines an invalid backend type. Backend type "xxx" is not supported
It doesn't matter in which order I configured my backend and the DbBackend at
/etc/icingaweb2/authentication.ini
. Because of that I had to debug the complete login sequence.To Reproduce
The first problem (or actually hurdle) I encourtered is the function
icingaweb2/library/Icinga/Authentication/Auth.php
Line 239 in c4b6e4b
icingaweb2/library/Icinga/Authentication/Auth.php
Line 88 in c4b6e4b
ExternalBackend
. So If I create my own backend with the implemation of the InterfaceUserBackendInterface
. The function returns false everytime and consequently the authentication fails. Here is the workarround for now that the own backend extends the classExternalBackend
although the most things isn't needed from that class. Maybe to create an own interface, which also will be checked inauthExternal
instead of the class name? Just to produce nicer code.The second problem I encourtered is this call
icingaweb2/library/Icinga/Authentication/User/UserBackend.php
Line 91 in c4b6e4b
icingaweb2/library/Icinga/Application/Modules/Module.php
Line 1374 in c4b6e4b
the call will fail, because the own modul isn't loaded and the own backend isn't registred yet. This produces the mentioned error message above and happens as long as, until the own module gets loaded! Depending on the number of modules installed, the log file becomes filled with error messages!
The only workarround for this is to rename the own module to a little senseless name like "aaamybackend" to provoke the fact that the own module with the own backend is loaded first.
Expected behavior
I know this is a still rare case. Maybe not everybody is crazy like my/us 😆 to create a own backend. So get a solution for this will be low prio I think. For loading in a specific order instead of alphabetical could be to set something like a load order. So that, the call
Icinga::app()->getModuleManager()->getLoadedModules()
returns the correct and needed order.And for the "problem" with
authExternal
a solution could be an own interface as I wrote before. But that's only that the code will be nicer, not more.I just wanted to draw attention to it.
Your Environment
Include as many relevant details about the environment you experienced the problem in
icinga2 --version
): 2.14.2-1php --version
): 8.0.30The text was updated successfully, but these errors were encountered: