-
Notifications
You must be signed in to change notification settings - Fork 711
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
GUACAMOLE-1239: Correct logic for, and fix missing, case sensitivity settings. #1028
GUACAMOLE-1239: Correct logic for, and fix missing, case sensitivity settings. #1028
Conversation
@necouchman I found another issue related to the case sensitive with the quick connect extension.
HistoryTrackingConnection.java:109 connectionRecordMapper.insert(connectionRecordModel,
environment.getCaseSensitiveUsernames()); The extension works on an instance without auth-jdbc. |
@corentin-soriano It looks like maybe you're not using the latest git staging/1.6.0 version after the merge of the latest round of changes? Specifically, the warning about having enabled case-sensitive usernames was moved so that it only occurs during module loading, and not at each call, so you shouldn't have that warning right below the connection attempt, which indicates you may have an older version. I'll still test it out and see what happens with that extension in my environment. Thank you for the continued testing and reporting these issues!! ***UPDATE: I'm able to reproduce the issues noted above, so I'll try to track down why this is happening... |
@corentin-soriano Okay, I've corrected the latest issue you identified with non-JDBC connections inserting history records into the database in this pull request. @mike-jumper You might take a look and make sure that what I did is sane - I couldn't pull the I've also tested out things like creating users, creating connections, assigning permissions, etc., and I'm not seeing any issues, so I'm going to mark this as ready to review. I'll continue testing a few other scenarios - enabling/disabling case sensitivity, add some usernames with mixed case, etc., and see if I can break anything else. |
ba649d7
to
7b4af2a
Compare
@necouchman I no longer encounter the issue, thank you! |
It looks like this should work, but it's a little goofy to be reaching through the user to get access to the environment. Consider injecting the environment into the |
I think it could potentially be problematic to leverage |
Thanks @jmuehlner and @mike-jumper - a question comes to mind before I pursue a particular solution: In these situations, which environment should the case-(in)sensitivity be pulled from? Since the |
The current approach with the various I also think it would make sense to allow the authenticating extension to dictate how the identifiers it presents should be compared ( To switch over to that approach, the other cases where case sensitivity is handled would need to be updated to honor The current approach is less automatic, but I think that's a Good Thing, since any change from the default, strict behavior must be explicitly requested by the admin. |
So, if I'm understanding what you're saying correctly, given the current way these properties are interpreted,
Yeah, seems like this might be a future enhancement with a lot more thought and effort putting into doing it safely and with as little surprise as possible. |
Actually, maybe I'm just confused, here. Given Corentin's example:
So, you're saying that the extension that defines the |
Hm ... maybe what I was thinking is actually backwards, and we should instead:
Otherwise things stop making sense. The JSON auth has a I'm starting to thing these changes have part of the right idea, and we need to change the rest to match. |
7b4af2a
to
2c5414a
Compare
I'll go back through the previous changes and see what needs to be done to rework things using this logic.
I've pushed a commit that I think tackles this particular issue without too much hassle - let me know if that looks okay to you.
Yeah, this makes sense to me. I'll review and see what changes need to be made to implement this logic. |
So, if I'm thinking about this correctly, what this looks like a little more concretely is:
Does that sound right? |
Yes and no. That would be an alternative and consistent approach. Taking a mammoth step back to the beginning, I think we have two mutually-exclusive possible approaches:
Migrating to the former would mean getting rid of Migrating to the latter would mean keeping I find myself flipping back and forth between these without a clear answer as to which is truly best. I suspect that's probably also why the current approach is a sort of mix of these - they're both reasonable approaches. |
Then again ... it's hard to argue against the sheer simplicity and safety of losing |
@mike-jumper @jmuehlner : I've taken a stab at an approach that should make the source for case-sensitivity more consistent across different login modules - essentially, what I've tried to do, is make sure that, whenever and wherever possible, particularly within the JDBC module, the source for the case sensitivity setting comes from the logged in user. The logged in user, in turn will pull from the environment for the current authentication module, which will either be that particular extension's configuration property or the global configuration property. I just finished this up and have verified that it compiles - tomorrow I'll run it through some testing to make sure that the various use-cases that others identified that were broken are still functional. If you spot any flaws in my logic, please give a shout. And, if we need to close it out and just go to a monolithic enable/disable option and scrap the whole per-extension setting, I can give that a run, too. 😩 |
I think we do need to switch over to the monolithic enable/disable option (and +1 on the 😩). As I review, I'm running into things like handling of usernames within history records, and there doesn't seem to be any way we can handle differences in case sensitivity sanely unless there is only the platform-wide option that states how all usernames are to be interpreted. For example, let's say there are two authentication systems installed:
If a user With a platform-wide option, things are completely unambiguous and everything is in agreement. With extension-specific options, things make sense as long as everything is manually configured to be in agreement, but stop making sense once there is any disagreement between extensions. |
Okay, I'll switch it up and go that route. It pains me a little bit to take away the flexibility of being able to choose on a per-extension basis, but the example you give above highlights the challenges with even making that available and the confusion that might arise were someone to try to debug that sort of situation. The other thing that has continued to nag at the back of my mind is that I think we (ultimately) need to make the same option available for group names. This effort has focused almost exclusively on usernames, but I cannot help but think that the expectation of making usernames case-insensitive is going to easily make someone think that group names also ought to be case-insensitive. Thoughts on expanding the scope from just |
I agree. I'm sure this will be necessary and it makes sense to include this as part of the general configurable case sensitivity effort. |
…ty, retaining only global configuration.
Okay - I think I've completed the re-work of the user code to only pull from the global configuration value, and removed all of the extension-based options. I have left the bits in place, mainly in the JDBC module, that pull from the I'll see if I can knock the And then...testing... |
Working through the |
Almost there. Wrapping things up today. 🤞 |
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 think we should probably remove the isCaseSensitive()
function, at least from guacamole-ext, so that it does not potentially result in conflicting information between an implementation's isCaseSensitive()
vs. the global configuration option.
If it makes things easier to plumb within the JDBC auth, I don't see any issue with having a isCaseSensitive()
function that's strictly internal to JDBC.
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.
Okay - I'm almost done with the changes - hoping to at least get the draft out tonight ahead of doing some testing, and you can see what I've done, there. I left isCaseSensitive()
in, for now, because it helps with the comparisons between identifiers. But you can see what you think after I've pushed the remaining changes...
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.
Awesome - sounds reasonable to me.
Okay...here are the changes. I am 💯 certain that I have made multiple mistakes. I have done 0️⃣ testing after finishing these changes - my eyes are crossing from SO. MUCH. XML - while it compiles right now, I very much doubt that it will actually work out of the gate. There are also several style issues that need fixing. But, any overall concerns or comments about the approach, let me know. |
Oof, I don't blame them, but thanks for doing this. I think we're on the right path. |
Sounds good. I'm working through testing, now, and have already corrected a couple of issues, which I'll push, here, shortly. |
b9e673b
to
48b1d5b
Compare
I've removed this from draft state, as I've done several rounds of testing, fixed several items, and am cautiously optimistic that it is working as intended and that I've corrected the typos. If others are inclined to test, that would be welcome - so far I've only tested with PostgreSQL, as that is my DB of choice. I'll try to spin up MySQL and SQL Server at some point, here, soon, and test with those. |
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 rather like these changes, particularly the clean approach of using CaseSensitivity
to represent both usernames and group names.
I've found only a few minor issues, with a couple probably worth a quick grep to look for other occurrences:
- In several locations, "case sensitivity" is written as "case-sensitivity". I believe "case sensitivity" is the correct way, with the hyphen used only for things like "case-sensitive" and "case-insensitive".
- The exception caught when attempting to read the case sensitivity value from
guacamole.properties
is variously logged without the{}
placeholder fore.getMessage()
or with juste
(full stack trace) instead ofe.getMessage()
.
Everything else looks great.
guacamole-ext/src/main/java/org/apache/guacamole/environment/Environment.java
Show resolved
Hide resolved
...uacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/base/EntityService.java
Outdated
Show resolved
Hide resolved
...uth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/permission/PermissionService.java
Outdated
Show resolved
Hide resolved
...base/src/main/java/org/apache/guacamole/auth/jdbc/tunnel/AbstractGuacamoleTunnelService.java
Outdated
Show resolved
Hide resolved
.../guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/user/ModeledUser.java
Outdated
Show resolved
Hide resolved
...-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/usergroup/ModeledUserGroup.java
Outdated
Show resolved
Hide resolved
guacamole-ext/src/main/java/org/apache/guacamole/properties/CaseSensitivity.java
Outdated
Show resolved
Hide resolved
guacamole-ext/src/main/java/org/apache/guacamole/net/auth/AbstractAuthenticatedUser.java
Outdated
Show resolved
Hide resolved
…cts and remove per-extension configuration.
48b1d5b
to
f314e78
Compare
Next round of fixes for case-sensitivity stuff in the JDBC module.
Opening as a draft for the moment while I verify that the changes I've made will actually work consistently for username case-sensitivity.