Skip to content

Instantly share code, notes, and snippets.

View fspot's full-sized avatar

Frédéric Matigot fspot

View GitHub Profile
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Usage: python upn.py list
python upn.py add|delete <port> tcp|udp"""
import miniupnpc
import sys
try:
@fspot
fspot / jwt.md
Last active December 6, 2018 14:28

How to craft authenticated tokens ?

Say you want to create a token with limited rights, for example with only access to a specific small app "myapp", and with a limited view on the data, like if you had a group "mygroup" assigned (this mechanism requires to setup permissions).

And say you want this token to expire in 10 hours, for security reasons.

The python code for crafting the token (using pyjwt library) would be:

import jwt
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.