5

I would like to serve a Captive Portal - page that would prompt the user to agree to certain terms before starting browsing the web from my wireless network (through WiFi) using http.server on my Raspberry Pi that runs the newest version of Raspbian.

I have http.server (comes with Python3) up an running and have a webpage portal.html locally on the Pi. This is the page that I want users to be redirected to when they connect to my Pi. Lets say that the local IP of that page is 192.168.1.5:80/portal.html

My thought is that I would then somehow allow their connection when they have connected and accepted the terms and conditions.

How would I go about that?

Clone
  • 3,378
  • 11
  • 25
  • 41

2 Answers2

1

So 'old-style' captive portals (i believe) would just hijack an unencrypted HTTP GET request and force the browser to be redirected to the portal page. While easy, it also demonstrates how crazy insecure HTTP can be.

Now there more secure mechanisms implemented by OS's regarding captive portals. RFC 7710 details the exact mechanism. There are also OS specific requirements, like OS X requires that http://captive.apple.com/hotspotdetect.html is reachable. You will need to implement all of these to redirect to your page.

Community
  • 1
  • 1
Liam Kelly
  • 3,524
  • 1
  • 17
  • 41
  • Could you possibly have materials on implementing captive portals using Django? – sajeyks mwangi Nov 13 '22 at 14:03
  • @sajeyksmwangi captive portal is most often implemented by a proxy like nginx that then redirects to your Django app. You can google to find many examples of this. – Liam Kelly Nov 14 '22 at 15:31
0

You need to work out the document in question, with all the necessary terms and conditions that will link the acceptance of the conditions to a specific user. You can implement a simple login, and link a String (Name - ID) to a Boolean for example, "accepted = true". If you don't need to store the user data, just redirect yo your document and when checked "agree", then you allow the user connection.

mmelotti
  • 336
  • 3
  • 11