Source code template for External Web Portal (Controller 3.1.4 or above)

This thread has been locked for further replies. You can start a new thread to share your ideas or ask questions.

Source code template for External Web Portal (Controller 3.1.4 or above)

This thread has been locked for further replies. You can start a new thread to share your ideas or ask questions.
Source code template for External Web Portal (Controller 3.1.4 or above)
Source code template for External Web Portal (Controller 3.1.4 or above)
2019-03-08 09:40:23 - last edited 2020-11-27 12:48:53

This document outlines the requirements when establishing an external web portal server. In Omada Controller, External Web Portal can only be used when the portal authentication type is External Radius Server.

 

The below picture depicts the workflow among the wireless client, EAP, Omada Controller, External Web Portal and the Radius Server. It will help you better understand the requirements of establishing an External Web Portal server. (Note: The portal API of Omada Controller has changed in Omada Controller 3.1.4, if you have upgraded the Omada Controller 3.1.4 from older version Omada Controller, you may need to update your External Web Portal.)

 

                   

  1. Wireless client is connected to the SSID of the wireless network and try to access the internet. EAP device intercepts client’s HTTP request and then redirects it to the Omada Controller. (Step 1 and Step 2)
  2. The Omada Controller then redirects the client’s request to the external portal page by replying a HTTP response with status code 302 Found to the client. (Step 3 and Step 4)
  3. Client sends HTTP GET request to external web portal with parameter “?target=target_controller_ip&targetPort=target_controller_port&clientMac=client_mac&clientIp=client_ip&raidusServerIp=radius_server_ip&ap=ap_mac&ssid=ssid&radioId=radio_id(0 for 2.4G radio, 1 for 5G radio)&redirectUrl=redirecturl(if you did not set the redirect URL after wireless clients passing the portal authentication, the default redirect URL depends on the wireless clients)   ”. for example, “http://172.30.30.113?target=172.30.30.113&targetPort=8088&clientMac=F8-1E-DF-AA-AA-AA&clientIP=172.30.30.103&raidusServerIp=172.30.30.120&ap=AC-84-C6-BB-BB-BB&ssid=eap_test&radioId=1&redirectUrl=https%3A%2F%2F www.tp-link.com (Step 5)
  4. External web portal server should be able to get the value of the clientMac, clientIp, ap, ssid, radioId, redirectUrlparameters. Then external web portal server should return a page with a form. This form will collect the information of username, password, clientMac, clientIp, ap, ssid, radioId, redirectUrl

 

For example:

 

<form id="form">

    <div><span>username:</span><input type="text" id="username" name="username"/> </div>

 

    <div><span>password:</span><input type="password" id="password" name="password"/></div>

 

    <div style="display:none"><input type="text" id="clientMac" name="clientMac" /></div>

          <div style="display:none"><input name="clientIp" id="clientIp"/></div>

          <div style="display:none"><input name="ap" id="ap"/></div>

          <div style="display:none"><input name="ssid" id="ssid"/></div>

          <div style="display:none"><input name="radioId" id="radioId"/></div>

          <div style="display:none"><input name="redirectUrl" id="redirectUrl"/></div>

          <button type="submit">submit</button>

</form>

 

Please note that the “id” of these elements in your form should be the same as this example. The method to get the value of “username” and “password” can be defined by yourself, but the value of “clientMac”, “clientIp”, “ap”, “ssid”, “radioId”, “redirectUrl” must be obtained from the Http Request’s URL.

(Step 6)

 

5. The form should be POST  to http://target_controller_ip:targetport/portal/radius/auth after submit. (Step7)

6. Omada Controller communicates with radius server to verify the username and password. (Step 8 and Step 9)

7. If the authentication is passed, i.e., Access-Accept is received from radius server, Omada Controller will redirect a built-in success page or a predefined webpage according to the configuration to clients. (Step 10)

 

The below html template is a simple demo for you to develop your External Web Portal working with Omada Controller:

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

<div id="errorHint" style="color:red"></div>

<form id="form">

    <div><span>username:</span><input type="text" id="username" name="username"/> </div>

 

    <div><span>password:</span><input type="password" id="password" name="password"/></div>

 

    <div style="display:none"><input type="text" id="clientMac" name="clientMac" /></div>

          <div style="display:none"><input name="clientIp" id="clientIp"/></div>

          <div style="display:none"><input name="ap" id="ap"/></div>

          <div style="display:none"><input name="ssid" id="ssid"/></div>

          <div style="display:none"><input name="radioId" id="radioId"/></div>

          <div style="display:none"><input name="redirectUrl" id="redirectUrl"/></div>

          <button type="submit">submit</button>

