Skip to content

Instantly share code, notes, and snippets.

@jpf
jpf / output.sh
Created March 7, 2016 22:26
Don't hate: cavitate
$ for w in `cat /usr/share/dict/words | egrep 'ate$'`; do echo "Don't hate: ${w}"; done
Don't hate: abacate
Don't hate: abacinate
Don't hate: abalienate
Don't hate: abate
Don't hate: abbreviate
Don't hate: abdicate
Don't hate: aberrate
Don't hate: abietate
Don't hate: abintestate
@jpf
jpf / requirements.org
Last active November 2, 2023 05:29
What a requirements.txt file might look like in a literate program

#

@jpf
jpf / signed-jwt-in-python.md
Last active February 17, 2024 15:07
JWTs signed with RS256 in Python: A demonstration of org-babel

Introduction

This is a guide to using pyjwt to sign and validate a JWT using RS256.

The trickiest part of doing this is knowing what the proper OpenSSL commands are to generate the RSA keypair. I demonstrate that below.

Generating RSA keys

@jpf
jpf / fetch-ssl-from-okta-com.sh
Created November 10, 2015 18:59
How to fetch the SSL certificate from www.okta.com
echo '' | openssl s_client -connect www.okta.com:443
@jpf
jpf / welcome.py
Created August 20, 2015 01:58
The code I used for my welcome message at the sfpython "Project Night at Okta" event
import os
import time
import okta
# Get your very own Okta organization at: http://developer.okta.com
client = okta.AuthClient("https://example.okta.com",
"your-api-token")
@jpf
jpf / okta-words.txt
Created June 29, 2015 18:39
cat /usr/share/dict/words | egrep -i '^octa' | sed 's/cta/kta/g'
oktachloride
oktachord
oktachordal
oktachronous
Oktacnemus
oktacolic
oktactinal
oktactine
Oktactiniae
oktactinian
@jpf
jpf / okta_openvpn.py
Created April 30, 2015 20:19
Okta OpenVPN, using pyca/cryptography instead of M2Crypto
#!/usr/bin/env python2
# vim: set noexpandtab:ts=4
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# Contributors: gdestuynder@mozilla.com
import ConfigParser
import base64
@jpf
jpf / app.py
Created March 21, 2015 00:46
Example SAML SP using PySAML2. Can handle IdP initiated requests and make SP initated (authn) requests
# -*- coding: utf-8 -*-
import logging
import os
import uuid
from flask import Flask
from flask import redirect
from flask import request
from flask import url_for
from flask.ext.login import LoginManager
@jpf
jpf / validate_ssl_pin.py
Created March 3, 2015 02:15
How to implmement TLS Public Key Pinning in Python (Sort of modeled after HKPK)
import urllib3
from urllib3 import HTTPSConnectionPool
import certifi
import base64
import M2Crypto
import hashlib
class TestHTTPSConnectionPool(HTTPSConnectionPool):
def _validate_conn(self, conn):
# * * * * * command to be executed
# - - - - -
# | | | | |
# | | | | +- - - - day of week (0 - 6) (Sunday=0)
# | | | +- - - - - month (1 - 12)
# | | +- - - - - - day of month (1 - 31)
# | +- - - - - - - hour (0 - 23)
# +- - - - - - - - minute (0 - 59)