Merge oidc settings for user directory view

This commit is contained in:
Johannes Zellner
2023-08-11 11:32:45 +02:00
parent cd0b51dac2
commit 4936475c2a
7 changed files with 333 additions and 367 deletions

View File

@@ -25,6 +25,7 @@ angular.module('Application').controller('UserSettingsController', ['$scope', '$
$scope.ready = false;
$scope.config = Client.getConfig();
$scope.userInfo = Client.getUserInfo();
$scope.oidcClients = [];
$scope.profileConfig = {
editableUserProfiles: true,
@@ -287,10 +288,142 @@ angular.module('Application').controller('UserSettingsController', ['$scope', '$
}
};
$scope.refreshOIDCClients = function () {
Client.getOidcClients(function (error, result) {
if (error) return console.error('Failed to load oidc clients', error);
$scope.oidcClients = result;
});
};
$scope.clientAdd = {
busy: false,
error: {},
id: '',
name: '',
secret: '',
loginRedirectUri: '',
tokenSignatureAlgorithm: '',
show: function () {
$scope.clientAdd.id = '';
$scope.clientAdd.secret = '';
$scope.clientAdd.name = '';
$scope.clientAdd.loginRedirectUri = '';
$scope.clientAdd.tokenSignatureAlgorithm = 'RS256';
$scope.clientAdd.busy = false;
$scope.clientAdd.error = null;
$scope.clientAddForm.$setPristine();
$('#oidcClientAddModal').modal('show');
},
submit: function () {
$scope.clientAdd.busy = true;
$scope.clientAdd.error = {};
Client.addOidcClient($scope.clientAdd.id, $scope.clientAdd.name, $scope.clientAdd.secret, $scope.clientAdd.loginRedirectUri, $scope.clientAdd.tokenSignatureAlgorithm, function (error) {
if (error) {
if (error.statusCode === 409) {
$scope.clientAdd.error.id = 'Client ID already exists';
$('#clientId').focus();
} else {
console.error('Unable to add openid client.', error);
}
$scope.clientAdd.busy = false;
return;
}
$scope.refreshOIDCClients();
$scope.clientAdd.busy = false;
$('#oidcClientAddModal').modal('hide');
});
}
};
$scope.clientEdit = {
busy: false,
error: {},
id: '',
name: '',
secret: '',
loginRedirectUri: '',
tokenSignatureAlgorithm: '',
show: function (client) {
$scope.clientEdit.id = client.id;
$scope.clientEdit.name = client.name;
$scope.clientEdit.secret = client.secret;
$scope.clientEdit.loginRedirectUri = client.loginRedirectUri;
$scope.clientEdit.tokenSignatureAlgorithm = client.tokenSignatureAlgorithm;
$scope.clientEdit.busy = false;
$scope.clientEdit.error = null;
$scope.clientEditForm.$setPristine();
$('#oidcClientEditModal').modal('show');
},
submit: function () {
$scope.clientEdit.busy = true;
$scope.clientEdit.error = {};
Client.updateOidcClient($scope.clientEdit.id, $scope.clientEdit.name, $scope.clientEdit.secret, $scope.clientEdit.loginRedirectUri, $scope.clientEdit.tokenSignatureAlgorithm, function (error) {
if (error) {
console.error('Unable to edit openid client.', error);
$scope.clientEdit.busy = false;
return;
}
$scope.refreshOIDCClients();
$scope.clientEdit.busy = false;
$('#oidcClientEditModal').modal('hide');
});
}
};
$scope.deleteClient = {
busy: false,
error: {},
id: '',
show: function (client) {
$scope.deleteClient.busy = false;
$scope.deleteClient.id = client.id;
$('#oidcClientDeleteModal').modal('show');
},
submit: function () {
Client.delOidcClient($scope.deleteClient.id, function (error) {
$scope.deleteClient.busy = false;
if (error) return console.error('Failed to delete openid client', error);
$scope.refreshOIDCClients();
$('#oidcClientDeleteModal').modal('hide');
});
}
};
Client.onReady(function () {
$scope.externalLdap.refresh();
$scope.profileConfig.refresh();
$scope.userDirectoryConfig.refresh();
$scope.refreshOIDCClients();
});
// setup all the dialog focus handling
['oidcClientAddModal', 'oidcClientEditModal'].forEach(function (id) {
$('#' + id).on('shown.bs.modal', function () {
$(this).find('[autofocus]:first').focus();
});
});
new Clipboard('#userDirectoryUrlClipboardButton').on('success', function(e) {