GUACAMOLE-103: Implement common redirect form field.

This commit is contained in:
Virtually Nick
2020-05-25 19:55:38 -04:00
parent 6c3095135d
commit 5762cdda47
25 changed files with 179 additions and 402 deletions

View File

@@ -53,85 +53,6 @@
</configuration> </configuration>
</plugin> </plugin>
<!-- Pre-cache Angular templates with maven-angular-plugin -->
<plugin>
<groupId>com.keithbranton.mojo</groupId>
<artifactId>angular-maven-plugin</artifactId>
<version>0.3.2</version>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>html2js</goal>
</goals>
</execution>
</executions>
<configuration>
<sourceDir>${basedir}/src/main/resources</sourceDir>
<include>**/*.html</include>
<target>${basedir}/src/main/resources/generated/templates-main/templates.js</target>
<prefix>app/ext/guac-cas</prefix>
</configuration>
</plugin>
<!-- JS/CSS Minification Plugin -->
<plugin>
<groupId>com.samaxes.maven</groupId>
<artifactId>minify-maven-plugin</artifactId>
<version>1.7.5</version>
<executions>
<execution>
<id>default-cli</id>
<configuration>
<charset>UTF-8</charset>
<webappSourceDir>${basedir}/src/main/resources</webappSourceDir>
<webappTargetDir>${project.build.directory}/classes</webappTargetDir>
<cssSourceDir>/</cssSourceDir>
<cssTargetDir>/</cssTargetDir>
<cssFinalFile>cas.css</cssFinalFile>
<cssSourceFiles>
<cssSourceFile>license.txt</cssSourceFile>
</cssSourceFiles>
<cssSourceIncludes>
<cssSourceInclude>**/*.css</cssSourceInclude>
</cssSourceIncludes>
<jsSourceDir>/</jsSourceDir>
<jsTargetDir>/</jsTargetDir>
<jsFinalFile>cas.js</jsFinalFile>
<jsSourceFiles>
<jsSourceFile>license.txt</jsSourceFile>
</jsSourceFiles>
<jsSourceIncludes>
<jsSourceInclude>**/*.js</jsSourceInclude>
</jsSourceIncludes>
<!-- Do not minify and include tests -->
<jsSourceExcludes>
<jsSourceExclude>**/*.test.js</jsSourceExclude>
</jsSourceExcludes>
<jsEngine>CLOSURE</jsEngine>
<!-- Disable warnings for JSDoc annotations -->
<closureWarningLevels>
<misplacedTypeAnnotation>OFF</misplacedTypeAnnotation>
<nonStandardJsDocs>OFF</nonStandardJsDocs>
</closureWarningLevels>
</configuration>
<goals>
<goal>minify</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Copy dependencies prior to packaging --> <!-- Copy dependencies prior to packaging -->
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>

View File

@@ -99,7 +99,8 @@ public class AuthenticationProviderService {
// to the authorization page via JavaScript) // to the authorization page via JavaScript)
new CASTicketField( new CASTicketField(
confService.getAuthorizationEndpoint(), confService.getAuthorizationEndpoint(),
confService.getRedirectURI() confService.getRedirectURI(),
"LOGIN.INFO_CAS_REDIRECT_PENDING"
) )
})) }))

View File

@@ -21,7 +21,7 @@ package org.apache.guacamole.auth.cas.form;
import java.net.URI; import java.net.URI;
import javax.ws.rs.core.UriBuilder; import javax.ws.rs.core.UriBuilder;
import org.apache.guacamole.form.Field; import org.apache.guacamole.form.RedirectField;
/** /**
@@ -30,25 +30,18 @@ import org.apache.guacamole.form.Field;
* and then is returned to Guacamole where the ticket field is * and then is returned to Guacamole where the ticket field is
* processed. * processed.
*/ */
public class CASTicketField extends Field { public class CASTicketField extends RedirectField {
/** /**
* The standard HTTP parameter which will be included within the URL by all * The parameter that will be present upon successful CAS authentication.
* CAS services upon successful authentication and redirect.
*/ */
public static final String PARAMETER_NAME = "ticket"; public static final String PARAMETER_NAME = "ticket";
/** /**
* The standard URI name for the CAS login resource. * The standard URI name for the CAS login resource.
*/ */
private static final String CAS_LOGIN_URI = "login"; private static final String CAS_LOGIN_URI = "login";
/**
* The full URI which the field should link to.
*/
private final URI authorizationURI;
/** /**
* Creates a new CAS "ticket" field which links to the given CAS * Creates a new CAS "ticket" field which links to the given CAS
* service using the provided client ID. Successful authentication at the * service using the provided client ID. Successful authentication at the
@@ -64,28 +57,21 @@ public class CASTicketField extends Field {
* @param redirectURI * @param redirectURI
* The URI that the CAS service should redirect to upon successful * The URI that the CAS service should redirect to upon successful
* authentication. * authentication.
*
* @param redirectMsg
* The message that will be displayed for the user while the redirect
* is processed. This will be processed through Guacamole's translation
* system.
*/ */
public CASTicketField(URI authorizationEndpoint, URI redirectURI) { public CASTicketField(URI authorizationEndpoint, URI redirectURI,
String redirectMsg) {
// Init base field properties
super(PARAMETER_NAME, "GUAC_CAS_TICKET");
this.authorizationURI = UriBuilder.fromUri(authorizationEndpoint) super(PARAMETER_NAME, UriBuilder.fromUri(authorizationEndpoint)
.path(CAS_LOGIN_URI) .path(CAS_LOGIN_URI)
.queryParam("service", redirectURI) .queryParam("service", redirectURI)
.build(); .build(),
redirectMsg);
} }
/**
* Returns the full URI that this field should link to when a new ticket
* needs to be obtained from the CAS service.
*
* @return
* The full URI that this field should link to.
*/
public String getAuthorizationURI() {
return authorizationURI.toString();
}
} }

View File

@@ -1,28 +0,0 @@
/*
* 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.
*/
/**
* Module which provides handling for CAS authentication.
*/
angular.module('guacCAS', [
'form'
]);
// Ensure the CAS module is loaded along with the rest of the app
angular.module('index').requires.push('guacCAS');

View File

@@ -1,33 +0,0 @@
/*
* 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.
*/
/**
* Config block which registers CAS-specific field types.
*/
angular.module('guacCAS').config(['formServiceProvider',
function guacCASConfig(formServiceProvider) {
// Define field for ticket from CAS service
formServiceProvider.registerFieldType("GUAC_CAS_TICKET", {
templateUrl : 'app/ext/guac-cas/templates/casTicketField.html',
controller : 'guacCASController',
module : 'guacCAS'
});
}]);

View File

@@ -1,30 +0,0 @@
/*
* 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.
*/
/**
* Controller for the "GUAC_CAS_TICKET" field which simply redirects the user
* immediately to the authorization URI.
*/
angular.module('guacCAS').controller('guacCASController', ['$scope',
function guacCASController($scope) {
// Redirect to authorization URI
window.location = $scope.field.authorizationURI;
}]);

View File

@@ -1,5 +0,0 @@
<div class="cas-ticket-field-container">
<div class="cas-ticket-field">
<p>{{ 'LOGIN.INFO_CAS_REDIRECT_PENDING' | translate }}</p>
</div>
</div>

View File

