kaptk2 / portal

Sample UniFi portal in php
93 stars 41 forks source link

$id in the code #2

Closed shabeermothi closed 11 years ago

shabeermothi commented 11 years ago

I have a question. The id which you use in the $data packed as JSON. What does that $id imply. From the code i find it to be the id which is passed to login page. But will any id work with the UniFi controller, dont they require a mac address. Could you please help as to how to use the $id ?

kaptk2 commented 11 years ago

I am not totally sure what you are asking. The $id is generated by the UniFi controller itself. It is set as a session variable for use later. So all this application does is $_GET's the variable out of the URL and then sets it as a session variable for use later. In other words this application doesn't generate it, we get it from UniFi.

shabeermothi commented 11 years ago

But from what i see from the code is that $_GET['id'] is fetched from the request and is then set in session which is then later passed as an argument taken from session to sendAuthorization. Am not sure how would UniFi controller generate an id which is passed in the query string. Maybe am understanding something wrong. Could you please help?

kaptk2 commented 11 years ago

The UniFi software takes care of generating that 'id' string. So when you have "external portal" selected in your unifi guest portal that is what the system gives out if you are a unauthenticated user.

As an example: You have not authticated to the wireless network, you fire up your laptop and try to visit google.com. The unifi system sees that you are not authenticated so hijacks your request and sends it to the external portal server with a long URL that contains all the stuff the external portal server needs to authorize users. The portal server is just in charge of authentication. So once the correct credentials are entered, the portal server sends a message back to the unifi controller letting it know that your id is okay to use the network (aka authorizing your system).

Hope that helps

On Sun, Mar 10, 2013 at 12:19 AM, shabeermothi notifications@github.comwrote:

But from what i see from the code is that $_GET['id'] is fetched from the request and is then set in session which is then later passed as an argument taken from session to sendAuthorization. Am not sure how would UniFi controller generate an id which is passed in the query string. Maybe am understanding something wrong. Could you please help?

— Reply to this email directly or view it on GitHubhttps://github.com/kaptk2/portal/issues/2#issuecomment-14677612 .