mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 05:07:41 +00:00
GUACAMOLE-210: Refactor source referencing OAuth to OpenID. This extension uses OpenID, not OAuth.
This commit is contained in:
@@ -17,16 +17,16 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.apache.guacamole.auth.oauth;
|
package org.apache.guacamole.auth.openid;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Provider;
|
import com.google.inject.Provider;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import org.apache.guacamole.auth.oauth.conf.ConfigurationService;
|
import org.apache.guacamole.auth.openid.conf.ConfigurationService;
|
||||||
import org.apache.guacamole.auth.oauth.form.OAuthTokenField;
|
import org.apache.guacamole.auth.openid.form.TokenField;
|
||||||
import org.apache.guacamole.auth.oauth.token.TokenValidationService;
|
import org.apache.guacamole.auth.openid.token.TokenValidationService;
|
||||||
import org.apache.guacamole.auth.oauth.user.AuthenticatedUser;
|
import org.apache.guacamole.auth.openid.user.AuthenticatedUser;
|
||||||
import org.apache.guacamole.GuacamoleException;
|
import org.apache.guacamole.GuacamoleException;
|
||||||
import org.apache.guacamole.form.Field;
|
import org.apache.guacamole.form.Field;
|
||||||
import org.apache.guacamole.net.auth.Credentials;
|
import org.apache.guacamole.net.auth.Credentials;
|
||||||
@@ -36,7 +36,7 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service providing convenience functions for the OAuth AuthenticationProvider
|
* Service providing convenience functions for the OpenID AuthenticationProvider
|
||||||
* implementation.
|
* implementation.
|
||||||
*/
|
*/
|
||||||
public class AuthenticationProviderService {
|
public class AuthenticationProviderService {
|
||||||
@@ -47,7 +47,7 @@ public class AuthenticationProviderService {
|
|||||||
private final Logger logger = LoggerFactory.getLogger(AuthenticationProviderService.class);
|
private final Logger logger = LoggerFactory.getLogger(AuthenticationProviderService.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service for retrieving OAuth configuration information.
|
* Service for retrieving OpenID configuration information.
|
||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
private ConfigurationService confService;
|
private ConfigurationService confService;
|
||||||
@@ -84,10 +84,10 @@ public class AuthenticationProviderService {
|
|||||||
|
|
||||||
String token = null;
|
String token = null;
|
||||||
|
|
||||||
// Pull OAuth token from request if present
|
// Pull OpenID token from request if present
|
||||||
HttpServletRequest request = credentials.getRequest();
|
HttpServletRequest request = credentials.getRequest();
|
||||||
if (request != null)
|
if (request != null)
|
||||||
token = request.getParameter(OAuthTokenField.PARAMETER_NAME);
|
token = request.getParameter(TokenField.PARAMETER_NAME);
|
||||||
|
|
||||||
// If token provided, validate and produce authenticated user
|
// If token provided, validate and produce authenticated user
|
||||||
if (token != null) {
|
if (token != null) {
|
||||||
@@ -99,13 +99,13 @@ public class AuthenticationProviderService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Request OAuth token
|
// Request OpenID token
|
||||||
throw new GuacamoleInvalidCredentialsException("Invalid login.",
|
throw new GuacamoleInvalidCredentialsException("Invalid login.",
|
||||||
new CredentialsInfo(Arrays.asList(new Field[] {
|
new CredentialsInfo(Arrays.asList(new Field[] {
|
||||||
|
|
||||||
// OAuth-specific token (will automatically redirect the user
|
// OpenID-specific token (will automatically redirect the user
|
||||||
// to the authorization page via JavaScript)
|
// to the authorization page via JavaScript)
|
||||||
new OAuthTokenField(
|
new TokenField(
|
||||||
confService.getAuthorizationEndpoint(),
|
confService.getAuthorizationEndpoint(),
|
||||||
confService.getClientID(),
|
confService.getClientID(),
|
||||||
confService.getRedirectURI()
|
confService.getRedirectURI()
|
@@ -17,7 +17,7 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.apache.guacamole.auth.oauth;
|
package org.apache.guacamole.auth.openid;
|
||||||
|
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
@@ -29,11 +29,11 @@ import org.apache.guacamole.net.auth.UserContext;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Guacamole authentication backend which authenticates users using an
|
* Guacamole authentication backend which authenticates users using an
|
||||||
* arbitrary external system implementing OAuth. No storage for connections is
|
* arbitrary external system implementing OpenID. No storage for connections is
|
||||||
* provided - only authentication. Storage must be provided by some other
|
* provided - only authentication. Storage must be provided by some other
|
||||||
* extension.
|
* extension.
|
||||||
*/
|
*/
|
||||||
public class OAuthAuthenticationProvider implements AuthenticationProvider {
|
public class OpenIDAuthenticationProvider implements AuthenticationProvider {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Injector which will manage the object graph of this authentication
|
* Injector which will manage the object graph of this authentication
|
||||||
@@ -42,25 +42,25 @@ public class OAuthAuthenticationProvider implements AuthenticationProvider {
|
|||||||
private final Injector injector;
|
private final Injector injector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new OAuthAuthenticationProvider that authenticates users
|
* Creates a new OpenIDAuthenticationProvider that authenticates users
|
||||||
* against an OAuth service
|
* against an OpenID service.
|
||||||
*
|
*
|
||||||
* @throws GuacamoleException
|
* @throws GuacamoleException
|
||||||
* If a required property is missing, or an error occurs while parsing
|
* If a required property is missing, or an error occurs while parsing
|
||||||
* a property.
|
* a property.
|
||||||
*/
|
*/
|
||||||
public OAuthAuthenticationProvider() throws GuacamoleException {
|
public OpenIDAuthenticationProvider() throws GuacamoleException {
|
||||||
|
|
||||||
// Set up Guice injector.
|
// Set up Guice injector.
|
||||||
injector = Guice.createInjector(
|
injector = Guice.createInjector(
|
||||||
new OAuthAuthenticationProviderModule(this)
|
new OpenIDAuthenticationProviderModule(this)
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getIdentifier() {
|
public String getIdentifier() {
|
||||||
return "oauth";
|
return "openid";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
@@ -17,20 +17,20 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.apache.guacamole.auth.oauth;
|
package org.apache.guacamole.auth.openid;
|
||||||
|
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
import org.apache.guacamole.auth.oauth.conf.ConfigurationService;
|
import org.apache.guacamole.auth.openid.conf.ConfigurationService;
|
||||||
import org.apache.guacamole.auth.oauth.token.TokenValidationService;
|
import org.apache.guacamole.auth.openid.token.TokenValidationService;
|
||||||
import org.apache.guacamole.GuacamoleException;
|
import org.apache.guacamole.GuacamoleException;
|
||||||
import org.apache.guacamole.environment.Environment;
|
import org.apache.guacamole.environment.Environment;
|
||||||
import org.apache.guacamole.environment.LocalEnvironment;
|
import org.apache.guacamole.environment.LocalEnvironment;
|
||||||
import org.apache.guacamole.net.auth.AuthenticationProvider;
|
import org.apache.guacamole.net.auth.AuthenticationProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Guice module which configures OAuth-specific injections.
|
* Guice module which configures openid-specific injections.
|
||||||
*/
|
*/
|
||||||
public class OAuthAuthenticationProviderModule extends AbstractModule {
|
public class OpenIDAuthenticationProviderModule extends AbstractModule {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Guacamole server environment.
|
* Guacamole server environment.
|
||||||
@@ -38,14 +38,14 @@ public class OAuthAuthenticationProviderModule extends AbstractModule {
|
|||||||
private final Environment environment;
|
private final Environment environment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A reference to the OAuthAuthenticationProvider on behalf of which this
|
* A reference to the OpenIDAuthenticationProvider on behalf of which this
|
||||||
* module has configured injection.
|
* module has configured injection.
|
||||||
*/
|
*/
|
||||||
private final AuthenticationProvider authProvider;
|
private final AuthenticationProvider authProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new OAuth authentication provider module which configures
|
* Creates a new OpenID authentication provider module which configures
|
||||||
* injection for the OAuthAuthenticationProvider.
|
* injection for the OpenIDAuthenticationProvider.
|
||||||
*
|
*
|
||||||
* @param authProvider
|
* @param authProvider
|
||||||
* The AuthenticationProvider for which injection is being configured.
|
* The AuthenticationProvider for which injection is being configured.
|
||||||
@@ -54,7 +54,7 @@ public class OAuthAuthenticationProviderModule extends AbstractModule {
|
|||||||
* If an error occurs while retrieving the Guacamole server
|
* If an error occurs while retrieving the Guacamole server
|
||||||
* environment.
|
* environment.
|
||||||
*/
|
*/
|
||||||
public OAuthAuthenticationProviderModule(AuthenticationProvider authProvider)
|
public OpenIDAuthenticationProviderModule(AuthenticationProvider authProvider)
|
||||||
throws GuacamoleException {
|
throws GuacamoleException {
|
||||||
|
|
||||||
// Get local environment
|
// Get local environment
|
||||||
@@ -72,7 +72,7 @@ public class OAuthAuthenticationProviderModule extends AbstractModule {
|
|||||||
bind(AuthenticationProvider.class).toInstance(authProvider);
|
bind(AuthenticationProvider.class).toInstance(authProvider);
|
||||||
bind(Environment.class).toInstance(environment);
|
bind(Environment.class).toInstance(environment);
|
||||||
|
|
||||||
// Bind OAuth-specific services
|
// Bind openid-specific services
|
||||||
bind(ConfigurationService.class);
|
bind(ConfigurationService.class);
|
||||||
bind(TokenValidationService.class);
|
bind(TokenValidationService.class);
|
||||||
|
|
@@ -17,14 +17,15 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.apache.guacamole.auth.oauth.conf;
|
package org.apache.guacamole.auth.openid.conf;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import org.apache.guacamole.GuacamoleException;
|
import org.apache.guacamole.GuacamoleException;
|
||||||
import org.apache.guacamole.environment.Environment;
|
import org.apache.guacamole.environment.Environment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service for retrieving configuration information regarding the OAuth service.
|
* Service for retrieving configuration information regarding the OpenID
|
||||||
|
* service.
|
||||||
*/
|
*/
|
||||||
public class ConfigurationService {
|
public class ConfigurationService {
|
||||||
|
|
||||||
@@ -35,11 +36,11 @@ public class ConfigurationService {
|
|||||||
private Environment environment;
|
private Environment environment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the authorization endpoint (URI) of the OAuth service as
|
* Returns the authorization endpoint (URI) of the OpenID service as
|
||||||
* configured with guacamole.properties.
|
* configured with guacamole.properties.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
* The authorization endpoint of the OAuth service, as configured with
|
* The authorization endpoint of the OpenID service, as configured with
|
||||||
* guacamole.properties.
|
* guacamole.properties.
|
||||||
*
|
*
|
||||||
* @throws GuacamoleException
|
* @throws GuacamoleException
|
||||||
@@ -47,17 +48,17 @@ public class ConfigurationService {
|
|||||||
* endpoint property is missing.
|
* endpoint property is missing.
|
||||||
*/
|
*/
|
||||||
public String getAuthorizationEndpoint() throws GuacamoleException {
|
public String getAuthorizationEndpoint() throws GuacamoleException {
|
||||||
return environment.getRequiredProperty(OAuthGuacamoleProperties.OAUTH_AUTHORIZATION_ENDPOINT);
|
return environment.getRequiredProperty(OpenIDGuacamoleProperties.OPENID_AUTHORIZATION_ENDPOINT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the OAuth client ID which should be submitted to the OAuth
|
* Returns the OpenID client ID which should be submitted to the OpenID
|
||||||
* service when necessary, as configured with guacamole.properties. This
|
* service when necessary, as configured with guacamole.properties. This
|
||||||
* value is typically provided by the OAuth service when OAuth credentials
|
* value is typically provided by the OpenID service when OpenID credentials
|
||||||
* are generated for your application.
|
* are generated for your application.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
* The client ID to use when communicating with the OAuth service,
|
* The client ID to use when communicating with the OpenID service,
|
||||||
* as configured with guacamole.properties.
|
* as configured with guacamole.properties.
|
||||||
*
|
*
|
||||||
* @throws GuacamoleException
|
* @throws GuacamoleException
|
||||||
@@ -65,17 +66,17 @@ public class ConfigurationService {
|
|||||||
* property is missing.
|
* property is missing.
|
||||||
*/
|
*/
|
||||||
public String getClientID() throws GuacamoleException {
|
public String getClientID() throws GuacamoleException {
|
||||||
return environment.getRequiredProperty(OAuthGuacamoleProperties.OAUTH_CLIENT_ID);
|
return environment.getRequiredProperty(OpenIDGuacamoleProperties.OPENID_CLIENT_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the URI that the OAuth service should redirect to after
|
* Returns the URI that the OpenID service should redirect to after
|
||||||
* the authentication process is complete, as configured with
|
* the authentication process is complete, as configured with
|
||||||
* guacamole.properties. This must be the full URL that a user would enter
|
* guacamole.properties. This must be the full URL that a user would enter
|
||||||
* into their browser to access Guacamole.
|
* into their browser to access Guacamole.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
* The client secret to use when communicating with the OAuth service,
|
* The client secret to use when communicating with the OpenID service,
|
||||||
* as configured with guacamole.properties.
|
* as configured with guacamole.properties.
|
||||||
*
|
*
|
||||||
* @throws GuacamoleException
|
* @throws GuacamoleException
|
||||||
@@ -83,7 +84,7 @@ public class ConfigurationService {
|
|||||||
* property is missing.
|
* property is missing.
|
||||||
*/
|
*/
|
||||||
public String getRedirectURI() throws GuacamoleException {
|
public String getRedirectURI() throws GuacamoleException {
|
||||||
return environment.getRequiredProperty(OAuthGuacamoleProperties.OAUTH_REDIRECT_URI);
|
return environment.getRequiredProperty(OpenIDGuacamoleProperties.OPENID_REDIRECT_URI);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -99,7 +100,7 @@ public class ConfigurationService {
|
|||||||
* is missing.
|
* is missing.
|
||||||
*/
|
*/
|
||||||
public String getIssuer() throws GuacamoleException {
|
public String getIssuer() throws GuacamoleException {
|
||||||
return environment.getRequiredProperty(OAuthGuacamoleProperties.OAUTH_ISSUER);
|
return environment.getRequiredProperty(OpenIDGuacamoleProperties.OPENID_ISSUER);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -117,7 +118,7 @@ public class ConfigurationService {
|
|||||||
* property is missing.
|
* property is missing.
|
||||||
*/
|
*/
|
||||||
public String getJWKSEndpoint() throws GuacamoleException {
|
public String getJWKSEndpoint() throws GuacamoleException {
|
||||||
return environment.getRequiredProperty(OAuthGuacamoleProperties.OAUTH_JWKS_ENDPOINT);
|
return environment.getRequiredProperty(OpenIDGuacamoleProperties.OPENID_JWKS_ENDPOINT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -133,7 +134,7 @@ public class ConfigurationService {
|
|||||||
* type property is missing.
|
* type property is missing.
|
||||||
*/
|
*/
|
||||||
public String getUsernameClaimType() throws GuacamoleException {
|
public String getUsernameClaimType() throws GuacamoleException {
|
||||||
return environment.getRequiredProperty(OAuthGuacamoleProperties.OAUTH_USERNAME_CLAIM_TYPE);
|
return environment.getRequiredProperty(OpenIDGuacamoleProperties.OPENID_USERNAME_CLAIM_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@@ -17,30 +17,30 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.apache.guacamole.auth.oauth.conf;
|
package org.apache.guacamole.auth.openid.conf;
|
||||||
|
|
||||||
import org.apache.guacamole.properties.StringGuacamoleProperty;
|
import org.apache.guacamole.properties.StringGuacamoleProperty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides properties required for use of the OAuth authentication provider.
|
* Provides properties required for use of the OpenID authentication provider.
|
||||||
* These properties will be read from guacamole.properties when the OAuth
|
* These properties will be read from guacamole.properties when the OpenID
|
||||||
* authentication provider is used.
|
* authentication provider is used.
|
||||||
*/
|
*/
|
||||||
public class OAuthGuacamoleProperties {
|
public class OpenIDGuacamoleProperties {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class should not be instantiated.
|
* This class should not be instantiated.
|
||||||
*/
|
*/
|
||||||
private OAuthGuacamoleProperties() {}
|
private OpenIDGuacamoleProperties() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The authorization endpoint (URI) of the OAuth service.
|
* The authorization endpoint (URI) of the OpenID service.
|
||||||
*/
|
*/
|
||||||
public static final StringGuacamoleProperty OAUTH_AUTHORIZATION_ENDPOINT =
|
public static final StringGuacamoleProperty OPENID_AUTHORIZATION_ENDPOINT =
|
||||||
new StringGuacamoleProperty() {
|
new StringGuacamoleProperty() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() { return "oauth-authorization-endpoint"; }
|
public String getName() { return "openid-authorization-endpoint"; }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -48,22 +48,22 @@ public class OAuthGuacamoleProperties {
|
|||||||
* The endpoint (URI) of the JWKS service which defines how received ID
|
* The endpoint (URI) of the JWKS service which defines how received ID
|
||||||
* tokens (JWTs) shall be validated.
|
* tokens (JWTs) shall be validated.
|
||||||
*/
|
*/
|
||||||
public static final StringGuacamoleProperty OAUTH_JWKS_ENDPOINT =
|
public static final StringGuacamoleProperty OPENID_JWKS_ENDPOINT =
|
||||||
new StringGuacamoleProperty() {
|
new StringGuacamoleProperty() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() { return "oauth-jwks-endpoint"; }
|
public String getName() { return "openid-jwks-endpoint"; }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The issuer to expect for all received ID tokens.
|
* The issuer to expect for all received ID tokens.
|
||||||
*/
|
*/
|
||||||
public static final StringGuacamoleProperty OAUTH_ISSUER =
|
public static final StringGuacamoleProperty OPENID_ISSUER =
|
||||||
new StringGuacamoleProperty() {
|
new StringGuacamoleProperty() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() { return "oauth-issuer"; }
|
public String getName() { return "openid-issuer"; }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -71,37 +71,37 @@ public class OAuthGuacamoleProperties {
|
|||||||
* The claim type which contains the authenticated user's username within
|
* The claim type which contains the authenticated user's username within
|
||||||
* any valid JWT.
|
* any valid JWT.
|
||||||
*/
|
*/
|
||||||
public static final StringGuacamoleProperty OAUTH_USERNAME_CLAIM_TYPE =
|
public static final StringGuacamoleProperty OPENID_USERNAME_CLAIM_TYPE =
|
||||||
new StringGuacamoleProperty() {
|
new StringGuacamoleProperty() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() { return "oauth-username-claim-type"; }
|
public String getName() { return "openid-username-claim-type"; }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OAuth client ID which should be submitted to the OAuth service when
|
* OpenID client ID which should be submitted to the OpenID service when
|
||||||
* necessary. This value is typically provided by the OAuth service when
|
* necessary. This value is typically provided by the OpenID service when
|
||||||
* OAuth credentials are generated for your application.
|
* OpenID credentials are generated for your application.
|
||||||
*/
|
*/
|
||||||
public static final StringGuacamoleProperty OAUTH_CLIENT_ID =
|
public static final StringGuacamoleProperty OPENID_CLIENT_ID =
|
||||||
new StringGuacamoleProperty() {
|
new StringGuacamoleProperty() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() { return "oauth-client-id"; }
|
public String getName() { return "openid-client-id"; }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The URI that the OAuth service should redirect to after the
|
* The URI that the OpenID service should redirect to after the
|
||||||
* authentication process is complete. This must be the full URL that a
|
* authentication process is complete. This must be the full URL that a
|
||||||
* user would enter into their browser to access Guacamole.
|
* user would enter into their browser to access Guacamole.
|
||||||
*/
|
*/
|
||||||
public static final StringGuacamoleProperty OAUTH_REDIRECT_URI =
|
public static final StringGuacamoleProperty OPENID_REDIRECT_URI =
|
||||||
new StringGuacamoleProperty() {
|
new StringGuacamoleProperty() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() { return "oauth-redirect-uri"; }
|
public String getName() { return "openid-redirect-uri"; }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
@@ -17,7 +17,7 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.apache.guacamole.auth.oauth.form;
|
package org.apache.guacamole.auth.openid.form;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
@@ -26,15 +26,15 @@ import java.security.SecureRandom;
|
|||||||
import org.apache.guacamole.form.Field;
|
import org.apache.guacamole.form.Field;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Field definition which represents the token returned by an OAuth service.
|
* Field definition which represents the token returned by an OpenID service.
|
||||||
* Within the user interface, this will be rendered as an appropriate "Log in
|
* Within the user interface, this will be rendered as an appropriate "Log in
|
||||||
* with ..." button which links to the OAuth service.
|
* with ..." button which links to the OpenID service.
|
||||||
*/
|
*/
|
||||||
public class OAuthTokenField extends Field {
|
public class TokenField extends Field {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The standard HTTP parameter which will be included within the URL by all
|
* The standard HTTP parameter which will be included within the URL by all
|
||||||
* OAuth services upon successful authentication and redirect.
|
* OpenID services upon successful authentication and redirect.
|
||||||
*/
|
*/
|
||||||
public static final String PARAMETER_NAME = "id_token";
|
public static final String PARAMETER_NAME = "id_token";
|
||||||
|
|
||||||
@@ -61,31 +61,31 @@ public class OAuthTokenField extends Field {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new OAuth "id_token" field which links to the given OAuth
|
* Creates a new OpenID "id_token" field which links to the given OpenID
|
||||||
* service using the provided client ID. Successful authentication at the
|
* service using the provided client ID. Successful authentication at the
|
||||||
* OAuth service will result in the client being redirected to the specified
|
* OpenID service will result in the client being redirected to the specified
|
||||||
* redirect URI. The OAuth token will be embedded in the fragment (the part
|
* redirect URI. The OpenID token will be embedded in the fragment (the part
|
||||||
* following the hash symbol) of that URI, which the JavaScript side of
|
* following the hash symbol) of that URI, which the JavaScript side of
|
||||||
* this extension will move to the query parameters.
|
* this extension will move to the query parameters.
|
||||||
*
|
*
|
||||||
* @param authorizationEndpoint
|
* @param authorizationEndpoint
|
||||||
* The full URL of the endpoint accepting OAuth authentication
|
* The full URL of the endpoint accepting OpenID authentication
|
||||||
* requests.
|
* requests.
|
||||||
*
|
*
|
||||||
* @param clientID
|
* @param clientID
|
||||||
* The ID of the OAuth client. This is normally determined ahead of
|
* The ID of the OpenID client. This is normally determined ahead of
|
||||||
* time by the OAuth service through some manual credential request
|
* time by the OpenID service through some manual credential request
|
||||||
* procedure.
|
* procedure.
|
||||||
*
|
*
|
||||||
* @param redirectURI
|
* @param redirectURI
|
||||||
* The URI that the OAuth service should redirect to upon successful
|
* The URI that the OpenID service should redirect to upon successful
|
||||||
* authentication.
|
* authentication.
|
||||||
*/
|
*/
|
||||||
public OAuthTokenField(String authorizationEndpoint, String clientID,
|
public TokenField(String authorizationEndpoint, String clientID,
|
||||||
String redirectURI) {
|
String redirectURI) {
|
||||||
|
|
||||||
// Init base field properties
|
// Init base field properties
|
||||||
super(PARAMETER_NAME, "GUAC_OAUTH_TOKEN");
|
super(PARAMETER_NAME, "GUAC_OPENID_TOKEN");
|
||||||
|
|
||||||
// Build authorization URI from given values
|
// Build authorization URI from given values
|
||||||
try {
|
try {
|
||||||
@@ -106,7 +106,7 @@ public class OAuthTokenField extends Field {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the full URI that this field should link to when a new token
|
* Returns the full URI that this field should link to when a new token
|
||||||
* needs to be obtained from the OAuth service.
|
* needs to be obtained from the OpenID service.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
* The full URI that this field should link to.
|
* The full URI that this field should link to.
|
@@ -17,10 +17,10 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.apache.guacamole.auth.oauth.token;
|
package org.apache.guacamole.auth.openid.token;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import org.apache.guacamole.auth.oauth.conf.ConfigurationService;
|
import org.apache.guacamole.auth.openid.conf.ConfigurationService;
|
||||||
import org.apache.guacamole.GuacamoleException;
|
import org.apache.guacamole.GuacamoleException;
|
||||||
import org.apache.guacamole.GuacamoleSecurityException;
|
import org.apache.guacamole.GuacamoleSecurityException;
|
||||||
import org.apache.guacamole.GuacamoleServerException;
|
import org.apache.guacamole.GuacamoleServerException;
|
||||||
@@ -34,12 +34,12 @@ import org.jose4j.keys.resolvers.HttpsJwksVerificationKeyResolver;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Service for validating ID tokens forwarded to us by the client, verifying
|
* Service for validating ID tokens forwarded to us by the client, verifying
|
||||||
* that they did indeed come from the OAuth service.
|
* that they did indeed come from the OpenID service.
|
||||||
*/
|
*/
|
||||||
public class TokenValidationService {
|
public class TokenValidationService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service for retrieving OAuth configuration information.
|
* Service for retrieving OpenID configuration information.
|
||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
private ConfigurationService confService;
|
private ConfigurationService confService;
|
@@ -17,7 +17,7 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.apache.guacamole.auth.oauth.user;
|
package org.apache.guacamole.auth.openid.user;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import org.apache.guacamole.net.auth.AbstractAuthenticatedUser;
|
import org.apache.guacamole.net.auth.AbstractAuthenticatedUser;
|
||||||
@@ -25,8 +25,8 @@ import org.apache.guacamole.net.auth.AuthenticationProvider;
|
|||||||
import org.apache.guacamole.net.auth.Credentials;
|
import org.apache.guacamole.net.auth.Credentials;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An OAuth-specific implementation of AuthenticatedUser, associating a
|
* An openid-specific implementation of AuthenticatedUser, associating a
|
||||||
* username and particular set of credentials with the OAuth authentication
|
* username and particular set of credentials with the OpenID authentication
|
||||||
* provider.
|
* provider.
|
||||||
*/
|
*/
|
||||||
public class AuthenticatedUser extends AbstractAuthenticatedUser {
|
public class AuthenticatedUser extends AbstractAuthenticatedUser {
|
@@ -2,17 +2,17 @@
|
|||||||
|
|
||||||
"guacamoleVersion" : "0.9.11-incubating",
|
"guacamoleVersion" : "0.9.11-incubating",
|
||||||
|
|
||||||
"name" : "OAuth Authentication Extension",
|
"name" : "OpenID Authentication Extension",
|
||||||
"namespace" : "guac-oauth",
|
"namespace" : "guac-openid",
|
||||||
|
|
||||||
"authProviders" : [
|
"authProviders" : [
|
||||||
"org.apache.guacamole.auth.oauth.OAuthAuthenticationProvider"
|
"org.apache.guacamole.auth.openid.OpenIDAuthenticationProvider"
|
||||||
],
|
],
|
||||||
|
|
||||||
"js" : [
|
"js" : [
|
||||||
"oauthModule.js",
|
"openidModule.js",
|
||||||
"oauthController.js",
|
"openidController.js",
|
||||||
"oauthConfig.js"
|
"openidConfig.js"
|
||||||
]
|
]
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -18,16 +18,16 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Config block which registers OAuth-specific field types.
|
* Config block which registers openid-specific field types.
|
||||||
*/
|
*/
|
||||||
angular.module('guacOAuth').config(['formServiceProvider',
|
angular.module('guacOpenID').config(['formServiceProvider',
|
||||||
function guacOAuthConfig(formServiceProvider) {
|
function guacOpenIDConfig(formServiceProvider) {
|
||||||
|
|
||||||
// Define field for token from OAuth service
|
// Define field for token from OpenID service
|
||||||
formServiceProvider.registerFieldType("GUAC_OAUTH_TOKEN", {
|
formServiceProvider.registerFieldType("GUAC_OPENID_TOKEN", {
|
||||||
template : '',
|
template : '',
|
||||||
controller : 'guacOAuthController',
|
controller : 'guacOpenIDController',
|
||||||
module : 'guacOAuth'
|
module : 'guacOpenID'
|
||||||
});
|
});
|
||||||
|
|
||||||
}]);
|
}]);
|
@@ -18,11 +18,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller for the "GUAC_OAUTH_TOKEN" field which simply redirects the user
|
* Controller for the "GUAC_OPENID_TOKEN" field which simply redirects the user
|
||||||
* immediately to the authorization URI.
|
* immediately to the authorization URI.
|
||||||
*/
|
*/
|
||||||
angular.module('guacOAuth').controller('guacOAuthController', ['$scope',
|
angular.module('guacOpenID').controller('guacOpenIDController', ['$scope',
|
||||||
function guacOAuthController($scope) {
|
function guacOpenIDController($scope) {
|
||||||
|
|
||||||
// Redirect to authorization URI
|
// Redirect to authorization URI
|
||||||
window.location = $scope.field.authorizationURI;
|
window.location = $scope.field.authorizationURI;
|
@@ -18,11 +18,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Module which provides handling for OAuth authentication.
|
* Module which provides handling for OpenID authentication.
|
||||||
*/
|
*/
|
||||||
angular.module('guacOAuth', [
|
angular.module('guacOpenID', [
|
||||||
'form'
|
'form'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Ensure the OAuth module is loaded along with the rest of the app
|
// Ensure the OpenID module is loaded along with the rest of the app
|
||||||
angular.module('index').requires.push('guacOAuth');
|
angular.module('index').requires.push('guacOpenID');
|
Reference in New Issue
Block a user