Skip to content

Conversation

@Al2Klimov
Copy link
Member

No description provided.

@Al2Klimov Al2Klimov self-assigned this Nov 5, 2025
@cla-bot cla-bot bot added the cla/signed label Nov 5, 2025
@Al2Klimov Al2Klimov changed the title LoginButtonHook: additional buttons to be displayed below the login form LoginButtonHook: additional buttons below the login form Nov 5, 2025
@Al2Klimov Al2Klimov force-pushed the LoginButtonHook branch 2 times, most recently from 4036e73 to 6b568c9 Compare November 5, 2025 16:43
Copy link
Member Author

@Al2Klimov Al2Klimov left a 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?

Comment on lines 8 to 20
class LBH implements LoginButtonHook
{
public function getButtons(): array
{
return [
new LoginButton(
function () {
var_dump(42);
die;
},
'LolCat',
'https://al2klimov.de/teapot.jpg'
),
Copy link
Member Author

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) {
Copy link
Member

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)
Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

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?

Copy link
Member Author

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 */ }

Copy link
Member

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
Copy link
Member

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.

Copy link
Member Author

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, why not?

Copy link
Member Author

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. :-)

@Al2Klimov Al2Klimov force-pushed the LoginButtonHook branch 2 times, most recently from e42fff6 to ce24a63 Compare November 7, 2025 15:40
@Al2Klimov Al2Klimov requested a review from lippserd November 17, 2025 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants