This repository has been archived on 2025-05-04. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
fastly-py/fastly/auth.py
Tyler McMullen 2435affbc8 initial
2012-02-07 03:55:05 -08:00

22 lines
557 B
Python

"""
"""
from errors import *
import urllib
class KeyAuthenticator(object):
def __init__(self, key):
self.key = key
def add_auth(self, headers):
headers['X-Fastly-Key'] = self.key
class SessionAuthenticator(object):
def __init__(self, conn, login, password):
body = urllib.urlencode({ 'user': login, 'password': password })
resp, data = conn.request('POST', '/login', body)
self.session_key = resp.getheader('Set-Cookie')
def add_auth(self, headers):
headers['Cookie'] = self.session_key