Skip to content

Custom UniFi hotspot portal that integrates with Nexudus Spaces and membership status aware

License

Notifications You must be signed in to change notification settings

kumpul/unifi-nexudus-hotspot

 
 

Repository files navigation

UniFi Hotspot with Nexudus integration

UniFi - Custom portal that integrates with Nexudus Spaces and membership status aware.

This project is an implementation of a external guest portal for Unifi managed networks. The purpose of having an external portal is that you can plug in your own authentication and user database to control access to your network. Read about the concept here and also check out our easy to use API client library for UniFi: @oddbit/unifi

This particular example is using Nexudus Spaces to check for active membership status in a coworking space, as a requirement for being allowed onto the wifi network. Check out the API client library @oddbit/nexudus that we have developed.

Apart from the project's own purpose, it is also an example of how easy it is to adopt an existing Express application to run on Firebase hosting/cloud functions. Apart from the configuration setup, there is no code awareness whether the app is made for running on Firebase or in a Docker container. You can choose whichever works best for you.

N.B.

This fork is being made especially for Firebase hosting and closely tied with Firebase cloud functions to enable management of vouchers.

Hotspot login

Hotspot device requests

Unauthenticated devices that connects to the hotspot will trigger a hotspot login page to be presented. The unifi controller will redirect the device browser to an URL similar to this:

http://hotspot.example.com/guest/s/default/?id=aa:bb:cc:dd:ee:ff&ap=00:11:22:33:44:55&t=1234567890&url=http://connectivitycheck.gstatic.com/generate_204&ssid=our-wifi-hotspot-ssid

There's currenly no graceful handling of bad requests such as 404s or requests that are missing required parameters. This is lazily designed like this since there is no reason for accessing the hotspot portal manually. The UniFi controller will populate the required parameters and make request to the supported endpoints.

But the URL above is still good to have if you are in need for some troubleshooting.

Using Firebase

Travis Build Status

The are a few good benefits of running the Unifi External guest portal on Firebase: CDN, managed SSL certificate and high reliability and it's very easy to set up for automatic configuration and deployment for each new revision of the application. But it requires a roundtrip to an external site, outside of your LAN, in order to log a device in on the guest portal.

This most definitely is an extra configuration step of your Unifi controller. But it is also possible that it takes slightly longer time for the hotspot login page to display. You might also want to think what kind of fallback behavior you want if the WAN connection is cut. With a Firebase hosting it would mean that your hotspot login will also break when there's no Internet connection. Do you need your LAN to work whilst WAN is offline?

Configure Unifi Controller

Under SettingsGuest Control configure the options below:

Guest Policies

  • Custom Portal: 151.101.1.195 or 151.101.65.195
  • Redirection
    • Use secure portal: Check this box
    • Redirect using hostname: <your-project-id>.firebaseapp.com

Access Control

  • Pre-Authorization Access:
    • <your-project-id>.firebaseapp.com

Deploying to Firebase

You'll have to clone and configure your .firebaserc or just set the project

firebase use <your-project-id>
  
firebase functions:config:set unifi.username="myAdminUser"
firebase functions:config:set unifi.password="mySecretPassword"
firebase functions:config:set unifi.host="unifi-controller.example.com"
firebase functions:config:set unifi.port=8443
firebase functions:config:set unifi.use_ssl=true
firebase functions:config:set unifi.is_selfsigned=true
firebase functions:config:set unifi.redirect_url="https://www.yourcompany.example.com"
firebase functions:config:set nexudus.shortname="your-nexudus-space-shortname"

firebase deploy

Configuring Environment variables

These are the environment variables that are avaialable to be set in the application. Some of the variables has a reasonable default value if omitted when running the image. The others, which are recommended or required are described below.

  • nexudus.shortname (required) - The Nexudus space short name for your business, e.g. nexudus as in http://nexudus.spaces.nexudus.com/.
  • unifi.password (required) - Password for the API calls to be authorized with the UniFi controller.
  • unifi.host (required) - IP or hostname of the UniFi controller portal, e.g. unifi.example.com
  • unifi.port - The port on which the UniFi controller is responding to REST/HTTP requests. If you don't know which one it is, you can most likely just omit it and use default (default: 8443)
  • unifi.use_ssl - Whether your UniFi controller portal is setup to use SSL (default: true)
  • unifi.is_selfsigned - Whether your SSL certificate for the UniFi portal is self signed (default: false)
  • unifi.username - Username for the API calls to be authorized with the UniFi controller. It's recommended that you create a dedicated admin user for API calls like this one (default: admin)
  • unifi.redirect_url - URL to redirect the connecting device if none was found in the hotspot connection request (default: https://www.kumpul.co)

About

Custom UniFi hotspot portal that integrates with Nexudus Spaces and membership status aware

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 65.3%
  • HTML 21.0%
  • JavaScript 13.7%