Skip to content
Rework wifidog-auth by Laravel
PHP HTML Shell Dockerfile Vue
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci opt: code coverage by codecov. #27 Jun 21, 2019
app
bootstrap opt: upgrade to Laravel 5.8. #17 May 22, 2019
config
database
docker opt: docker May 22, 2019
public opt: npm build files should not in git May 22, 2019
resources new: disable password login and register Jun 26, 2019
routes new: disable password login and register Jun 26, 2019
storage opt: upgrade to Laravel 5.8. #17 May 22, 2019
tests opt: remove useless import Jul 5, 2019
.dockerignore use Docker #15 Oct 24, 2018
.editorconfig upgrate to laravel 5.7. close #12 Oct 19, 2018
.env.example upgrate to laravel 5.6 #/issues/8 Jul 13, 2018
.gitattributes laravel 5.4 new project Oct 16, 2017
.gitignore opt: code coverage by codecov. #27 Jun 21, 2019
.styleci.yml opt: upgrade to Laravel 5.8. #17 May 22, 2019
Dockerfile
LICENSE add Anti 996 License Jun 9, 2019
README.md opt: code coverage by codecov. #27 Jun 21, 2019
artisan upgrate to laravel 5.6 #/issues/8 Jul 13, 2018
composer.json
composer.lock
lint.sh new: use circleci for unit test and lint Oct 16, 2017
package-lock.json build(deps-dev): bump lodash from 4.17.11 to 4.17.13 Jul 14, 2019
package.json build(deps-dev): bump lodash from 4.17.11 to 4.17.13 Jul 14, 2019
phpcs.xml upgrade to laravel 5.6, fix lint. #8 Jul 13, 2018
phpunit.sh opt: improve test coverage Jun 27, 2019
phpunit.xml opt: code coverage by codecov. #27 Jun 21, 2019
server.php laravel 5.4 new project Oct 16, 2017
webpack.mix.js opt: upgrade to Laravel 5.8. #17 May 22, 2019

README.md

Wifidog Auth (Laravel 5.8)

CircleCI Docker Cloud Build Status codecov LICENSE

This project provides a auth server for wifidog. For API details, please see the WiFiDog Protocol V1.

Pages

  • login/
  • portal/
  • messages/ OR gw_message.php

Apis

  • ping/
  • auth/

Getting Started

composer install
cp .env.example .env
sudo chmod 777 bootstrap/cache
sudo chmod -R 777 storage
touch database/database.sqlite
chmod 777 database
chmod 666 database/database.sqlite
php artisan key:generate
php artisan jwt:secret
php artisan migrate
./phpunit.sh

npm install
npm run dev
sudo ln -s `pwd` /var/www/
sudo ln -s `realpath config/apache2/sites-available/laravel.conf` /etc/apache2/sites-available/
sudo a2ensite laravel && sudo service apache2 restart
echo '127.0.0.1 wifidog-auth.lan' | sudo tee -a /etc/hosts
curl 'http://wifidog-auth.lan/ping?gw_id=001217DA42D2&sys_uptime=742725&sys_memfree=2604&sys_load=0.03&wifidog_uptime=3861'
google-chrome http://wifidog-auth.lan/

If you want to use MySQL, change .env like this(don't forget to migrate again):

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=wifidog
DB_USERNAME=root
DB_PASSWORD=1

Docker

docker run --rm \
    --env APP_NAME="Wifidog Auth" \
    --env APP_ENV=local \
    --env APP_KEY=base64:silhtn4zkyodaaDIRSU0QEqq4CwKfjdzLqZectaHIi8= \
    --env JWT_SECRET=EYyXkh0xqc9mdDB93KQVfit0ykyTAknuNlmoPnGkp0cfiFScFMBSy6Prlk0DZdg8 \
    --env DB_CONNECTION=mysql \
    --env DB_HOST=172.17.0.1 \
    --env DB_PORT=3306 \
    --env DB_DATABASE=wifidog \
    --env DB_USERNAME=root \
    --env DB_PASSWORD=1 \
    -it "wifidog/wifidog-auth-laravel"

Wifidog Config

If you want to use local computer as web server and your phone for auth test, you should login into your openwrt router, then add computer IP to /etc/hosts, and change /etc/wifidog.conf.

If your web server IP is 192.168.1.42, mac is 00:00:DE:AD:BE:AF, and your openwrt router IP is 192.168.1.1, operate like this:

ssh root@192.168.1.1
echo "192.168.1.42 wifidog-auth" >> /etc/hosts
/etc/init.d/dnsmasq restart
vi /etc/wifidog.conf
AuthServer {
    Hostname wifidog-auth.lan
    Path /
}
TrustedMACList 00:00:DE:AD:BE:AF
/etc/init.d/wifidog restart
sleep 10
/etc/init.d/wifidog status

Now take out your phone, connect the openwrt wifi, when you try to visit any http website, you will see this login page:

phone screenshot of wifidog auth

After register or login, you can use internet.

Social Login

If you want to use Facebook Login(more providers are here), add these to .env

FACEBOOK_APP_ID=123456
FACEBOOK_APP_SECRET=secret
FACEBOOK_VALID_OAUTH_REDIRECT_URI="http://wifidog-auth.lan/login/facebook/callback"
AUTH_SOCIAL_LOGIN_PROVIDERS="Facebook"

then change ipset of router:

ssh root@192.168.1.1
opkg update
opkg install dnsmasq-full
echo "ipset create facebook hash:ip" >> /etc/firewall.user
echo "ipset=/facebook.com/fbcdn.net/facebook" >> /etc/dnsmasq.conf
fw3 reload
/etc/init.d/dnsmasq restart

Add this to /etc/wifidog.conf

FirewallRuleSet unknown-users {
    FirewallRule allow to-ipset facebook
}

If your router doesn't support ipset, can only add these to /etc/wifidog.conf, but this way can not guarantee the reliability.

FirewallRuleSet global {
    FirewallRule allow tcp to www.facebook.com
    FirewallRule allow tcp to m.facebook.com
    FirewallRule allow tcp to static.xx.fbcdn.net
}
/etc/init.d/wifidog restart

Debug

If you have problems, try these methods:

  1. debug auth server: check the access log and error log, they are usually in /var/log/apache2/
  2. debug wifidog: edit /usr/bin/wifidog-init, change "start" section's "wifidog $OPTIONS" to "wifidog -f -d 9"

Tech

  • PHP Framework: Laravel
  • Coding standard: following PSR-2. run ./lint.sh to check.
  • Unit Test: using PHPUnit. run ./phpunit.sh
You can’t perform that action at this time.