Skip to content

Instantly share code, notes, and snippets.

@chapnickc
chapnickc / jwt_validator.py
Created September 2, 2017 22:23 — forked from jdalegonzalez/jwt_validator.py
Uses the the python-jose package to decode and validate an amazon identity or access token.
#!/usr/bin/env python3
""" Handles validation of a JWT web-token passed by the client
"""
import os
import sys
import argparse
import requests
import simplejson as json
@chapnickc
chapnickc / cognito-developer-authenticated-client-example.py
Created June 28, 2017 21:41 — forked from dkarchmer/cognito-developer-authenticated-client-example.py
django-boto3-cognito: AWS' Cognito Developer Authenticated Identities Authflow using Django/Python/Boto3 (For building stand-alone clients)
__author__ = 'dkarchmer'
'''
This script emulates a stand-alone Python based client. It relies on Boto3 to access AWS, but
requires your Django server to have an API for your user to access Cognito based credentials
Because of Cognito, the client (this script) will only get temporary AWS credentials associated
to your user and only your user, and based on whatever you configure your AIM Policy to be.
Most Cognito examples demonstrate how to use Cognito for Mobile Apps, so this scripts demonstrate
how to create a stand-alone Python script but operating similarly to these apps.
@chapnickc
chapnickc / check_jwt_sig.py
Created June 28, 2017 20:14 — forked from rondomondo/check_jwt_sig.py
Two methods/examples of how to decode and verify the signature of AWS cognito JWT web tokens externally. This uses RSA key pair and alternatively PKCS1_v1_5. See https://gist.github.com/rondomondo/efff911f2c41c295e23415e94e12b8d3 for example of signing and verification by downloading an ISSUERS PKI SSL certificate from the signers website, and h…
#!/usr/bin/env python
import os
import time
import json
import base64
import requests
import argparse
from base64 import urlsafe_b64decode, b64decode
from Crypto.Hash import SHA256, SHA512
@chapnickc
chapnickc / include_guards.py
Last active March 25, 2017 05:59
Add include guards to all header files in a directory
#!/usr/bin/env python3
import os.path
import sys
import glob
try:
# pass the directory as an argument
path = os.path.abspath(sys.argv[1])
except IndexError as e:
print(e)
@chapnickc
chapnickc / CMakeLists.txt
Created June 22, 2016 02:15 — forked from sander/CMakeLists.txt
CMake configuration for BLE Nano mbed projects on OS X
# Based on: https://developer.mbed.org/forum/team-63-Bluetooth-Low-Energy-community/topic/5257/
cmake_minimum_required(VERSION 2.8)
project(PROJECT)
set(ARMGCC_PREFIX
${PROJECT_SOURCE_DIR}/../../tools/arm/gcc-arm-none-eabi-4_9-2015q2)
set(MBED_SRC_PATH
${PROJECT_SOURCE_DIR}/../../lib/mbed/libraries/mbed)
set(BLE_API_SRC_PATH
@chapnickc
chapnickc / Downloader.py
Last active May 12, 2016 01:38
A useful class to download files from the internet
#!/usr/bin/env python3
import os
import time
from functools import wraps
import multiprocessing as mtp
import requests