auth_pubtkt

Sagteware kiekie:
auth_pubtkt
Sagteware besonderhede:
Weergawe: 0.1
Upload datum: 12 May 15
Ontwikkelaar: Andrey Plotnikov
Lisensie: Gratis
Populariteit: 12

Rating: 3.0/5 (Total Votes: 1)

auth_pubtkt is 'n module wat mod_auth_pubtkt verifikasie implemente vir Python wêreld.
skepping kaartjie
Invoer noodwendige modules:
& Nbsp; >>> van M2Crypto invoer RSA
& Nbsp; >>> invoer auth_pubtkt
& Nbsp; >>> invoer auth_pubtkt.tests
& Nbsp; >>> invoer os.path
& Nbsp; >>> invoer tyd datetime
Laai RSA private sleutel van toetse pakket:
& Nbsp; >>> privkey_path = os.path.join (os.path.dirname (auth_pubtkt.tests .__ file__), 'rsa_priv.pem')
& Nbsp; >>> privkey = RSA.load_key (privkey_path)
Stel verstryking tyd om 2011/01/01 00:00
& Nbsp; >>> validuntil = int (time.mktime (datetime.datetime (2011, 1, 1) .timetuple ()))
Genereer kaartjie vir gebruiker John:
& Nbsp; >>> kaartjie = auth_pubtkt.create_ticket (privkey, "Johannes, validuntil, tekens = ['su'])
& Nbsp; >>> kaartjie
 'uid=john;validuntil=1293814800;tokens=su;sig=YuM/RL8ub+XMb0ZTTlFYF6ehwRV8SnKx+TLj/syZmVx1ncR4QD58OMdRkmdmDCY9sdsoivcf+ACRCRX19nmEc5Ba+182FyRKC8bGL51GwPs+lMgaIaXxvhSvRbl/00sTWny+XEv1fEQDSc5tw3/ug6/YA9xt2wywUX1+hxfWQ5U='
Middleware
& Nbsp; >>> invoer urllib
& 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; ... vir die sleutel in gesorteerde (environ.keys ()):
& Nbsp; ... Druk '% s:% s'% (sleutel, omge [sleutel])
& Nbsp; >>> app = auth_pubtkt.AuthPubTKTMiddleware (test_app, pubkey)
& Nbsp; >>> env = {}
& Nbsp; >>> env ['REMOTE_ADDR'] = '192.168.1.10'
& Nbsp; >>> env ['REQUEST_METHOD'] = 'Kry'
& Nbsp; >>> env ['HTTP_COOKIE'] = 'auth_pubtkt = "% s"'% urllib.quote (kaartjie)
& Nbsp; >>> app (env, lambda status, begin: Geen)
& Nbsp; AUTH_TYPE: koekie
& 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: KRY
& Nbsp; auth_pubtkt.ticket_fields: {'tekens': ['su'], 'validuntil': 1293814800, 'uid': 'Johannes'}

Vereistes :

  • Python

Kommentaar te auth_pubtkt

Kommentaar nie gevind
Kommentaar te lewer
Draai op die foto!