Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Side by Side Diff: appengine/components/components/auth/service_account.py

Issue 2013943002: Changing license header, again! (Closed) Base URL: git@github.com:luci/luci-py.git@master
Patch Set: Fixed third parties Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2015 The LUCI Authors. All rights reserved. 1 # Copyright 2015 The LUCI Authors. All rights reserved.
2 # Use of this source code is governed by the Apache v2.0 license that can be 2 # Use of this source code is governed under the Apache License, Version 2.0
3 # found in the LICENSE file. 3 # that can be found in the LICENSE file.
4 4
5 """Generation of OAuth2 token for a service account. 5 """Generation of OAuth2 token for a service account.
6 6
7 A fancier version of app_identity.get_access_token(...) that can be used if 7 A fancier version of app_identity.get_access_token(...) that can be used if
8 app_identity is not appropriate for some reasons. For example, there's no way 8 app_identity is not appropriate for some reasons. For example, there's no way
9 to invite @appspot.gserviceaccount.com account to some Cloud API projects, 9 to invite @appspot.gserviceaccount.com account to some Cloud API projects,
10 while it is possible to create @developer.gserviceaccount.com belonging to such 10 while it is possible to create @developer.gserviceaccount.com belonging to such
11 project. 11 project.
12 12
13 Supports three ways to generate OAuth2 tokens: 13 Supports three ways to generate OAuth2 tokens:
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 168
169 169
170 def _rsa_sign(blob, private_key_pem): 170 def _rsa_sign(blob, private_key_pem):
171 """Byte blob + PEM key => RSA-SHA256 signature byte blob.""" 171 """Byte blob + PEM key => RSA-SHA256 signature byte blob."""
172 # Lazy import crypto. It is not available in unit tests outside of sandbox. 172 # Lazy import crypto. It is not available in unit tests outside of sandbox.
173 from Crypto.Hash import SHA256 173 from Crypto.Hash import SHA256
174 from Crypto.PublicKey import RSA 174 from Crypto.PublicKey import RSA
175 from Crypto.Signature import PKCS1_v1_5 175 from Crypto.Signature import PKCS1_v1_5
176 pkey = RSA.importKey(private_key_pem) 176 pkey = RSA.importKey(private_key_pem)
177 return PKCS1_v1_5.new(pkey).sign(SHA256.new(blob)) 177 return PKCS1_v1_5.new(pkey).sign(SHA256.new(blob))
OLDNEW
« no previous file with comments | « appengine/components/components/auth/replication_test.py ('k') | appengine/components/components/auth/service_account_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698