NetBox plugin to generate API token for a user
Project description
netbox-api-token-generator
A Django Netbox plugin to expose API token generation API using basic authorization header
This Django Netbox plugin will expose a REST API
GET /api/plugins/token/token
with following required header parameters
Authorization: Basic <base64>
: TheAuthorization
header will be base64 ofusername:password
stringZ-Expires: yyyy-MM-dd
: TheX-Expires
is use to provide expiry for the token
Installation and configuration
This instruction only describes how to install this plugin into Docker-compose instance of NetBox.
General installation steps and considerations follow the official guidelines. The plugin is available as a Python package from PyPi or from GitHub.
0. Pull NetBox docker-compose version from GitHub
mkdir ~/netbox && cd "$_"
git clone https://github.com/netbox-community/netbox-docker
1. Create new docker container based on latest netbox image
cd ~/netbox
git clone https://github.com/agrawald/netbox-api-token-generator
cd netbox-api-token-generator
sudo docker build -t netbox-myplugins .
What's in the Dockerfile:
FROM netboxcommunity/netbox:latest COPY ./netbox_api_token_generator /opt/netbox/netbox/netbox_api_token_generator
2. Change netbox service in docker-compose.yml (do not delete, just add new lines and change image name)
version: '3.4'
services:
netbox: &netbox
# Change image name to netbox-myplugins (old name is netboxcommunity/netbox:${VERSION-latest})
image: netbox-myplugins
...
ports:
- 8080:8080
3. Update the PLUGINS parameter in the global Netbox configuration.py config file in netbox-docker/configuration directory
PLUGINS = [
"netbox_api_token_generator"
]
4. Start Docker-compose
$ cd ~/netbox/netbox-docker/
sudo docker-compose up -d
Usage
You can use either postman or a simple curl as shown below to generate an API token
curl --request GET 'http://NETBOX_IP:8080/api/plugins/token/token' --header 'Authorization: Basic BASE64' --header 'X-Expires: 2021-12-31'
Response will be a JSON as shown below
{ "token": "adshkjhWJKHSDBCFlajksdhkjhkjahr214kjh234235kjasdkj123dhkj23h423kjk" }
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file netbox_api_token_generator-0.1.tar.gz
.
File metadata
- Download URL: netbox_api_token_generator-0.1.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f56ff70d7e49fed247f08ff666a256ce8846887a2df5b037e8a3ab775d1f2ddf |
|
MD5 | 38595f1e19c76d3e450f493074e64210 |
|
BLAKE2b-256 | d032f91279030c371e5108d69c1bfae3304dcc6fb03260eeef40491c03d31ae5 |
File details
Details for the file netbox_api_token_generator-0.1-py3-none-any.whl
.
File metadata
- Download URL: netbox_api_token_generator-0.1-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e61e4c3177a4c13dbeb08e1630626b5886414defcae4be72107b8beb794e8b8c |
|
MD5 | 682b79ce5b25b42e687089fb89cafdd8 |
|
BLAKE2b-256 | 1b34f08f85b9ae8aeb790f6624740a34e30bacc93f36aec4101ffc5cc7828924 |