Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    1 User Per Voucher Code

    Scheduled Pinned Locked Moved Captive Portal
    13 Posts 5 Posters 4.2k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      MohamedMagdi
      last edited by

      Thanks for answering Derelict, Yes i have checked this option and the same problem any other solution ?

      1 Reply Last reply Reply Quote 0
      • S
        sebastiannielsen
        last edited by

        Try my solution in this thread:
        https://forum.pfsense.org/index.php?topic=107309.0

        Im unsure if it works, but it looks like it should work.

        If it don't work, set up a custom authentication page that will, in addition to allowing the user in, also mark the voucher as "spent".

        1 Reply Last reply Reply Quote 0
        • DerelictD
          Derelict LAYER 8 Netgate
          last edited by

          It works.

          Chattanooga, Tennessee, USA
          A comprehensive network diagram is worth 10,000 words and 15 conference calls.
          DO NOT set a source address/port in a port forward or firewall rule unless you KNOW you need it!
          Do Not Chat For Help! NO_WAN_EGRESS(TM)

          1 Reply Last reply Reply Quote 0
          • M
            MohamedMagdi
            last edited by

            Thanks sebastiannielsen, but this solution wont let me change the voucher time so all vouchers will be expired after "Hard timeout" period i just wanted to make vouchers with various amount of times
            so isn't there any other solution ??

            1 Reply Last reply Reply Quote 0
            • M
              MohamedMagdi
              last edited by

              i found this solution but idk how to apply it
              https://forum.pfsense.org/index.php?topic=43100.0

              1 Reply Last reply Reply Quote 0
              • GertjanG
                Gertjan
                last edited by

                @MohamedMagdi:

                i found this solution but idk how to apply it
                https://forum.pfsense.org/index.php?topic=43100.0

                So, found an old using solution that worked for an ancient pfSense version, instead of the proposed -recent- one ….
                Why ? What is the logic ?

                No "help me" PM's please. Use the forum, the community will thank you.
                Edit : and where are the logs ??

                S 1 Reply Last reply Reply Quote 0
                • S
                  sebastiannielsen
                  last edited by

                  Then its only one solution left:
                  Recode the voucher login page to "spend" each voucher code after use.

                  To do this, create a login page, that will submit the voucher code to lets say captiveportal-spend.php
                  on "File manager", create a script captiveportal-spend.php, that will check against a list of valid voucher codes, and then delete the voucher code from that list. This could be as simple as a list of sha256 hashes of valid voucher codes in the webroot of captive portal, and the script simply deletes the hash of each voucher code when it finds a valid one.
                  When the script finds a valid hash, it will output a javascript form, that will autosubmit to the $PORTAL_ACTION$ url.

                  To increase security, you could have 2 sets of 64 bit keypairs, where you will generate 2 sets of vouchers containing the exact same numbers, just different keys.
                  So in the script captiveportal-spend.php, check against the sha256 hashes in file, and if a match is found, voucher is deleted from that file, then you decrypt the voucher using the first public key, and then you encrypt, but now with the private key found in the voucher settings, and create a autosubmit form for this.

                  Eg, in the captive portal settings for vouchers, you have keypair B set up.
                  So on the receipt, you print the voucher like "V78E2Q", that is created using the private key of pair A.
                  Then user enter it on login page.
                  Gets sent to captiveporta-spend.php. captiveportal-spend.php checks in sha256 file if voucher exist. If yes, then delete the hash and continue. If no, display error message that voucher has been spent.
                  captiveportal-spend.php DECRYPT voucher using public key of pair A, rendering a magic number + ticket ID + roll ID and checksum. Then captiveportal-spend.php ENCRYPT using the private key of pair B.
                  Then it creates a autosubmit page to the real $PORTAL_ACTION$ containing this voucher code.

                  Of course, this is not rock solid security, as anyone that would listen in the communication, eg with a client-side listening software, or with web developer tools not following redirects, could capture the final form and use the final "multiple-use-code". But such a techny-savy user could hack the system in other ways like spoofing mac/ip or even use internet sharing and such.

                  But this would atleast make it significantly harder to use the same voucher code for multiple devices.

                  1 Reply Last reply Reply Quote 0
                  • GertjanG
                    Gertjan
                    last edited by

                    @sebastiannielsen:

                    ….
                    Of course, this is not rock solid security, as anyone that would listen in the communication, eg with a client-side listening software, or with web developer tools not following redirects, could capture the final form and use the final "multiple-use-code". But such a techny-savy user could hack the system in other ways like spoofing mac/ip or even use internet sharing and such.

                    To lower this risque, activate https option for the captive portal (you'll be needing domain name - and a free, but valid and recognized certificate from startssl.com (or others))

                    No "help me" PM's please. Use the forum, the community will thank you.
                    Edit : and where are the logs ??

                    1 Reply Last reply Reply Quote 0
                    • S
                      sebastiannielsen
                      last edited by

                      Gertjan: As I said, the listening is then done on client side, so HTTPS would not harden it so much, since the user could use wget or any other HTTPS capable client to do the authentication.

                      But to further even increase security, you could use a captcha and even javascript code that will ensure a real functioning browser, along with HTTPS. Then it will be a tough nut to crack.

                      1 Reply Last reply Reply Quote 0
                      • S
                        sanctify @Gertjan
                        last edited by

                        @gertjan how do you upload or install this patch on the Pfsense that's these "1 User Per Voucher Code"?

                        GertjanG 1 Reply Last reply Reply Quote 0
                        • GertjanG
                          Gertjan @sanctify
                          last edited by

                          @sanctify said in 1 User Per Voucher Code:

                          @gertjan how do you upload or install this patch on the Pfsense that's these "1 User Per Voucher Code"?

                          That question was valid in 2016, that's 5 years ago.

                          These days, you select :

                          1a3997c6-e867-4d97-b29f-6a38cc9bd176-image.png

                          No "help me" PM's please. Use the forum, the community will thank you.
                          Edit : and where are the logs ??

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post
                          Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.