Skip to content
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

login: Warn before logging into multiple hosts #20861

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mvollmer
Copy link
Member

@mvollmer mvollmer commented Aug 9, 2024

  • tests
  • design

This is the second half of #20834.

@mvollmer
Copy link
Member Author

@garrett, this is the "Login Page" version of #20826.

@mvollmer
Copy link
Member Author

Old demo: https://youtu.be/lvR2youiY4M

Comment on lines -357 to +365
.login-pf #banner {
.login-pf #banner, .login-pf #multihost-warning {
margin-block: 1rem 0.5rem;
margin-inline: 0;
grid-area: banner;
inline-size: 100%;
}

#banner-message {
#banner-message, #multihost-message {
Copy link
Member

Choose a reason for hiding this comment

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

We really shouldn't target IDs in the CSS. We already do, I know, but we shouldn't add more. (The selectors should be targeting classes.)

We especially should not have IDs nested under other selectors like this.

Ideally, we'd fix the older parts by changing those too.

Anyway, I'm not expecting you to have to fix this, just pointing out that it's bad form. We're already doing bad stuff anyway in the file, so it's not a huge deal. But it's important for new code and we should (at some point) clean up instances where IDs are used in CSS. It's important everyone on the team understands this, as using IDs leads to other bad things, like CSS not working as expected, resulting in !important and other bad things.

https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Selectors/Type_Class_and_ID_Selectors#id_selectors

The ID selector has high specificity. This means styles applied based on matching an ID selector will overrule styles applied based on other selector, including class and type selectors. Because an ID can only occur once on a page and because of the high specificity of ID selectors, it is preferable to add a class to an element instead of an ID. If using the ID is the only way to target the element — perhaps because you do not have access to the markup and cannot edit it — consider using the ID within an attribute selector, such as p[id="header"]. Learn specificity.

(Note: We shouldn't use an attribute selector as it suggests, but actually fix the HTML.)

IDs are great and to be used in JavaScript for quick specific element selecting (as there's only one unique instance of an ID allowed on a document), of course. But it's bad for CSS.

Copy link
Member

Choose a reason for hiding this comment

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

(BTW: I'm not blocking on this in this PR or nitpicking, just pointing out something that would have really bad side effects, especially elsewhere in Cockpit.)

martinpitt added a commit to martinpitt/cockpit-machines that referenced this pull request Nov 21, 2024
martinpitt added a commit to cockpit-project/cockpit-machines that referenced this pull request Nov 22, 2024
@mvollmer mvollmer force-pushed the login-warn-multihost branch from 3462e54 to 7dd084c Compare January 8, 2025 13:27
@mvollmer mvollmer force-pushed the login-warn-multihost branch from 7dd084c to 50b915c Compare January 8, 2025 14:34
redirect_to_current_machine();
else {
id("multihost-message").textContent = format(_("You are already connected to '$0' in this browser session. Connecting to other hosts will allow them to execute arbitrary code on each other. Please be careful."),
cur_machine == "." ? "localhost" : cur_machine);
Copy link
Contributor

Choose a reason for hiding this comment

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

This added line is not executed by any test.

@garrett
Copy link
Member

garrett commented Jan 15, 2025

Is the "old demo" video @ https://youtu.be/lvR2youiY4M still relevant, or have things changed since? Could you state that it's still what it looks and acts like or add a new video otherwise? Thanks!

@mvollmer
Copy link
Member Author

@garrett, the new warning on the login page looks like this:

image

(This is obviously terrible.)

The demo https://youtu.be/lvR2youiY4M is still correct regarding the behavior.

Copy link
Member

@garrett garrett left a comment

Choose a reason for hiding this comment

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

Oof, yeah, I agree that is quite bad visually.

Is this to the point where it's blocking on me? (Apologies; I've been picking off issues one by one from a very long list of things that might possibly need my attention.)

Problems

  1. The look of it (which we all can agree... is not ideal): I'll have to fix this with CSS.
  2. The level of alert. This should be a warning, not an info tip.
  3. "You're already connected to" makes it sound like you're connecting to that specific host again. We'll need to adjust the words.
  4. The placement might not be the best, as it's disconnected to where you're logging in. This is somewhat subjective though, I guess.
  5. Actions about what you can do about it: "Go there" is obviously not correct. But this also doesn't really make it clear what you're doing or why. It's not clear what the problem actually is. You don't know why this is an issue and if you should avoid doing this or not.
  6. The grey button is basically invisible on a similar shade of blue. It does not stand out nor look like a button as a result.

Solutions will be...

  1. Better messaging
  2. Better warning level
  3. Better overall design, possibly?
    • We could make it work with an alert at the top, but I'm concerned that it's too disconnected and someone wouldn't see it.
    • It's also falling into what's sometimes called "banner blindness". Although this isn't an ad, it's in a place and size like one, and people have trained themselves to ignore blocks like this. https://en.wikipedia.org/wiki/Banner_blindness
  4. Improve style, with CSS adjustments

I think with the exception of # 2 (probably), these all require me to step in?

Should we / could we talk about this to agree upon things to make it easier and also try to prioritize this higher, since it's security-related and probably not that much work to get it to the finish line?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants