Utiliser un portail externe pour l’accès invité
Activez un portail externe si vous souhaitez que les invités accèdent à un portail de connexion que vos développeurs Web ont conçu sur votre propre site Web.
Un portail externe est une page Web que vos utilisateurs WLAN consultent après avoir sélectionné votre SSID. Par exemple, vous pouvez envoyer des invités vers la page d’accueil de votre entreprise ou un portail de connexion que vos développeurs Web ont configuré spécifiquement pour votre organisation.
Pour plus de sécurité, vous pouvez spécifier des utilisateurs autorisés, des sous-réseaux autorisés et des noms d’hôte autorisés. Vous pouvez également entrer une liste de noms d’hôte à bloquer.
- Accédez au WLAN.
Remarque :
-
Si le WLAN se trouve dans un modèle WLAN, sélectionnez Organisation > sans fil | Modèles WLAN, cliquez sur le modèle, puis sur le WLAN.
-
Pour un WLAN au niveau du site, sélectionnez Site > Wireless | WLAN, puis cliquez sur le WLAN.
-
- Dans la fenêtre Modifier le WLAN, sous Portail invité, cliquez sur Transférer vers un portail externe.
- (Facultatif) Cliquez sur le bouton Modifier l’autorisation de l’invité si vous souhaitez limiter l’accès à des utilisateurs spécifiques. Procédez ensuite comme suit :
- Dans la fenêtre Invités autorisés, cliquez sur Ajouter.
- Dans la fenêtre Autoriser l’invité, saisissez l’adresse MAC de l’invité (obligatoire), les informations facultatives de l’utilisateur et la période pendant laquelle l’utilisateur reste autorisé.
Remarque :Vous pouvez utiliser l’option Search Client pour rechercher un client déjà connecté au WLAN.
- Cliquez sur Autoriser en bas de la fenêtre Autoriser l’invité.
- Répétez ces étapes pour ajouter d’autres invités à la liste.
- Dans la fenêtre Invités autorisés, cliquez sur Ajouter.
- Saisissez l’URL du portail, en commençant par http:// ou https://.
Remarque :
Utilisez les autres champs pour affiner l’accès. Par exemple, n’autorisez que certains sous-réseaux ou noms d’hôte.
- Cochez ou décochez la case Ignorer le portail invité/externe en cas d’exception .
Lorsque cette fonctionnalité est sélectionnée, chaque point d’accès tente d’atteindre le portail ou l’IdP, mais s’il n’est pas joignable, l’AP autorise automatiquement les invités à se connecter au WLAN.
- Cliquez sur Enregistrer en bas de la fenêtre Modifier le WLAN.
Utilisez PHP et des fichiers Read-Me pour créer votre portail externe
- Créez votre portail externe en vous référant aux exemples de fichiers PHP et aux informations Read-Me suivantes.
index.php<?php /* These parameters are sent by Mist on the 302 redirect to this portal page: wlan_id - WLAN object's UUID ap_mac - MAC address of the AP client_mac - MAC address of the client device url - Originally requested url by the client, ie: http://www.mist.com ap_name - Name of the AP site_name - Name of the Site If you want to send the guest to a content page after authorization, configure the $url instead of using the valued that is passed as a parameter. */ $wlan_id = $_GET['wlan_id']; $ap_mac = $_GET['ap_mac']; $client_mac = $_GET['client_mac']; $url = $_GET['url']; $ap_name = $_GET['ap_name']; $site_name = $_GET['site_name']; ?> <html> <body> <form action="authme.php" method="post"> <input type="hidden" name="wlan_id" value="<?php echo($wlan_id) ?>" /> <input type="hidden" name="ap_mac" value="<?php echo($ap_mac) ?>" /> <input type="hidden" name="client_mac" value="<?php echo($client_mac) ?>" /> <input type="hidden" name="url" value="<?php echo($url) ?>" /> <input type="hidden" name="ap_name" value="<?php echo($ap_name) ?>" /> <input type="hidden" name="site_name" value="<?php echo($site_name) ?>" /> <table> <tr> <td><b>Your Full Name</b></td> <td><input type="text" name="name" /></td> </tr> <tr> <td><b>Your Email Address</b></td> <td><input type="text" name="email" /></td> </tr> <tr> <td><input type="submit" value="Login" /></td> </tr> </table> </form> </body> </html>
authme.php<?php $secret = ''; // WLAN API Key, obtained from the Mist Web GUI after creating the WLAN $wlan_id = $_POST['wlan_id']; $ap_mac = $_POST['ap_mac']; $client_mac = $_POST['client_mac']; $url = $_POST['url']; $ap_name = $_POST['ap_name']; $site_name = $_POST['site_name']; $authorize_min = 525600; // Duration (in minutes) the guest MAC address is authorized before they are redirected back to the portal page) $context = sprintf('%s/%s/%s/%d/%d/%d/%d', $wlan_id, $ap_mac, $client_mac, $authorize_min, ); $token = urlencode(base64_encode($context)); // The below portal fields are passed back to Mist and shown in the Guest Portal Information $name = $_POST['name']; $email = $_POST['email']; $field1 = 'Whatever you want Custom field 1 to be'; $field2 = 'Whatever you want Custom field 2 to be'; $field3 = 'Whatever you want Custom field 3 to be'; $field4 = 'Whatever you want Custom field 4 to be'; $forward = urlencode($url); // URL the user is forwarded to after authorization $extra = '&forward=' . $forward; $extra .= '&name=' . urlencode("$name"); $extra .= '&field1=' . urlencode("$field1"); $extra .= '&field2=' . urlencode("$field2"); $extra .= '&field3=' . urlencode("$field3"); $extra .= '&field4=' . urlencode("$field4"); $extra .= '&email=' . urlencode("$email"); $expires = time() + 120; // The time until which the authorization URL is valid $payload = sprintf('expires=%d&token=%s%s', $expires, $token, $extra); $signature = urlencode(base64_encode(hash_hmac('sha1', $payload, $secret, true))); $final_url = sprintf('http://portal.mist.com/authorize?signature=%s&%s', $signature, $payload); /* Debug code used for testing purposes only If set to true, display the variable details without authorizing the guest in the Mist cloud */ $debugging = false; if ($debugging) { header('Content-Type: text/plain'); echo sprintf('token : urlencode(base64(%s))', $context) . PHP_EOL; echo sprintf(' %s', $token) . PHP_EOL; echo sprintf('foward : %s', $url) . PHP_EOL; echo sprintf(' %s', $foward) . PHP_EOL; echo sprintf('payload-to-sign: %s', $payload) . PHP_EOL; echo sprintf('signature : %s', $signature) . PHP_EOL; echo sprintf('URL : %s', $final_url) . PHP_EOL; echo sprintf('client_mac : %s', $client_mac) . PHP_EOL; echo sprintf('ap_mac : %s', $ap_mac) . PHP_EOL; echo sprintf('ap_name : %s', $ap_name) . PHP_EOL; echo sprintf('wlan_id : %s', $wlan_id) . PHP_EOL; echo sprintf('site_name : %s', $site_name) . PHP_EOL; echo sprintf('name : %s', $name) . PHP_EOL; echo sprintf('email : %s', $email) . PHP_EOL; echo sprintf('field1 : %s', $field1) . PHP_EOL; echo sprintf('field2 : %s', $field2) . PHP_EOL; echo sprintf('field3 : %s', $field3) . PHP_EOL; echo sprintf('field4 : %s', $field4) . PHP_EOL; } else { // Guest is redirected to the Mist portal for authorization. If successful, the Mist portal will then redirect the guest to the $url header('Location: ' . $final_url); } ?>Informations Read-MeThis sample code shows how to use the PHP POST method to pass the below parameter values from the landing page (index.php) to the authorization page (authme.php). The authorization page will also request the user to provide some information. Authorization HOW-TOs ===================== Syntax: signature=<signature>&expires=<epoch-seconds>&token=<token>&forward=<forward> Note: Wired captive portal does not support this mechanism, please use the JWT based one. <forward>: url to forward the user to after authorization <token>: base64("wlan-id/ap-mac/client-mac/authorize_min/0/0/0") <signature>: base64(hmac_sha1(<secret>, "expires=...")) Example token : urlencode(base64("be22bba7-8e22-e1cf-5185-b880816fe2cf/5c5b35001234/d58f6bb4c9d8/480/0/0/0")) = YmUyMmJiYTctOGUyMi1lMWNmLTUxODUtYjg4MDgxNmZlMmNmLzVjNWIzNTAwMTIzNC9kNThmNmJiNGM5ZDgvNDgwLzAvMC8w expires : 1768587994 forward : urlencode("http://www.mist.com") http%3A%2F%2Fwww.mist.com%2F payload-to-sign: expires=1768587994&token=YmUyMmJiYTctOGUyMi1lMWNmLTUxODUtYjg4MDgxNmZlMmNmLzVjNWIzNTAwMTIzNC9kNThmNmJiNGM5ZDgvNDgwLzAvMC8w&forward=http%3A%2F%2Fwww.mist.com%2F secret : test-secret (only used by /authorize-test for testing purpose) signature : J7VJlf2Zlcs%2BOxhVxCf8hL0XYC0%3D final URL : http://portal.mist.com/authorize-test?signature=J7VJlf2Zlcs%2BOxhVxCf8hL0XYC0%3D&expires=1768587994&token=YmUyMmJiYTctOGUyMi1lMWNmLTUxODUtYjg4MDgxNmZlMmNmLzVjNWIzNTAwMTIzNC9kNThmNmJiNGM5ZDgvNDgwLzAvMC8w&forward=http%3A%2F%2Fwww.mist.com%2F Alternatively, you can use JWT tokens: Syntax: jwt=<jwt token> Payload: { "ap_mac": "5c5b35001234", "wlan_id": "be22bba7-8e22-e1cf-5185-b880816fe2cf", "client_mac": "d58f6bb4c9d8", "minutes": 480, "expires": 1768587994, "forward": "http://www.mist.com", "authorize_only": false } Notes: authorize_only: if true and authorization is successful, 200 OK will be returned instead of 302 Redirect the user to the `forward` URL Example ``` import jwt secret = "test-secret" payload = { "ap_mac": "5c5b35001234", "wlan_id": "be22bba7-8e22-e1cf-5185-b880816fe2cf", # only for _wireless_ captive portal "site_id": "ce22bba7-8e22-e1cf-5185-b880816fe2ce", # only for _wired_ captive portal" "port_name": "eth0", # only for _wired_ captive portal" "client_mac": "d58f6bb4c9d8", "minutes": 480, "expires": 1768587994, "forward": "http://www.mist.com", "authorize_only": False } encoded_jwt = jwt.encode(payload, secret, algorithm='HS256') ``` encoded_jwt: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdXRob3JpemVfb25seSI6ZmFsc2UsImV4cGlyZXMiOjE3Njg1ODc5OTQsImFwX21hYyI6IjVjNWIzNTAwMTIzNCIsImZvcndhcmQiOiJodHRwOi8vd3d3Lm1pc3QuY29tIiwiY2xpZW50X21hYyI6ImQ1OGY2YmI0YzlkOCIsIm1pbnV0ZXMiOjQ4MCwid2xhbl9pZCI6ImJlMjJiYmE3LThlMjItZTFjZi01MTg1LWI4ODA4MTZmZTJjZiJ9.msBloHe05XzbzaMEqjsi8XSNWa_3uc--4wucKz3dQGk final URL : http://portal.mist.com/authorize-test?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdXRob3JpemVfb25seSI6ZmFsc2UsImV4cGlyZXMiOjE3Njg1ODc5OTQsImFwX21hYyI6IjVjNWIzNTAwMTIzNCIsImZvcndhcmQiOiJodHRwOi8vd3d3Lm1pc3QuY29tIiwiY2xpZW50X21hYyI6ImQ1OGY2YmI0YzlkOCIsIm1pbnV0ZXMiOjQ4MCwid2xhbl9pZCI6ImJlMjJiYmE3LThlMjItZTFjZi01MTg1LWI4ODA4MTZmZTJjZiJ9.msBloHe05XzbzaMEqjsi8XSNWa_3uc--4wucKz3dQGkRemarque :Remplacez
portal.mist.compar l’URL du portail Wi-Fi invité appropriée en fonction de l’instance cloud dans laquelle votre organisation Mist a été créée. Pour rechercher l’URL du portail Wi-Fi invité de votre région, consultez les informations sur les adresses IP et les ports de Mist Cloud dans le Guide de gestion de Juniper Mist. - Pour obtenir la valeur dont vous avez besoin
$secretdans auth.php, rouvrez la fenêtre Modifier WLAN et copiez la clé secrète de l’API. - Configurez votre page d’autorisation (authme.php) pour appeler le backend Mist Juniper avec les paramètres de chaîne de requête requis :
?signature=signature&expires=expires&token=token&optional-
expires : horodatage d’époque jusqu’à laquelle l’URL d’autorisation est valide.
-
Par exemple : 1768587994 (Cela signifie que l’URL d’autorisation expirerait le 16 janvier 2026 à 18:26:34 UTC.)
-
-
token – Une chaîne base64 ayant le format : wlan_id/ap_mac/client_mac/authorize_min/0/0/0
-
Par exemple : be22bba7-8e22-e1cf-5185-b880816fe2cf/5c5b35001234/d58f6bb4c9d8/480/0/0/0
-
-
signature – Chaîne Base64 de valeurs hachées, utilisant sha1 comme algorithme de hachage et le secret API du WLAN invité comme clé. Cela aurait le format suivant : expires=expires&token=token&optional
-
Par exemple : J7VJlf2Zlcs %2BOxhVxCf8hL0XYC0%3D
-
-
facultatif – Les détails de l’invité facultatif et l’URL vers laquelle l’utilisateur est redirigé après l’autorisation, au format suivant : forward=url&name=name&email=email&company=company&field1=field1&field2=field2&field3=field3&field4=field4
Remarque : Assurez-vous que toutes les valeurs de paramètre sont transmises en base64.
-
Par exemple : forward=http%3A%2F%2Fwww.mist.com %2F
-
-
- Configurez votre page d’autorisation pour appeler Juniper Mist pour obtenir l’autorisation d’invité. L’URL d’autorisation finale ressemblerait à ceci :
http://portal.mist.com/authorize?signature=J7VJlf2Zlcs%2BOxhVxCf8hL0XYC0%3D&expires=1768587994&token=YmUyMmJiYTctOGUyMi1lMWNmLTUxODUtYjg4MDgxNmZlMmNmLzVjNWIzNTAwMTIzNC9kNThmNmJiNGM5ZDgvNDgwLzAvMC8w&forward=http%3A%2F%2Fwww.mist.com%2F - Testez le portail captif externe en connectant un appareil et en tentant de vous authentifier.
L’appareil doit être redirigé vers le portail Juniper Mist pour autorisation. Si l’authentification réussit, l’utilisateur sera redirigé vers l’URL telle que définie dans le code de votre portail captif externe.
Remarque :Utilisez-le
/authorizepour le portail en ligne. À des fins de test, vous pouvez utiliser/authorize-test, ce qui nécessite les valeurs d’exemple fictives fournies dans les informations de lecture.