auth_pubtkt

Screenshot Software:
auth_pubtkt
Detalii soft:
Versiune: 0.1
Incarca data: 12 May 15
Producător: Andrey Plotnikov
Licenţă: Gratuit
Popularitate: 12

Rating: 3.0/5 (Total Votes: 1)

auth_pubtkt este un modul care implementează autentificarea mod_auth_pubtkt pentru lumea Python.
crearea de vânzare bilete
Importul module nessesary:
& Nbsp; >>> din M2Crypto import RSA
& Nbsp; >>> auth_pubtkt import
& Nbsp; >>> auth_pubtkt.tests import
& Nbsp; >>> os.path import
& Nbsp; >>> timp import, datetime
Încărcarea RSA cheie privată de pachet de teste:
& Nbsp; >>> privkey_path = os.path.join (os.path.dirname (auth_pubtkt.tests .__ file__), "rsa_priv.pem")
& Nbsp; >>> privkey = RSA.load_key (privkey_path)
Timp de expirare set de 2011/01/01 00:00
& Nbsp; >>> validuntil = Int (time.mktime (datetime.datetime (2011, 1, 1) .timetuple ()))
Generarea bilet de utilizator "john":
& Nbsp; >>> bilet = auth_pubtkt.create_ticket (privkey, "john", validuntil, token = ['su'])
& Nbsp; >>> bilet
 'uid=john;validuntil=1293814800;tokens=su;sig=YuM/RL8ub+XMb0ZTTlFYF6ehwRV8SnKx+TLj/syZmVx1ncR4QD58OMdRkmdmDCY9sdsoivcf+ACRCRX19nmEc5Ba+182FyRKC8bGL51GwPs+lMgaIaXxvhSvRbl/00sTWny+XEv1fEQDSc5tw3/ug6/YA9xt2wywUX1+hxfWQ5U='
Middleware
& Nbsp; >>> urllib import
& Nbsp; >>> pubkey_path = os.path.join (os.path.dirname (auth_pubtkt.tests .__ file__), "rsa_pub.pem")
& Nbsp; >>> pubkey = RSA.load_pub_key (pubkey_path)
& Nbsp; >>> def test_app (environ, start_response):
& Nbsp; ... pentru cheie in sortate (environ.keys ()):
& Nbsp; ... print '% s:% s "% (tasta, environ [tasta])
& Nbsp; >>> app = auth_pubtkt.AuthPubTKTMiddleware (test_app, pubkey)
& Nbsp; >>> Mediu = {}
& Nbsp; >>> env ['REMOTE_ADDR'] = '192.168.1.10 "
& Nbsp; >>> env ['REQUEST_METHOD'] = 'GET'
& Nbsp; >>> env ['HTTP_COOKIE'] = 'auth_pubtkt = "% s" "% urllib.quote (bilet)
& Nbsp; >>> app (env, statutul lambda, începe: Nici unul)
& Nbsp; AUTH_TYPE: cookie
& Nbsp; HTTP_COOKIE: auth_pubtkt="uid=john;validuntil=1293814800;tokens=su;sig=YuM/RL8ub+XMb0ZTTlFYF6ehwRV8SnKx+TLj/syZmVx1ncR4QD58OMdRkmdmDCY9sdsoivcf+ACRCRX19nmEc5Ba+182FyRKC8bGL51GwPs+lMgaIaXxvhSvRbl/00sTWny+XEv1fEQDSc5tw3/ug6/YA9xt2wywUX1+hxfWQ5U="
& Nbsp; REMOTE_ADDR: 192.168.1.10
& Nbsp; REMOTE_USER: john
& Nbsp; REMOTE_USER_DATA:
& Nbsp; REMOTE_USER_TOKENS: su
& Nbsp; REMOTE_USER_TOKENS_LIST: ['su']
& Nbsp; REQUEST_METHOD: GET
& nbsp; auth_pubtkt.ticket_fields: {"jetoane": ['su'], "validuntil": 1293814800, "uid": "john"}

Cerințe :

  • Python

Comentarii la auth_pubtkt

Comentariile nu a fost găsit
Adauga comentarii
Porniţi pe imagini!