@@ -53,27 +53,6 @@
</configuration> </configuration>
</plugin> </plugin>
<!-- Pre-cache Angular templates with maven-angular-plugin -->
<plugin>
<groupId>com.keithbranton.mojo</groupId>
<artifactId>angular-maven-plugin</artifactId>
<version>0.3.2</version>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>html2js</goal>
</goals>
</execution>
</executions>
<configuration>
<sourceDir>${basedir}/src/main/resources</sourceDir>
<include>**/*.html</include>
<target>${basedir}/src/main/resources/generated/templates-main/templates.js</target>
<prefix>app/ext/guac-openid</prefix>
</configuration>
</plugin>
<!-- JS/CSS Minification Plugin --> <!-- JS/CSS Minification Plugin -->
<plugin> <plugin>
<groupId>com.samaxes.maven</groupId> <groupId>com.samaxes.maven</groupId>
@@ -88,18 +67,6 @@
<webappSourceDir>${basedir}/src/main/resources</webappSourceDir> <webappSourceDir>${basedir}/src/main/resources</webappSourceDir>
<webappTargetDir>${project.build.directory}/classes</webappTargetDir> <webappTargetDir>${project.build.directory}/classes</webappTargetDir>
<cssSourceDir>/</cssSourceDir>
<cssTargetDir>/</cssTargetDir>
<cssFinalFile>openid.css</cssFinalFile>
<cssSourceFiles>
<cssSourceFile>license.txt</cssSourceFile>
</cssSourceFiles>
<cssSourceIncludes>
<cssSourceInclude>**/*.css</cssSourceInclude>
</cssSourceIncludes>
<jsSourceDir>/</jsSourceDir> <jsSourceDir>/</jsSourceDir>
<jsTargetDir>/</jsTargetDir> <jsTargetDir>/</jsTargetDir>
<jsFinalFile>openid.js</jsFinalFile> <jsFinalFile>openid.js</jsFinalFile>

View File

@@ -121,7 +121,8 @@ public class AuthenticationProviderService {
confService.getScope(), confService.getScope(),
confService.getClientID(), confService.getClientID(),
confService.getRedirectURI(), confService.getRedirectURI(),
nonceService.generate(confService.getMaxNonceValidity() * 60000L) nonceService.generate(confService.getMaxNonceValidity() * 60000L),
"LOGIN.INFO_OID_PENDING_REDIRECT"
) )
})) }))

View File

@@ -21,13 +21,13 @@ package org.apache.guacamole.auth.openid.form;
import java.net.URI; import java.net.URI;
import javax.ws.rs.core.UriBuilder; import javax.ws.rs.core.UriBuilder;
import org.apache.guacamole.form.Field; import org.apache.guacamole.form.RedirectField;
/** /**
* Field definition which represents the token returned by an OpenID Connect * Field definition which represents the token returned by an OpenID Connect
* service. * service.
*/ */
public class TokenField extends Field { public class TokenField extends RedirectField {
/** /**
* 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
@@ -35,11 +35,6 @@ public class TokenField extends Field {
*/ */
public static final String PARAMETER_NAME = "id_token"; public static final String PARAMETER_NAME = "id_token";
/**
* The full URI which the field should link to.
*/
private final URI authorizationURI;
/** /**
* Creates a new field which requests authentication via OpenID connect. * Creates a new field which requests authentication via OpenID connect.
* Successful authentication at the OpenID Connect service will result in * Successful authentication at the OpenID Connect service will result in
@@ -68,32 +63,24 @@ public class TokenField extends Field {
* @param nonce * @param nonce
* A random string unique to this request. To defend against replay * A random string unique to this request. To defend against replay
* attacks, this value must cease being valid after its first use. * attacks, this value must cease being valid after its first use.
*
* @param redirectMsg
* The message that will be displayed to the user during redirect. This
* will be processed through Guacamole's translation system.
*/ */
public TokenField(URI authorizationEndpoint, String scope, public TokenField(URI authorizationEndpoint, String scope,
String clientID, URI redirectURI, String nonce) { String clientID, URI redirectURI, String nonce,
String redirectMsg) {
// Init base field properties super(PARAMETER_NAME, UriBuilder.fromUri(authorizationEndpoint)
super(PARAMETER_NAME, "GUAC_OPENID_TOKEN");
this.authorizationURI = UriBuilder.fromUri(authorizationEndpoint)
.queryParam("scope", scope) .queryParam("scope", scope)
.queryParam("response_type", "id_token") .queryParam("response_type", "id_token")
.queryParam("client_id", clientID) .queryParam("client_id", clientID)
.queryParam("redirect_uri", redirectURI) .queryParam("redirect_uri", redirectURI)
.queryParam("nonce", nonce) .queryParam("nonce", nonce)
.build(); .build(),
redirectMsg);
} }
/**
* Returns the full URI that this field should link to when a new token
* needs to be obtained from the OpenID service.
*
* @return
* The full URI that this field should link to.
*/
public String getAuthorizationURI() {
return authorizationURI.toString();
}
} }

