admin: Replace PKI page by authentication settings, refactor

This commit is contained in:
nemunaire 2025-03-26 12:32:16 +01:00
parent 4dcf1218d8
commit 7e301b8ecb
6 changed files with 114 additions and 33 deletions

View file

@ -25,6 +25,10 @@ angular.module("FICApp", ["ngRoute", "ngResource", "ngSanitize"])
controller: "SettingsController",
templateUrl: "views/settings.html"
})
.when("/auth", {
controller: "AuthController",
templateUrl: "views/auth.html"
})
.when("/pki", {
controller: "PKIController",
templateUrl: "views/pki.html"
@ -921,6 +925,49 @@ angular.module("FICApp")
};
})
.controller("AuthController", function ($scope, $http) {
$scope.generateHtpasswd = function () {
$http.post("api/htpasswd").then(function () {
$scope.addToast('success', 'Fichier htpasswd généré avec succès');
}, function (response) {
$scope.addToast('danger', 'An error occurs when generating htpasswd file:', response.data.errmsg);
});
};
$scope.removeHtpasswd = function () {
$http.delete("api/htpasswd").then(function () {
$scope.addToast('success', 'Fichier htpasswd supprimé avec succès');
}, function (response) {
$scope.addToast('danger', 'An error occurs when deleting htpasswd file:', response.data.errmsg);
});
};
})
.controller("OAuthController", function ($scope, $http) {
$scope.refreshOAuthStatus = function () {
$http.get("api/oauth-status").then(function (res) {
$scope.oauth_status = response.data;
});
};
$scope.genDexCfg = function () {
$http.post("api/dex.yaml").then(function () {
$http.post("api/dex-password.tpl").then(function () {
$scope.addToast('success', 'Dex config refreshed.', "Don't forget to reload/reboot frontend host.");
}, function (response) {
$scope.addToast('danger', 'An error occurs when generating dex password tpl:', response.data.errmsg);
});
}, function (response) {
$scope.addToast('danger', 'An error occurs when generating dex config:', response.data.errmsg);
});
$http.post("api/vouch-proxy.yaml").then(function () {
$scope.addToast('success', 'VouchProxy config refreshed.', "Don't forget to reload/reboot frontend host.");
}, function (response) {
$scope.addToast('danger', 'An error occurs when generating VouchProxy config:', response.data.errmsg);
});
}
})
.controller("PKIController", function ($scope, $rootScope, Certificate, CACertificate, Team, $location, $http) {
var ts = Date.now() - Date.now() % 86400000;
var d = new Date(ts);
@ -1005,20 +1052,6 @@ angular.module("FICApp")
$scope.addToast('danger', 'An error occurs when generating certificate:', response.data.errmsg);
});
};
$scope.generateHtpasswd = function () {
$http.post("api/htpasswd").then(function () {
$scope.addToast('success', 'Fichier htpasswd généré avec succès');
}, function (response) {
$scope.addToast('danger', 'An error occurs when generating htpasswd file:', response.data.errmsg);
});
};
$scope.removeHtpasswd = function () {
$http.delete("api/htpasswd").then(function () {
$scope.addToast('success', 'Fichier htpasswd supprimé avec succès');
}, function (response) {
$scope.addToast('danger', 'An error occurs when deleting htpasswd file:', response.data.errmsg);
});
};
})
.controller("PublicController", function ($scope, $rootScope, $routeParams, $location, Scene, Theme, Teams, Exercice) {
@ -2461,22 +2494,6 @@ angular.module("FICApp")
}
};
$scope.genDexCfg = function () {
$http.post("api/dex.yaml").then(function () {
$http.post("api/dex-password.tpl").then(function () {
$scope.addToast('success', 'Dex config refreshed.', "Don't forget to reload/reboot frontend host.");
}, function (response) {
$scope.addToast('danger', 'An error occurs when generating dex password tpl:', response.data.errmsg);
});
}, function (response) {
$scope.addToast('danger', 'An error occurs when generating dex config:', response.data.errmsg);
});
$http.post("api/vouch-proxy.yaml").then(function () {
$scope.addToast('success', 'VouchProxy config refreshed.', "Don't forget to reload/reboot frontend host.");
}, function (response) {
$scope.addToast('danger', 'An error occurs when generating VouchProxy config:', response.data.errmsg);
});
}
$scope.desactiveTeams = function () {
$http.post("api/disableinactiveteams").then(function () {
$scope.teams = Team.query();