mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUAC-971: Re-authenticate with server for each page visited.
This commit is contained in:
@@ -25,55 +25,113 @@
|
|||||||
*/
|
*/
|
||||||
angular.module('index').config(['$routeProvider', '$locationProvider',
|
angular.module('index').config(['$routeProvider', '$locationProvider',
|
||||||
function indexRouteConfig($routeProvider, $locationProvider) {
|
function indexRouteConfig($routeProvider, $locationProvider) {
|
||||||
|
|
||||||
// Disable HTML5 mode (use # for routing)
|
// Disable HTML5 mode (use # for routing)
|
||||||
$locationProvider.html5Mode(false);
|
$locationProvider.html5Mode(false);
|
||||||
|
|
||||||
$routeProvider
|
/**
|
||||||
.when('/', {
|
* Attempts to re-authenticate with the Guacamole server, sending any
|
||||||
title: 'APP.NAME',
|
* query parameters in the URL, along with the current auth token, and
|
||||||
bodyClassName: 'home',
|
* updating locally stored token if necessary.
|
||||||
templateUrl: 'app/home/templates/home.html',
|
*
|
||||||
controller: 'homeController'
|
* @param {Service} $injector
|
||||||
})
|
* The Angular $injector service.
|
||||||
.when('/manage/', {
|
*
|
||||||
title: 'APP.NAME',
|
* @returns {Promise}
|
||||||
bodyClassName: 'manage',
|
* A promise which resolves successfully only after an attempt to
|
||||||
templateUrl: 'app/manage/templates/manage.html',
|
* re-authenticate has been made.
|
||||||
controller: 'manageController'
|
*/
|
||||||
})
|
var updateCurrentToken = ['$injector', function updateCurrentToken($injector) {
|
||||||
.when('/manage/connections/:id?', {
|
|
||||||
title: 'APP.NAME',
|
// Required services
|
||||||
bodyClassName: 'manage',
|
var $location = $injector.get('$location');
|
||||||
templateUrl: 'app/manage/templates/manageConnection.html',
|
var $q = $injector.get('$q');
|
||||||
controller: 'manageConnectionController'
|
var authenticationService = $injector.get('authenticationService');
|
||||||
})
|
|
||||||
.when('/manage/connectionGroups/:id?', {
|
// Promise for authentication attempt
|
||||||
title: 'APP.NAME',
|
var authAttempt = $q.defer();
|
||||||
bodyClassName: 'manage',
|
|
||||||
templateUrl: 'app/manage/templates/manageConnectionGroup.html',
|
// Re-authenticate including any parameters in URL
|
||||||
controller: 'manageConnectionGroupController'
|
authenticationService.updateCurrentToken($location.search())
|
||||||
})
|
['finally'](function authenticationAttemptComplete() {
|
||||||
.when('/manage/users/:id', {
|
authAttempt.resolve();
|
||||||
title: 'APP.NAME',
|
|
||||||
bodyClassName: 'manage',
|
|
||||||
templateUrl: 'app/manage/templates/manageUser.html',
|
|
||||||
controller: 'manageUserController'
|
|
||||||
})
|
|
||||||
.when('/login/', {
|
|
||||||
title: 'APP.NAME',
|
|
||||||
bodyClassName: 'login',
|
|
||||||
templateUrl: 'app/login/templates/login.html',
|
|
||||||
controller: 'loginController'
|
|
||||||
})
|
|
||||||
.when('/client/:type/:id/:params?', {
|
|
||||||
bodyClassName: 'client',
|
|
||||||
templateUrl: 'app/client/templates/client.html',
|
|
||||||
controller: 'clientController'
|
|
||||||
})
|
|
||||||
.otherwise({
|
|
||||||
redirectTo: '/'
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Return promise that will resolve regardless of success/failure
|
||||||
|
return authAttempt.promise;
|
||||||
|
|
||||||
|
}];
|
||||||
|
|
||||||
|
// Configure each possible route
|
||||||
|
$routeProvider
|
||||||
|
|
||||||
|
// Home screen
|
||||||
|
.when('/', {
|
||||||
|
title : 'APP.NAME',
|
||||||
|
bodyClassName : 'home',
|
||||||
|
templateUrl : 'app/home/templates/home.html',
|
||||||
|
controller : 'homeController',
|
||||||
|
resolve : { updateCurrentToken: updateCurrentToken }
|
||||||
|
})
|
||||||
|
|
||||||
|
// Management screen
|
||||||
|
.when('/manage/', {
|
||||||
|
title : 'APP.NAME',
|
||||||
|
bodyClassName : 'manage',
|
||||||
|
templateUrl : 'app/manage/templates/manage.html',
|
||||||
|
controller : 'manageController',
|
||||||
|
resolve : { updateCurrentToken: updateCurrentToken }
|
||||||
|
})
|
||||||
|
|
||||||
|
// Connection editor
|
||||||
|
.when('/manage/connections/:id?', {
|
||||||
|
title : 'APP.NAME',
|
||||||
|
bodyClassName : 'manage',
|
||||||
|
templateUrl : 'app/manage/templates/manageConnection.html',
|
||||||
|
controller : 'manageConnectionController',
|
||||||
|
resolve : { updateCurrentToken: updateCurrentToken }
|
||||||
|
})
|
||||||
|
|
||||||
|
// Connection group editor
|
||||||
|
.when('/manage/connectionGroups/:id?', {
|
||||||
|
title : 'APP.NAME',
|
||||||
|
bodyClassName : 'manage',
|
||||||
|
templateUrl : 'app/manage/templates/manageConnectionGroup.html',
|
||||||
|
controller : 'manageConnectionGroupController',
|
||||||
|
resolve : { updateCurrentToken: updateCurrentToken }
|
||||||
|
})
|
||||||
|
|
||||||
|
// User editor
|
||||||
|
.when('/manage/users/:id', {
|
||||||
|
title : 'APP.NAME',
|
||||||
|
bodyClassName : 'manage',
|
||||||
|
templateUrl : 'app/manage/templates/manageUser.html',
|
||||||
|
controller : 'manageUserController',
|
||||||
|
resolve : { updateCurrentToken: updateCurrentToken }
|
||||||
|
})
|
||||||
|
|
||||||
|
// Login screen
|
||||||
|
.when('/login/', {
|
||||||
|
title : 'APP.NAME',
|
||||||
|
bodyClassName : 'login',
|
||||||
|
templateUrl : 'app/login/templates/login.html',
|
||||||
|
controller : 'loginController',
|
||||||
|
resolve : { updateCurrentToken: updateCurrentToken }
|
||||||
|
})
|
||||||
|
|
||||||
|
// Client view
|
||||||
|
.when('/client/:type/:id/:params?', {
|
||||||
|
bodyClassName : 'client',
|
||||||
|
templateUrl : 'app/client/templates/client.html',
|
||||||
|
controller : 'clientController',
|
||||||
|
resolve : { updateCurrentToken: updateCurrentToken }
|
||||||
|
})
|
||||||
|
|
||||||
|
// Redirect to home screen if page not found
|
||||||
|
.otherwise({
|
||||||
|
redirectTo : '/'
|
||||||
|
});
|
||||||
|
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user