View File

@@ -1,30 +0,0 @@
/*
* 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.
*/
/**
* Controller for the "GUAC_OPENID_TOKEN" field which simply redirects the user
* immediately to the authorization URI.
*/
angular.module('guacOpenID').controller('guacOpenIDController', ['$scope',
function guacOpenIDController($scope) {
// Redirect to authorization URI
window.location = $scope.field.authorizationURI;
}]);

View File

@@ -17,14 +17,6 @@
"js" : [ "js" : [
"openid.min.js" "openid.min.js"
], ]
"css" : [
"openid.min.css"
],
"resources" : {
"templates/openidTokenField.html" : "text/html"
}
} }

View File

@@ -1,28 +0,0 @@
/*
* 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.
*/
/**
* Module which provides handling for OpenID authentication.
*/
angular.module('guacOpenID', [
'form'
]);
// Ensure the OpenID module is loaded along with the rest of the app
angular.module('index').requires.push('guacOpenID');

View File

@@ -1,35 +0,0 @@
/*
* 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.
*/
.openid-token-field-container {
height: 100%;
width: 100%;
position: fixed;
left: 0;
top: 0;
display: table;
background: white;
}
.openid-token-field {
width: 100%;
display: table-cell;
vertical-align: middle;
text-align: center;
}

View File

@@ -1,5 +0,0 @@
<div class="openid-token-field-container">
<div class="openid-token-field">
<p>{{ 'LOGIN.INFO_REDIRECT_PENDING' | translate }}</p>
</div>
</div>

View File

