Usage: clogin login|logout|loop|test [--help] [OPTION...]
Login:
clogin login -u test -p test
Test connectivity:
clogin test
Continuesly check login state:
clogin loop -u test -p test
Logout:
clogin logout
wget https://raw.githubusercontent.com/authq/captive-login/master/bin/clogin
chmod +x clogin
sudo mv clogin /usr/local/binAt Amirkabir university, we have mikrotik powered captive-portal for internet access. This makes some challenges when a persistent internet connection is needed in headless devices and lab servers.
This utility automates captive-portal login proccess. I've tried to generalize all params as possible so it can be used in similar environments, at least with other mikrotik captive-portals.
Behind the scenes, login process is achived by sending a HTTPS POST request to /login endpoint of captive-portal containing username and password fields in body. Logout is done by sending a GET request to /logout endpoint.
Both success if HTTP response code is 302 (Mikrotik spec).
The connectivity test successes when GET requst to test url is 200.
For detailed info of how this script works, see bin/clogin.
Supported options:
-f, --conf- Path to config file (Defaults toclogin.conf)-l, --log-file <val>- Set log file (Defaults to/dev/stderr)-u, --username <val>- Set login username-p, --password <val>- Set login password--allow-empty- Allow using empty username and password-c, --client <val>- Set http client to make requests. (Possible values:auto|curl|wget)--base <val>- Set http client base url (Defauts tohttps://login.aut.ac.ir)--login-endpoint <val>- Set login endpoint (Defaults to/login)--logout-endpoint <val>- Set logout endpoint (Defaults to/logout)--test-url <val>- Set connectivity test url (Default tohttp://icanhazip.com)--loop-interval <val>- Set loop interval in seconds (Defaults to1800=30 minutes)-h, --help- Display help message-v, --version- Display version-x, --debug- Debug mode. Shows all internal invoked commands
Config files at the paths of /usr/local/etc/clogin.conf, /etc/clogin.conf and ~/.clogin.conf will be applied if readable in order before parsing options. For a complete example see etc/clogin.conf.
USERNAME=foo
PASSWORD=barWhen CONFIG_FILE environment variable or -f, --conf options provided it will be applied after parsing options.
It is possible to use environment variables instead of arguments to configure clogin.
Supported environment variables:
CONFIG_FILELOG_FILEUSERNAMEPASSWORDALLOW_EMPTYHTTP_CLIENTBASE_URLLOGIN_ENDPOINTLOGOUT_ENDPOINTSUCCESS_CODETEST_URLTEST_SUCCESS_CODELOOP_INTERVAL
An alpine based docker image (~4MB) is available for ease of use and deployment.
docker pull authq/captive-logindocker run -it --rm -e USERNAME="test" -e PASSWORD="test" authq/clogin loopThis project uses BATS for automated testing, Dockerfile for packaging and Makefile for development workflow.
Available Makefile commands:
make test- Run BATS testsmake install- Installscloginutility to/usr/local/binmake docker-build- Build docker imagemake docker- Build and test docker image functionality
Feel free forking this repository and making PRs for features and fixes :)
- Reyhoon Hotspot Login - A simple http client written in go to log us in with less pain and effort.
- Mili - Mili is an open source tool for auto login hotspot pages! (MacOS + Linux)
Copyright (C) 2018 Pooya Parsa pooya@pi0.ir
This work is released under the GNU General Public License v3.0. See LICENSE for details.