Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
79a21b2
GUACAMOLE-2258: Add code flow authorisation type, with or without a c…
Apr 7, 2026
31644eb
GUACAMOLE-2258: Use SessionManager directly from getLoginURI to store…
Apr 8, 2026
3157cba
GUACAMOLE-2258: Reinclude accidentally removed check if implicit toke…
Apr 8, 2026
4724bde
GUACAMOLE-2258: Minor white-spqce, import changes to minimize impact …
Apr 8, 2026
b3207b1
GUACAMOLE-2258: Remove accidentally committed files
Apr 8, 2026
4a19662
GUACAMOLE-2258: Add treatment of well-known endpoints
Apr 9, 2026
e477559
GUACAMOLE-2258: Treat review comments
Apr 10, 2026
546abda
GUACAMOLE-2258: Remove some no longer used imports for TokenValidatio…
Apr 10, 2026
33a6ea1
GUACAMOLE-2258: Print detected OIDC well-known information at debug-l…
Apr 10, 2026
d12f720
GUACAMOLE-2258: Replace use of java.net.HttpURLConnection with java.n…
Apr 10, 2026
03c7a73
GUACAMOLE-2258: No body in JsonUrlReader for GET method
Apr 13, 2026
adc051a
GUACAMOLE-2258: Replace openid-auth-timeout with openid-max-pkce-veri…
Apr 13, 2026
80faa8c
GUACAMOLE-2258: Copy/Paste editing error in comment block
Apr 13, 2026
048e2eb
GUACAMOLE-2258: Cut/paste/edit mistake in function JsDoc block
Apr 13, 2026
31f8675
GUACAMOLE-2258: Correct typos and error in all comments of the PR
Apr 13, 2026
3786b44
GUACAMOLE-2258: Address most of the review comments
May 3, 2026
f8f7902
GUACAMOLE-2258: Don't catch all exceptions in exchangeCode function
May 3, 2026
0bc986b
GUACAMOLE-2258: Forgot the import needed for the previous change
May 3, 2026
7f3ba49
GUACAMOLE-2258: Also use nonce with code flow
Jun 24, 2026
ba50fd1
GUACAMOLE-2258: Allow redirection to original page after login
Jun 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ public AuthenticatedUser authenticateUser(AuthenticationProvider authenticationP

// Authenticate user
AuthenticatedUser user = userService.retrieveAuthenticatedUser(authenticationProvider, credentials);
if (user != null)
if (user != null) {
user.setOriginalUri(credentials.getRequestDetails().getRequestURI());
return user;
}

// Otherwise, unauthorized
throw new GuacamoleInvalidCredentialsException("Invalid login", CredentialsInfo.USERNAME_PASSWORD);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ public abstract class RemoteAuthenticatedUser implements AuthenticatedUser {
*/
private final Set<String> effectiveGroups;

/**
* The URI that was originally used to the first call to the authentication
* providers authenticateUser method.
*/
private String originalUri;

/**
* Creates a new RemoteAuthenticatedUser, deriving the associated remote
* host from the given credentials.
Expand Down Expand Up @@ -103,4 +109,14 @@ public void invalidate() {
// Nothing to invalidate
}

@Override
public void setOriginalUri(String originalUri) {
this.originalUri = originalUri;
}

@Override
public String getOriginalUri() {
return this.originalUri;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.guacamole.auth.sso.session;

import java.util.concurrent.ConcurrentHashMap;
import java.util.Map;
import org.apache.guacamole.net.auth.AuthenticationSession;
import org.apache.guacamole.net.auth.Credentials;

/**
* Representation of an in-progress OpenID authentication attempt.
*/
public class SSOAuthenticationSession extends AuthenticationSession {
/**
* The key value used to store the redirection URI
*/
private static String REDIRECTION = "redirection";

/**
* THe key value of the redirection URI in the credential parameers
*/
private static String REQUEST_HREF = "href";

/**
* A Map of Arbitrary session data
*/
private final Map<String, Object> session;

/**
* Creates a new AuthenticationSession representing an in-progress
* authentication attempt.
*
* @param session
* A Map of the session data to be stored
*
* @param expires
* The number of milliseconds that may elapse before this session must
* be considered invalid.
*/
public SSOAuthenticationSession(Map<String,Object> session, long expires) {
super(expires);
this.session = session;
}

/**
* Creates a new AuthenticationSession representing an in-progress
* authentication attempt.
*
* @param expires
* The number of milliseconds that may elapse before this session must
* be considered invalid.
*/
public SSOAuthenticationSession(long expires) {
this(new ConcurrentHashMap<>(), expires);
}

/**
* Returns the stored session data
*
* @return
* The session data, can be null
*/
public Map<String, Object> getSession() {
return session;
}

/**
* Returns an Object stored in the session data
*
* @return
* The object in the session, can be null
*/
public Object get(String key) {
return session.get(key);
}

/**
* Returns an Object stored in the session data
*
* @return
* The object in the session, can be null
*/
public void put(String key, Object value) {
session.put(key, value);
}

/**
* Special case for redirection from credentials to
* simplify he authentication providers
*
* @return
* The redirection stored in teh session
*/
public String getRedirection() {
Object obj = session.get(REDIRECTION);
return obj == null ? null : obj.toString();
}

/**
* Special case for redirection from credentials to
* simplify he authentication providers
*
* @param credentials
* The credentials from which to extract the redirection.
*/
public void setRedirection(Credentials credentials) {
String redirection = credentials.getParameter(REQUEST_HREF);
put(REDIRECTION, redirection);
}
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.guacamole.auth.sso.session;

import java.util.Map;
import com.google.inject.Singleton;
import org.apache.guacamole.net.auth.AuthenticationSessionManager;

/**
* Manager service that temporarily stores authentication attempts while
* the authentication flow is underway.
*/
@Singleton
public class SSOAuthenticationSessionManager
extends AuthenticationSessionManager<SSOAuthenticationSession> {

/**
* Returns the stored session data used with the identity provider
*
* @param identifier
* The unique string returned by the call to defer(). For convenience,
* this value may safely be null.
*
* @return
* The session data
*/
public SSOAuthenticationSession resume(String identifier) {
return super.resume(identifier);
}
}

Loading