-
Notifications
You must be signed in to change notification settings - Fork 281
LoginButtonHook: additional buttons below the login form #5442
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
base: main
Are you sure you want to change the base?
Conversation
4036e73 to
6b568c9
Compare
Al2Klimov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lippserd Any feedback on the tech side before anyone applies makeup on the buttons?
library/Icinga/Application/LBH.php
Outdated
| class LBH implements LoginButtonHook | ||
| { | ||
| public function getButtons(): array | ||
| { | ||
| return [ | ||
| new LoginButton( | ||
| function () { | ||
| var_dump(42); | ||
| die; | ||
| }, | ||
| 'LolCat', | ||
| 'https://al2klimov.de/teapot.jpg' | ||
| ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a minimal hook example I use for testing.
| $loginButtons = []; | ||
| $request = ServerRequest::fromGlobals(); | ||
|
|
||
| foreach (Hook::all('LoginButton') as $class => $hook) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know that this is how we do it almost everywhere, but it is not helpful for finding hook usages. I would change the implementation so that we call LoginButtonHook::all().
| * @param string $label Text to show on the button | ||
| * @param ?string $logoUrl URL to an image to show on the button before the text | ||
| */ | ||
| public function __construct(callable $onSuccess, string $label, ?string $logoUrl = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make the class readonly and use constructor property promotion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would also use logoUri instead of Url.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I think about it a little longer, we could make this more flexible by providing ValidHtml $content and ?Attributes $attributes instead of label and logoUri. Then it would be possible to provide either images or icons, as well as other important attributes such as title. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Title can be another property (if you want) and an image is already possible, though unnecessary. IW2 users don't login with Google/ Facebook/ Apple/ ... At best they "Login with id.netways.de". In an actual big company, how many additional login buttons do you expect? Even when 2+, there's text on them saying what they're for.
At most I'd support arbitrary attributes. If we let users add whatever they want, they'll need to style it (CSP friendly) sooner or later, but you said we are responsible for the style of those buttons. Though, users already can style global things using the following hack.
Icinga Web wraps module LESS like this:
/* wrapper */ icinga-module-something {
/* module LESS */ button {
/* module LESS */ color: #234269;
/* module LESS */ }
/* wrapper */ }Knowing this you can jailbreak:
/* wrapper */ icinga-module-something {
/* module LESS */ }
/* module LESS */ button {
/* module LESS */ color: #234269;
/* module LESS */ }
/* module LESS */ html {
/* wrapper */ }There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just think we should design the hook so that it works optimally for us and is flexible enough to do everything we want. Therefore, I suggest to use content and attributes and embed the buttons in a module CSS container so that module CSS can be applied to the buttons.
| /** | ||
| * Form for user authentication via external identity providers | ||
| */ | ||
| class LoginWithForm extends Form |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would name this form ButtonForm since it is not tied to login, and I would also mark it as readonly and use constructor property promotion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In short, Icinga Web 2.13 will require PHP 8.2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, why not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No why not. Just a clarifying question from my side. :-)
e42fff6 to
ce24a63
Compare
ce24a63 to
64d3354
Compare
No description provided.