Skip to content
This repository has been archived by the owner on Jul 17, 2023. It is now read-only.

Commit

Permalink
GUACAMOLE-204: Fix style issues, comments, and a couple of minor code…
Browse files Browse the repository at this point in the history
… tweaks.
  • Loading branch information
necouchman committed May 17, 2017
1 parent c5321dd commit f569bf5
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 15 deletions.
9 changes: 6 additions & 3 deletions extensions/guacamole-auth-cas/pom.xml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -141,11 +141,14 @@
<version>0.9.11-incubating</version> <version>0.9.11-incubating</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>

<!-- Apereo CAS Client API -->
<dependency> <dependency>
<groupId>org.jasig.cas.client</groupId> <groupId>org.jasig.cas.client</groupId>
<artifactId>cas-client-core</artifactId> <artifactId>cas-client-core</artifactId>
<version>3.4.1</version> <version>3.4.1</version>
</dependency> </dependency>

<!-- Guice --> <!-- Guice -->
<dependency> <dependency>
<groupId>com.google.inject</groupId> <groupId>com.google.inject</groupId>
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public String getAuthorizationEndpoint() throws GuacamoleException {
* into their browser to access Guacamole. * into their browser to access Guacamole.
* *
* @return * @return
* The client secret to use when communicating with the CAS service, * The URI to redirect the client back to after authentication
* as configured with guacamole.properties. * is completed, as configured in guacamole.properties.
* *
* @throws GuacamoleException * @throws GuacamoleException
* If guacamole.properties cannot be parsed, or if the redirect URI * If guacamole.properties cannot be parsed, or if the redirect URI
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@


/** /**
* Field definition which represents the ticket returned by an CAS service. * Field definition which represents the ticket returned by an CAS service.
* Within the user interface, this will be rendered as an appropriate "Log in * This is processed transparently - the user is redirected to CAS, authenticates
* with ..." button which links to the CAS service. * and then is returned to Guacamole where the ticket field is
* processed.
*/ */
public class CASTicketField extends Field { public class CASTicketField extends Field {


Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -58,21 +58,25 @@ public class TicketValidationService {
* guacamole.properties could not be parsed. * guacamole.properties could not be parsed.
*/ */
public String processUsername(String ticket) throws GuacamoleException { public String processUsername(String ticket) throws GuacamoleException {

AttributePrincipal principal = null; AttributePrincipal principal = null;


// Retrieve the configured CAS URL and establish a ticket validator // Retrieve the configured CAS URL, establish a ticket validator,
// and then attempt to validate the supplied ticket. If that succeeds,
// grab the principal returned by the validator.
String casServerUrl = confService.getAuthorizationEndpoint(); String casServerUrl = confService.getAuthorizationEndpoint();
Cas20ProxyTicketValidator sv = new Cas20ProxyTicketValidator(casServerUrl); Cas20ProxyTicketValidator validator = new Cas20ProxyTicketValidator(casServerUrl);
sv.setAcceptAnyProxy(true); validator.setAcceptAnyProxy(true);
try { try {
String confRedirectURI = confService.getRedirectURI(); String confRedirectURI = confService.getRedirectURI();
Assertion a = sv.validate(ticket, confRedirectURI); Assertion a = validator.validate(ticket, confRedirectURI);
principal = a.getPrincipal(); principal = a.getPrincipal();
} }
catch (TicketValidationException e) { catch (TicketValidationException e) {
throw new GuacamoleException("Ticket validation failed.", e); throw new GuacamoleException("Ticket validation failed.", e);
} }


// Return the principal name as the username.
return principal.getName(); return principal.getName();


} }
Expand Down
11 changes: 7 additions & 4 deletions extensions/guacamole-auth-cas/src/main/resources/casConfig.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -34,16 +34,19 @@ angular.module('guacCAS').config(['formServiceProvider',


/** /**
* Config block which augments the existing routing, providing special handling * Config block which augments the existing routing, providing special handling
* for the "ticket=" fragments provided by OpenID Connect. * for the "ticket=" parameter provided by the CAS authentication process.
*/ */
angular.module('index').config(['$routeProvider','$windowProvider', angular.module('index').config(['$routeProvider','$windowProvider',
function indexRouteConfig($routeProvider,$windowProvider) { function indexRouteConfig($routeProvider,$windowProvider) {


var $window = $windowProvider.$get(); var $window = $windowProvider.$get();
var curPath = $window.location.href; var curPath = $window.location.href;
var ticketPos = curPath.indexOf("?ticket=") + 8; var ticketPos = curPath.indexOf('?ticket=');
var hashPos = curPath.indexOf("#/"); if (ticketPos < 0)
if (ticketPos > 0 && ticketPos < hashPos) { return null;
ticketPos += 8;
var hashPos = curPath.indexOf('#/');
if (ticketPos < hashPos) {
var ticket = curPath.substring(ticketPos, hashPos); var ticket = curPath.substring(ticketPos, hashPos);
var newPath = curPath.substring(0,ticketPos - 8) + '#/?ticket=' + ticket; var newPath = curPath.substring(0,ticketPos - 8) + '#/?ticket=' + ticket;
$window.location.href = newPath; $window.location.href = newPath;
Expand Down

0 comments on commit f569bf5

Please sign in to comment.