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

GUACAMOLE-1949 Nextcloud JWT Auth extension #984

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

pp7En
Copy link

@pp7En pp7En commented May 5, 2024

Hi all,

I have built a small extension for myself and would like to share it with you. Maybe this is a function that would go well with Guacamole.

I use a self-hosted Nextcloud and the plugin “External Sites”. This plugin offers the possibility to send a JWT to an embedded website. This JWT is (Nextcloud) user-related and always valid for 1 minute. If the JWT is missing or has expired, an excpetion will be thrown. The extension validates the JWT and if it is valid, the Guacamole login screen is displayed. Everything else then proceeds as usual. Additionally, I have implemented that only certain Nextcloud users are allowed this access, independent of a valid JWT.

I have decided to not make the login screen accessible worldwide, that's why an exception will be thrown if anyone call the guacamole client directly (https://example.com/guacamole) and a login is only possible within the Nextcloud (https://cloud.example.com/).

Another small additional use case in my environment: The login screen should still be displayed for a few clients (via IP addresses), so the IP address will be checked and validated.

Jira Ticket GUACAMOLE-1949


};

private static final StringListProperty NEXTCLOUD_JWT_ALLOWED_USER = new StringListProperty() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing a comment for this property.

return environment.getProperty(NEXTCLOUD_JWT_TRUSTED_NETWORKS, Collections.<String>emptyList());
}

public Collection<String> getAllowedUser() throws GuacamoleException {
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing a comment for this property as well.


}

private boolean isValidJWT(final String token) throws GuacamoleException {
Copy link
Contributor

Choose a reason for hiding this comment

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

These functions all need to be documented.

public UserData fromCredentials(Credentials credentials) {

// String json;
// byte[] correctSignature;
Copy link
Contributor

Choose a reason for hiding this comment

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

No commented out code please - if this function is unused, it should be removed.

* Service for handling cryptography-related operations.
*/
// @Inject
// private CryptoService cryptoService;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this if it's unused.

* via the Guacamole protocol handshake). Only connections with defined IDs
* are tracked here.
*/
private final ConcurrentHashMap<String, String> activeConnections =
Copy link
Contributor

@jmuehlner jmuehlner May 23, 2024

Choose a reason for hiding this comment

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

Why does this extension have its own internal tracking of connections? The ticket and PR description describe this extension to be for allowing an external service to control whether a user can log in or not, which shouldn't require any of this.

Most of the code here looks like it was just copied from the guacamole-auth-json ConnectionService class. If all this functionality is indeed needed here, maybe it could be moved to a shared class in guacamole-ext that both extensions can use, rather than just duplicating it here.

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