Skip to content
This repository has been archived by the owner on Jul 8, 2023. It is now read-only.

rharish101/fortinet-auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fortinet Firewall Authenticator

This is a script that logs in to a Fortinet firewall, such as one set up for public internet in colleges. The script is written with Python 3.5+ support with NO dependencies, since one cannot access the internet to download Python packages unless one logs in to the Fortinet firewall.

Usage

This script starts a session with the firewall and keeps running in the foreground. To start it, run the script as follows:

./fortinet_auth.py

This will ask you to type your username and password in the terminal. If you want to run this script as part of an automated process, you can specify the username and password as CLI arguments with the --username and --password flags respectively. Then it tries to authenticate with these credentials. If the username and password are incorrect, the script will raise an exception. If there is a connection error, then it waits for some time before retrying.

Once authenticated, the script stays in the foreground and periodically pings the keep-alive URL so that you aren't logged out. You can run this script under tmux or GNU Screen so that you don't have to keep an open SSH session or terminal.

To log out, simply terminate the script using a keyboard interrupt (Ctrl-C), or send a SIGTERM to the process.

For further information about available CLI arguments, run:

./fortinet_auth.py --help

For Contributing

pre-commit is used for managing hooks that run before each commit, to ensure code quality and run some basic tests. Thus, this needs to be set up only when one intends to commit changes to git.

  1. [Optional] Create and activate a virtual environment with Python >= 3.5.

  2. Install pre-commit:

    pip install pre-commit
  3. Install pre-commit hooks:

    pre-commit install

NOTE: You need to be inside the virtual environment where you installed the above dependencies every time you commit. However, this is not required if you have installed pre-commit globally.

Licenses

This repository uses REUSE to document licenses. Each file has a header containing copyright and license information. The license files that are used in this project can be found in the LICENSES directory.

The MIT license is placed in LICENSE, to signify that it constitutes the majority of the codebase, and for compatibility with GitHub.