Coder Social home page Coder Social logo

authq / captive-login Goto Github PK

View Code? Open in Web Editor NEW
27.0 4.0 5.0 45 KB

Captive-portal login utility for headless environments written in pure bash.

License: GNU General Public License v3.0

Makefile 1.36% Shell 97.79% Dockerfile 0.85%
captiveportal captive-portal mikrotik headless login automated amirkabir-university

captive-login's Introduction

CircleCI Docker Automated build Docker Build Status Docker layers

clogin(1) -- captive-portal login utility

SYNOPSIS

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

INSTALL

wget https://raw.githubusercontent.com/authq/captive-login/master/bin/clogin
chmod +x clogin
sudo mv clogin /usr/local/bin

DESCRIPTION

At 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 to clogin.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 to https://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 to http://icanhazip.com)
  • --loop-interval <val> - Set loop interval in seconds (Defaults to 1800 = 30 minutes)
  • -h, --help - Display help message
  • -v, --version - Display version
  • -x, --debug - Debug mode. Shows all internal invoked commands

CONFIG FILE

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=bar

When CONFIG_FILE environment variable or -f, --conf options provided it will be applied after parsing options.

ENVIRONMENT VARIABLES

It is possible to use environment variables instead of arguments to configure clogin.

Supported environment variables:

  • CONFIG_FILE
  • LOG_FILE
  • USERNAME
  • PASSWORD
  • ALLOW_EMPTY
  • HTTP_CLIENT
  • BASE_URL
  • LOGIN_ENDPOINT
  • LOGOUT_ENDPOINT
  • SUCCESS_CODE
  • TEST_URL
  • TEST_SUCCESS_CODE
  • LOOP_INTERVAL

DOCKER IMAGE

An alpine based docker image (~4MB) is available for ease of use and deployment.

docker pull authq/captive-login
docker run -it --rm  -e USERNAME="test" -e PASSWORD="test" authq/clogin loop

DEVELOPMENT

This project uses BATS for automated testing, Dockerfile for packaging and Makefile for development workflow.

Available Makefile commands:

  • make test - Run BATS tests
  • make install - Installs clogin utility to /usr/local/bin
  • make docker-build - Build docker image
  • make docker - Build and test docker image functionality

Feel free forking this repository and making PRs for features and fixes :)

RELATED PROJECTS

  • 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)

LICENSE

Copyright (C) 2018 Pooya Parsa [email protected]

This work is released under the GNU General Public License v3.0. See LICENSE for details.

captive-login's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

captive-login's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.