mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-10 07:01:21 +00:00
GUACAMOLE-136: Implement basic support for verifying user identity using Duo.
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* 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_DUO_SIGNED_RESPONSE" field which uses the DuoWeb
|
||||
* API to prompt the user for additional credentials, ultimately receiving a
|
||||
* signed response from the Duo service.
|
||||
*/
|
||||
angular.module('guacDuo').controller('duoSignedResponseController', ['$scope',
|
||||
function duoSignedResponseController($scope) {
|
||||
|
||||
/**
|
||||
* The iframe which contains the Duo authentication interface.
|
||||
*
|
||||
* @type HTMLIFrameElement
|
||||
*/
|
||||
var iframe = $('.duo-signature-response-field iframe')[0];
|
||||
|
||||
/**
|
||||
* Whether the Duo interface has finished loading within the iframe.
|
||||
*
|
||||
* @type Boolean
|
||||
*/
|
||||
$scope.duoInterfaceLoaded = false;
|
||||
|
||||
/**
|
||||
* Submits the signed response from Duo once the user has authenticated.
|
||||
* This is a callback invoked by the DuoWeb API after the user has been
|
||||
* verified and the signed response has been received.
|
||||
*
|
||||
* @param {HTMLFormElement} form
|
||||
* The form element provided by the DuoWeb API containing the signed
|
||||
* response as the value of an input field named "sig_response".
|
||||
*/
|
||||
var submitSignedResponse = function submitSignedResponse(form) {
|
||||
|
||||
// Update model to match received response
|
||||
$scope.$apply(function updateModel() {
|
||||
$scope.model = form.elements['sig_response'].value;
|
||||
});
|
||||
|
||||
// Submit updated credentials
|
||||
$(iframe).parents('form').submit();
|
||||
|
||||
};
|
||||
|
||||
// Update Duo loaded state when iframe finishes loading
|
||||
iframe.onload = function duoLoaded() {
|
||||
$scope.$apply(function updateLoadedState() {
|
||||
$scope.duoInterfaceLoaded = true;
|
||||
});
|
||||
};
|
||||
|
||||
// Initialize Duo interface within iframe
|
||||
Duo.init({
|
||||
iframe : iframe,
|
||||
host : $scope.field.apiHost,
|
||||
sig_request : $scope.field.signedRequest,
|
||||
submit_callback : submitSignedResponse
|
||||
});
|
||||
|
||||
}]);
|
Reference in New Issue
Block a user