Skip to content

Instantly share code, notes, and snippets.

View dmendiza's full-sized avatar
🏠
Working from home

Douglas Mendizábal dmendiza

🏠
Working from home
  • Middletown, CT
View GitHub Profile
# Add new import
from sqlalchemy_utils.types.password import PasswordType
# Change password in User model
password = db.Column(PasswordType(
schemes=[
'bcrypt',
'plaintext'
],
deprecated=['plaintext'],
@dmendiza
dmendiza / 01.sh
Last active August 29, 2015 14:18
private Use Cases
# Use Case 1
# Generate private RSA Key in PKCS#8 format and store using POST+PUT
# Media-Type: application/pkcs8
# Create the RSA keypair
openssl genrsa -out private.pem 2048
# Convert from "traditional" to PKCS#8
openssl pkcs8 -topk8 -nocrypt -in private.pem -out private.pk8
# Submit a metadata-only POST
@dmendiza
dmendiza / 01.sh
Last active August 29, 2015 14:18
public Use Cases
# Use Case 1
# Generate and store the public key of an RSA 2048 keypair using POST+PUT
# User Format: openssl default public key PEM. (aka SubjectPublicKeyInfo inside a PEM file with header/footer)
# Transfer Format: None - File does not need to be encoded for transfer
# Content-Type: application/octet-stream
# Expected Format from Barbican: Identical PEM file
# Create the RSA keypair
openssl genrsa -out private.pem 2048
@dmendiza
dmendiza / 01.sh
Last active August 29, 2015 14:18
symmetric Use Cases
# Use Case 1:
# Generate and store a random symmetric key for use in AES-256-CBC encryption using POST+PUT
# User Format: A file containing random bytes.
# Transfer Format: None - File does not need to be encoded for transfer.
# Content-Type: application/octet-stream
# Note that the content-type (media-type? [1]) is used in the PUT as "Content-Type: application/octet-stream"
# and again when retrieving the file in the GET as "Accept: application/octet-stream"
# Expected Format from Barbican: Identical file with the same random bytes
# Create an encryption_key file with 256 bits of random data
docker build -t postgres postgresql/
docker build -t keystone keystone/
docker run -d --name postgres postgres
docker run -d -p 5000:5000 -p 35357:35357 --link postgres:db --name keystone keystone
sed -i "s/OS_SERVICE_ENDPOINT=.*/OS_SERVICE_ENDPOINT=\"http:\/\/localhost:35357\/v2.0\"/" barbican/scripts/keystone_data.sh
./barbican/scripts/keystone_data.sh
@dmendiza
dmendiza / 01_install.sh
Last active March 1, 2021 18:09
Django Unchained - PyTexas 2014
# Install Django
pip install django

Keybase proof

I hereby claim:

  • I am dmend on github.
  • I am redrobot (https://keybase.io/redrobot) on keybase.
  • I have a public key whose fingerprint is 245C 7B6F 70E9 D8F3 F5D5 0CC9 AD14 1F30 2D58 923C

To claim this, I am signing this object:

def my_method_with_except():
try:
dangerous_method()
except Exception:
raise
def my_method_without_except():
dangerous_method()
from keystoneclient.v3 import client as keystone_client
from barbicanclient import client
keystone = keystone_client.Client(user_domain_name=DOMAIN_NAME,
username=USER,
password=PASS,
project_domain_name=PROJECT_DOMAIN_NAME,
project_name=PROJECT_NAME,
auth_url=KEYSTONE_URL)
@dmendiza
dmendiza / gist:8607196
Created January 24, 2014 21:42
python-barbicanclient authentication with Rackspace Identity
from barbicanclient.common import auth
from barbicanclient import client
# using username and password
rack_auth = auth.RackspaceAuthV2(auth_url='http://identity.rackspace...',
username='username',
password='password')
# alternatively you can use an api-key instead of a password
rack_auth = auth.RackspaceAuthV2(auth_url='http://identity.rackspace...',