From 5381e56a3f153414b08f4e42a5cee88c3f6a71ad Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Sat, 9 Jul 2022 20:16:15 +0200 Subject: [PATCH] Initial version --- .gitignore | 3 + README.md | 36 ++++ app.js | 178 +++++++++++++++++++ index.php | 416 ++++++++++++++++++++++++++++++++++++++++++++ jquery-3.6.0.min.js | 2 + logs/.gitignore | 2 + 6 files changed, 637 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 app.js create mode 100644 index.php create mode 100644 jquery-3.6.0.min.js create mode 100644 logs/.gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e3fa8e6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*~ +.*.swp +*.log diff --git a/README.md b/README.md new file mode 100644 index 0000000..438ea1f --- /dev/null +++ b/README.md @@ -0,0 +1,36 @@ +# Single page test CAS Client + +This single page application acting as CAS Client. + +Features : + * Login/Logout on CAS server + * Local logout + * Show authenticated user's informations (login and attributes) + * Show complete debug log of phpCAS library + +## Requirements + + * phpCAS library (from php-cas Debian package for instance) + * CURL and Dom PHP modules (from php-curl and php-dom Debian packages for instance) + * Apache PHP support (using _mod_php_ or _PHP Fpm_, install _libapache2-mod-php_ Debian packages for instance) + * One directory writable by Apache user for logging + +## Installation + + * Install the application and its requirements +``` +apt install -y libapache2-mod-php php-cas php-curl php-dom git +mkdir -p /var/www/connexion/public_html +git clone https://gogs.zionetrix.net/bn8/test-cas-client-sp.git /var/www/connexion/test-cas-client-sp +ln -s /var/www/connexion/test-cas-client-sp /var/www/connexion/public_html/test-sp +chown www-data: /var/www/connexion/test-cas-client-sp/logs +``` + + * Configure access to the application, for instance, in an existing Apache _VirtualHost_ definition by adding something like: +``` +Alias /test-sp /var/www/connexion/public_html/test-sp +ProxyPass /test-sp ! + + Require all granted + +``` diff --git a/app.js b/app.js new file mode 100644 index 0000000..a19d090 --- /dev/null +++ b/app.js @@ -0,0 +1,178 @@ +$(document).ready( function() { + // Lookup for UI components + var cas_server_selection = $('#cas_server_selection'); + var select_server = $('#select_server'); + + var div_cas_config = $('#cas_config'); + var ul_cas_config = div_cas_config.find('ul').first(); + + var div_user_info = $('#user_info'); + var div_warnings = $('#warnings'); + + var div_cas_logs = $('#cas_logs'); + var pre_cas_logs = div_cas_logs.find('pre').first(); + + var login_btn = $('#login_btn'); + var caslogout_btn = $('#caslogout_btn'); + var locallogout_btn = $('#locallogout_btn'); + var truncatelog_btn = $('#truncatelog_btn'); + + // Configure CAS servers selection (from API return) + var configure_cas_server_selection = function(cas_servers, selected) { + select_server.html(''); + if (!cas_servers || Object.keys(cas_servers).length <= 1) { + cas_server_selection.css('display', 'none'); + return true; + } + for (var cas_host in cas_servers) { + var option = $(''); + if (cas_host == selected) + option.attr('selected', 'selected'); + select_server.append(option); + } + cas_server_selection.css('display', 'block'); + }; + + // Show CAS configuration (from API return) + var show_cas_config = function(cas_config) { + ul_cas_config.html(''); + if (!cas_config) { + div_cas_config.css('display', 'none'); + return true; + } + for (var key in cas_config) { + var li = $('
  • '+key+': '+cas_config[key]+'
  • '); + ul_cas_config.append(li); + } + div_cas_config.css('display', 'block'); + }; + + // Show warning messages (from API return) + var show_warnings = function(warnings) { + div_warnings.html('

    Warning messages

    '); + if (!warnings.length) { + div_warnings.css('display', 'none'); + return true; + } + var ul = $('