@@ -28,6 +28,7 @@
* parameter in the first position; it may occur after several other parameters * parameter in the first position; it may occur after several other parameters
* within the fragment. * within the fragment.
*/ */
(function guacOpenIDTransformToken() { (function guacOpenIDTransformToken() {
if (/^#(?![?\/])(.*&)?id_token=/.test(location.hash)) if (/^#(?![?\/])(.*&)?id_token=/.test(location.hash))
location.hash = '/?' + location.hash.substring(1); location.hash = '/?' + location.hash.substring(1);

View File

@@ -1,12 +1,7 @@
{ {
"DATA_SOURCE_OPENID" : {
"NAME" : "OpenID SSO Backend"
},
"LOGIN" : { "LOGIN" : {
"FIELD_HEADER_ID_TOKEN" : "", "INFO_OID_REDIRECT_PENDING" : "Bitte warten, Sie werden zum Identitätsprovider weitergeleitet..."
"INFO_REDIRECT_PENDING" : "Bitte warten, Sie werden zum Identitätsprovider weitergeleitet..."
} }
} }

View File

@@ -6,7 +6,7 @@
"LOGIN" : { "LOGIN" : {
"FIELD_HEADER_ID_TOKEN" : "", "FIELD_HEADER_ID_TOKEN" : "",
"INFO_REDIRECT_PENDING" : "Please wait, redirecting to identity provider..." "INFO_OID_REDIRECT_PENDING" : "Please wait, redirecting to identity provider..."
} }
} }

View File

@@ -1,7 +1,7 @@
{ {
"LOGIN" : { "LOGIN" : {
"INFO_REDIRECT_PENDING" : "IDプロバイダへリダイレクトしています。" "INFO_OID_REDIRECT_PENDING" : "IDプロバイダへリダイレクトしています。"
} }
} }

View File

@@ -45,51 +45,51 @@ public class Field {
/** /**
* A text field, accepting arbitrary values. * A text field, accepting arbitrary values.
*/ */
public static String TEXT = "TEXT"; public static final String TEXT = "TEXT";
/** /**
* An email address field. This field type generally behaves * An email address field. This field type generally behaves
* identically to arbitrary text fields, but has semantic differences. * identically to arbitrary text fields, but has semantic differences.
*/ */
public static String EMAIL = "EMAIL"; public static final String EMAIL = "EMAIL";
/** /**
* A username field. This field type generally behaves identically to * A username field. This field type generally behaves identically to
* arbitrary text fields, but has semantic differences. * arbitrary text fields, but has semantic differences.
*/ */
public static String USERNAME = "USERNAME"; public static final String USERNAME = "USERNAME";
/** /**
* A password field, whose value is sensitive and must be hidden. * A password field, whose value is sensitive and must be hidden.
*/ */
public static String PASSWORD = "PASSWORD"; public static final String PASSWORD = "PASSWORD";
/** /**
* A numeric field, whose value must contain only digits. * A numeric field, whose value must contain only digits.
*/ */
public static String NUMERIC = "NUMERIC"; public static final String NUMERIC = "NUMERIC";
/** /**
* A boolean field, whose value is either blank or "true". * A boolean field, whose value is either blank or "true".
*/ */
public static String BOOLEAN = "BOOLEAN"; public static final String BOOLEAN = "BOOLEAN";
/** /**
* An enumerated field, whose legal values are fully enumerated by a * An enumerated field, whose legal values are fully enumerated by a
* provided, finite list. * provided, finite list.
*/ */
public static String ENUM = "ENUM"; public static final String ENUM = "ENUM";
/** /**
* A text field that can span more than one line. * A text field that can span more than one line.
*/ */
public static String MULTILINE = "MULTILINE"; public static final String MULTILINE = "MULTILINE";
/** /**
* A time zone field whose legal values are only valid time zone IDs, * A time zone field whose legal values are only valid time zone IDs,
* as dictated by Java within TimeZone.getAvailableIDs(). * as dictated by Java within TimeZone.getAvailableIDs().
*/ */
public static String TIMEZONE = "TIMEZONE"; public static final String TIMEZONE = "TIMEZONE";
/** /**
* Field type which allows selection of languages. The languages * Field type which allows selection of languages. The languages
@@ -97,31 +97,37 @@ public class Field {
* application. Legal values are valid language IDs, as dictated by * application. Legal values are valid language IDs, as dictated by
* the filenames of Guacamole's available translations. * the filenames of Guacamole's available translations.
*/ */
public static String LANGUAGE = "LANGUAGE"; public static final String LANGUAGE = "LANGUAGE";
/** /**
* A date field whose legal values conform to the pattern "YYYY-MM-DD", * A date field whose legal values conform to the pattern "YYYY-MM-DD",
* zero-padded. * zero-padded.
*/ */
public static String DATE = "DATE"; public static final String DATE = "DATE";
/** /**
* A time field whose legal values conform to the pattern "HH:MM:SS", * A time field whose legal values conform to the pattern "HH:MM:SS",
* zero-padded, 24-hour. * zero-padded, 24-hour.
*/ */
public static String TIME = "TIME"; public static final String TIME = "TIME";
/** /**
* An HTTP query parameter which is expected to be embedded in the URL * An HTTP query parameter which is expected to be embedded in the URL
* given to a user. * given to a user.
*/ */
public static String QUERY_PARAMETER = "QUERY_PARAMETER"; public static final String QUERY_PARAMETER = "QUERY_PARAMETER";
/** /**
* A color scheme accepted by the Guacamole server terminal emulator * A color scheme accepted by the Guacamole server terminal emulator
* and protocols which leverage it. * and protocols which leverage it.
*/ */
public static String TERMINAL_COLOR_SCHEME = "TERMINAL_COLOR_SCHEME"; public static final String TERMINAL_COLOR_SCHEME = "TERMINAL_COLOR_SCHEME";
/**
* A redirect field whose value is an encoded URL to which the user
* will be redirected.
*/
public static final String REDIRECT = "REDIRECT";
} }

View File

@@ -0,0 +1,86 @@
/*
* 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.form;
import java.net.URI;
/**
* A Guacamole field that redirects a user to another page.
*/
public class RedirectField extends Field {
/**
* The encoded URL of the redirect.
*/
private final URI redirectUrl;
/**
* The message that will be displayed for the user during the redirect
* process. This will be processed through Guacamole's translation system.
*/
private final String redirectMsg;
/**
* Creates a new field which facilitates redirection of the user
* to another page.
*
* @param name
* The name of this field.
*
* @param redirectUrl
* The URL to which the user should be redirected.
*
* @param redirectMsg
* The message to display during the redirect, which will be processed
* through Guacamole's translation system.
*/
public RedirectField(String name, URI redirectUrl, String redirectMsg) {
// Init base field properties
super(name, Field.Type.REDIRECT);
// Store the URL to which the user will be redirected.
this.redirectUrl = redirectUrl;
this.redirectMsg = redirectMsg;
}
/**
* Returns the URL of the redirect.
*
* @return
* The URL of the redirect.
*/
public String getRedirectUrl() {
return redirectUrl.toString();
}
/**
* Returns the message that will be displayed for the user while the
* redirect takes place.
*
* @return
* The message to display for the user.
*/
public String getRedirectMsg() {
return redirectMsg;
}
}

View File

@@ -18,16 +18,26 @@
*/ */
/** /**
* Config block which registers openid-specific field types. * Controller for the redirect field, which redirects the user to the provided
* URL.
*/ */
angular.module('guacOpenID').config(['formServiceProvider', angular.module('form').controller('redirectFieldController', ['$scope','$window',
function guacOpenIDConfig(formServiceProvider) { function redirectFieldController($scope,$window) {
// Define field for token from OpenID service /**
formServiceProvider.registerFieldType("GUAC_OPENID_TOKEN", { * Redirect the user to the provided URL.
templateUrl : 'app/ext/guac-openid/templates/openidTokenField.html', */
controller : 'guacOpenIDController', $window.location.href = $scope.field.redirectUrl;
module : 'guacOpenID'
}); /**
* Return the text that should be displayed to the user while the redirect
* is taking place.
*
* @return {String}
* The text to display for the user during the redirect.
*/
$scope.getRedirectMsg = function getRedirctMsg() {
return $scope.field.redirectMsg;
};
}]); }]);

View File

@@ -192,6 +192,19 @@ angular.module('form').provider('formService', function formServiceProvider() {
module : 'form', module : 'form',
controller : 'terminalColorSchemeFieldController', controller : 'terminalColorSchemeFieldController',
templateUrl : 'app/form/templates/terminalColorSchemeField.html' templateUrl : 'app/form/templates/terminalColorSchemeField.html'
},
/**
* Field type that supports redirecting the client browser to another
* URL.
*
* @see {@link Field.Type.REDIRECT}
* @type FieldType
*/
'REDIRECT' : {
module : 'form',
controller : 'redirectFieldController',
templateUrl : 'app/form/templates/redirectField.html'
} }
}; };

View File

@@ -17,7 +17,7 @@
* under the License. * under the License.
*/ */
.cas-ticket-field-container { .redirect-field-container {
height: 100%; height: 100%;
width: 100%; width: 100%;
position: fixed; position: fixed;
@@ -27,7 +27,7 @@
background: white; background: white;
} }
.cas-ticket-field { .redirect-field {
width: 100%; width: 100%;
display: table-cell; display: table-cell;
vertical-align: middle; vertical-align: middle;

View File

@@ -0,0 +1,5 @@
<div class="redirect-field-container">
<div class="redirect-field">
<p>{{ getRedirectMsg() | translate }}</p>
</div>
</div>