Skip to content

Instantly share code, notes, and snippets.

@dolph
dolph / hello.py
Last active December 20, 2015 01:29
Hello World WSGI
def application(env, start_response):
start_response('200 OK', [('Content-Type', 'text/plain')])
return 'Hello world, from Python!'
@dolph
dolph / demo.py
Last active December 20, 2015 21:38
encrypted access token demo
"""
Offline validation of oauth access_keys.
"""
import base64
import string
import unittest
import urllib
import uuid
import zlib
@dolph
dolph / git-ready
Last active December 21, 2015 21:39
Work from an up-to-date untracked branch using git.
#!/bin/bash
BRANCH=${1:-master}
git checkout $BRANCH
git pull
git checkout $BRANCH~0
find . -name "*.pyc" -delete
git log -n 1
git status
@dolph
dolph / keystoneclient_ux.py
Last active December 26, 2015 11:09
A demo of ideas for a completely refreshed keystoneclient user experience
import keystoneclient
# auto-discover the identity endpoint given just a host name (this could use
# SRV DNS records to reach the identity service)
c = keystoneclient.Client('example.com')
# authentication plugins are instantiated seperately from the base client.
# password auth is part of the core Identity API, and should be supported
# directly by the client.
password_auth = keystoneclient.PasswordAuth(
@dolph
dolph / icehouse.md
Last active December 27, 2015 17:59
OpenStack Keystone
@dolph
dolph / example.md
Last active December 28, 2015 21:49
Managing Keystone Identity Providers

Create a provider: POST /v3/identity_providers

Create an attribute mapping: POST /v3/mappings

Add an attribute mapping to a provider protocol: PUT /v3/identity_providers/abc123/protocols/saml

{
  "protocol": {
    "id": "saml",

"mapping_id": "xyz234"

Password change operations

Administrative password reset

This applies to both lost and compromised passwords.

Example:

PATCH /users/{user_id}

{"user": {"password": "new-password"}}

@dolph
dolph / v3.json
Last active December 30, 2015 10:29
GET /v3/
{
"version": {
"status": "stable",
"updated": "2013-03-06T00:00:00Z",
"media-types": [
{
"base": "application/json",
"type": "application/vnd.openstack.identity-v3+json"
},
{
@dolph
dolph / exercise.py
Last active December 31, 2015 03:49
import uuid
import multiprocessing
def f():
x = list()
for _ in xrange(1000000):
x.append(uuid.uuid4())
while True:
@dolph
dolph / discover.py
Last active December 31, 2015 21:19
Cached Identity API version discovery demo
"""Cached Identity API version discovery demo.
Running discover on an endpoint once results in an HTTP call:
$ python discover.py http://localhost:35357/
GET http://localhost:35357/
{2.0: u'http://localhost:35357/v2.0/', 3.0: u'http://localhost:35357/v3/'}
Running discover on an endpoint a second time hits the cache instead of HTTP: