From 81e88553e5ec00fdf67e3ecd36489412323e9e13 Mon Sep 17 00:00:00 2001 From: steel <mael.acier@ensiie.fr> Date: Sat, 18 Jan 2025 16:12:04 +0100 Subject: [PATCH] feat: enhance HTML structure and navigation in index.html, oauth2.php, and oidc.php for better user experience --- index.html | 52 ++++++++++++++++++++++++++++++++++++++++------------ oauth2.php | 27 ++++++++++++++++++++++----- oidc.php | 17 +++++++++++++++++ 3 files changed, 79 insertions(+), 17 deletions(-) diff --git a/index.html b/index.html index fa64bff..301a679 100644 --- a/index.html +++ b/index.html @@ -1,16 +1,44 @@ <html lang="fr"> + <head> + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1" /> + <meta name="color-scheme" content="light dark" /> + <link + rel="stylesheet" + href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.classless.min.css" + /> + <title>PHP Auth Demo</title> + </head> -<head> - <meta charset="utf-8"> - <meta name="viewport" content="width=device-width, initial-scale=1"> - <meta name="color-scheme" content="light dark"> - <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.classless.min.css"> - <title>PHP Demo</title> -</head> - -<body> + <body> <main> - <a href="oauth2.php"><button>Version OAuth 2</button></a> - <a href="oidc.php"><button>Version OpenID Connect</button></a> + <nav> + <ul> + <li><h2>PHP Auth Demo</h2></li> + </ul> + <ul> + <li> + <a + target="_blank" + href="https://git.iiens.net/arise/ariseid-connect/exemples/php" + > + Code source + </a> + </li> + </ul> + </nav> + <p> + Ce site présente deux exemples d'utilisation d'AriseID Connect + implémentés en PHP sans dépendances. + <hr> + La première version utilise le protocole OAuth 2.0 pour l'autorisation + et récupère les informations de l'utilisateur via l'API d'ARISE. + <br /> + La deuxième version utilise le protocole OpenID Connect pour + l'authentification. + </p> + <a href="oauth2.php"><button>Version OAuth 2</button></a> + <a href="oidc.php"><button>Version OpenID Connect</button></a> </main> -</body> \ No newline at end of file + </body> +</html> diff --git a/oauth2.php b/oauth2.php index 3f17674..3bf261f 100644 --- a/oauth2.php +++ b/oauth2.php @@ -1,19 +1,19 @@ <?php // Remplir ces champs avec les valeurs obtenues sur AriseID Connect -$clientId = 'f97b146f-121a-4400-a79c-7c2ecbbd87f8'; -$clientSecret = 'y6hsryRm6P~QSen~Xs0UtvkEcK'; +$clientId = getenv('AIDC_CLIENT_ID') ?: 'be28aa62-643f-42b4-80ae-902d45f93331'; +$clientSecret = getenv('AIDC_CLIENT_SECRET') ?: 'secret-gimydg6n7ddn6qwen6ypvccmrc4kpccul6l3cmdh4zbym4hwghrq'; -$oauthURLBase = 'http://oidc.127.0.0.1.nip.io:4444'; +$oauthURLBase = getenv('OAUTH_SERVER') ?: 'https://oidc.iiens.net'; // L'URL à laquelle on enverra d'abord l'utilisateur pour obtenir son autorisation $authorizeURL = "{$oauthURLBase}/oauth2/auth"; // Le point d'accès à partir duquel notre serveur demandera un jeton d'accès $tokenURL = "{$oauthURLBase}/oauth2/token"; // L'URL racine à utiliser pour effectuer des demandes d'API authentifiées -$apiURLBase = 'http://api.127.0.0.1.nip.io:5000'; +$apiURLBase = getenv('API_SERVER') ?: 'https://api.iiens.net'; // L'URL de ce script, utilisé comme URL de redirection -$baseURL = 'http://php.127.0.0.1.nip.io:8000/'; +$baseURL = (getenv('DOKKU_PROXY_SSL_PORT') ? 'https://' : 'http://') . $_SERVER['SERVER_NAME'] . ($_SERVER['SERVER_PORT'] != '80' ? ':' . $_SERVER['SERVER_PORT'] : '') . $_SERVER['PHP_SELF']; // On lance une session afin d'avoir un endroit où stocker les données entre les redirections session_start(); @@ -116,6 +116,23 @@ $jsonFlags = JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES <body> <main> + <nav> + <ul> + <li> + <h2>OAuth2 Demo</h2> + </li> + </ul> + <ul> + <li> + <a href="/"> Retour</a> + </li> + <li> + <a target="_blank" href="https://git.iiens.net/arise/ariseid-connect/exemples/php"> + Code source + </a> + </li> + </ul> + </nav> <?php if (empty($_SESSION['access_token'])): ?> <h3>Non connecté</h3> <a href="?action=login"><button>Se connecter</button></a> diff --git a/oidc.php b/oidc.php index 55ed030..a6244d7 100644 --- a/oidc.php +++ b/oidc.php @@ -126,6 +126,23 @@ $jsonFlags = JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES <body> <main> + <nav> + <ul> + <li> + <h2>OpenID Connect Demo</h2> + </li> + </ul> + <ul> + <li> + <a href="/"> Retour</a> + </li> + <li> + <a target="_blank" href="https://git.iiens.net/arise/ariseid-connect/exemples/php"> + Code source + </a> + </li> + </ul> + </nav> <?php if (empty($_SESSION['user_id'])): ?> <h3>Non connecté</h3> <a href="?action=login"><button>Se connecter</button></a> -- GitLab