</form>

 

 

 

<script type="text/javascript">

var errorHint = getQueryString("errorHint")

if (errorHint != null){

          document.getElementById("errorHint").innerHTML = errorHint.replace(new RegExp('\\+', 'g'), ' ');

}

var submitUrl = "http://" + getQueryString("target") + ":" + getQueryString("targetPort") + "/portal/radius/auth";

document.getElementById("form").action = submitUrl;

 

document.getElementById("clientMac").value = getQueryString("clientMac");

document.getElementById("clientIp").value = getQueryString("clientIp");

document.getElementById("ap").value = getQueryString("ap");

document.getElementById("ssid").value = getQueryString("ssid");

document.getElementById("radioId").value = getQueryString("radioId");

document.getElementById("redirectUrl").value = getQueryString("redirectUrl");

 

function getQueryString(name) {

 

    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");

 

    var r = window.location.search.substr(1).match(reg);

 

    if (r != null) return unescape(r[2]); return null;

 

}

 

</script>

  2      
  2      
#1
Options
10 Reply
Re:Re:Source code template for External Web Portal (Controller 3.1.4 or above)
2019-03-12 01:19:14

Half wrote

I have a question, the user name parameter, does the portal verify it? Since it is not specified in the configuration of the portal. I am having many problems with this installation, if someone can help me I would appreciate it.

 

Hi,

 

The username and password will be forwarded to the RADIUS server, and it is the RADIUS server verifies the username/password parameter. You can use the RADIUS server, such as FreeRADIUS to finish the authentication.

  2  
  2  
#3
Options
Re:Source code template for External Web Portal (Controller 3.1.4 or above)
2019-03-12 17:45:35

Where is the Linux_64 version? I see Windows only for now

  0  
  0  
#4
Options
Re:Re:Source code template for External Web Portal (Controller 3.1.4 or above)
2019-03-13 01:33:23 - last edited 2019-03-13 01:33:36

pixielark wrote

Where is the Linux_64 version? I see Windows only for now

 

Hi bro,

 

The Linux version of Controller 3.1.4 is under testing. It will be published later.

  3  
  3  
#5
Options
Re:Source code template for External Web Portal (Controller 3.1.4 or above)
2019-09-02 15:12:03

hello, how can i config external portal without require username/password authenticate. in my case i only need my guest see my welcome page first and click a button on web page.

 

thank you!

  0  
  0  
#10
Options
Re:Re:Source code template for External Web Portal (Controller 3.1.4 or above)
2019-09-03 01:25:22

sonhp wrote

hello, how can i config external portal without require username/password authenticate. in my case i only need my guest see my welcome page first and click a button on web page.

 

thank you!

 

For this demand, you can just use the "no authentication" function in Controller, no need to use the external portal server.

  0  
  0  
#11
Options
Re:Re:Re:Source code template for External Web Portal (Controller 3.1.4 or above)
2019-09-03 01:31:20

jonas wrote

sonhp wrote

hello, how can i config external portal without require username/password authenticate. in my case i only need my guest see my welcome page first and click a button on web page.

 

thank you!

 

For this demand, you can just use the "no authentication" function in Controller, no need to use the external portal server.

 

i already try to use built-in "no authentication" function, but this function has very limited on portal layout customization. is there are any way to do with external web portal?

 

thank you!

  0  
  0  
#12
Options
Re:Re:Re:Re:Source code template for External Web Portal (Controller 3.1.4 or above)
2019-09-06 09:39:35

i already try to use built-in "no authentication" function, but this function has very limited on portal layout customization. is there are any way to do with external web portal?thank you!

 

 

You can use External portal server of Omada Controller. You can custom your own authentication page, no need to use RADIUS server.

 

You can refer to the FAQ: https://www.tp-link.com/en/support/faq/2274/

  0  
  0  
#16
Options
Re:Source code template for External Web Portal (Controller 3.1.4 or above)
2019-12-25 13:58:59

@jonas 

 

Hi 

Can you please provide me a solution for this error?

  0  
  0  
#46
Options
Re:Re:Re:Re:Source code template for External Web Portal (Controller 3.1.4 or above)
2019-12-27 13:26:19

@Mycompanywala Any Sample code for that?

  0  
  0  
#50
Options
Re:Source code template for External Web Portal (Controller 3.1.4 or above)
2020-01-13 11:33:08 - last edited 2020-01-22 08:01:24

Hi @jonas,  

 

I try this configuration and send authentication to http://targetip:targetport/portal/radius/auth I get a error server error. Attached file is the error.

  0  
  0  
#55
Options

Information

Helpful: 2

Views: 17915

Replies: 10

Related Articles