| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
To "confirm" this implementation matches our current one I did the following: >>> import json
>>> from oauth2client.client import GoogleCredentials
>>> from OpenSSL import crypto
>>> from gcloud import credentials
>>> creds = GoogleCredentials.get_application_default() # Env. var. -> path to JSON key
>>> pkey = crypto.load_privatekey(crypto.FILETYPE_PEM, creds._private_key_pkcs8_text)
>>> data = b'foo'
>>> new_signed_bytes = crypto.sign(pkey, data, 'SHA256')
>>> curr_signed_bytes = credentials._get_signature_bytes(creds, data)
>>> new_signed_bytes == curr_signed_bytes
True |
Sorry, something went wrong.
|
H/T to @tseaver for pointing out that cryptography was managed by the PyCA which led me to discover that pyOpenSSL was too. |
Sorry, something went wrong.
This was done because PyCrypto does not install easily on Windows. pyOpenSSL is managed by PyCA (the Python crypto authority) and has a mature release process. This change was influenced by discussions about googleapis#1009.
|
@jonparrott Is pyOpenSSL supported on App Engine? |
Sorry, something went wrong.
|
I don't think so; only pycrypto and the core ssl library. |
Sorry, something went wrong.
|
OK. PyCrypto has a pretty crappy install story (latest version isn't on PyPI, pip install fails on Windows). It may be best to take the oauth2client approach and just implement using both pyOpenSSL and PyCrypto but require neither in setup.py. |
Sorry, something went wrong.
|
Sounds reasonable. |
Sorry, something went wrong.
|
I'd really hate to have our codebase cluttered with both the current PyCrypto-based implementation and the new pyOpenSSL-based one. |
Sorry, something went wrong.
Maybe now is the time to bite the bullet and get both implementations into oauth2client? Then the question becomes
|
Sorry, something went wrong.
I really don't want to introduce imperative platform-based variations in the requirements (breaking wheel generation, for instance). Is there a PEP 508-supported way to detect GAE? |
Sorry, something went wrong.
No. |
Sorry, something went wrong.
|
@jonparrott Wrote https://github.com/jonparrott/Darth-Vendor which probably makes him the foremost expert on packaging for GAE 😀 |
Sorry, something went wrong.
|
@jonparrott After some digging I realized this can be done in pure Python using pyasn1, pyasn1-modules and rsa. Is there any vendor-ing issue for these libraries on GAE? |
Sorry, something went wrong.
|
@dhermes if they have any native components, then yes. Let me verify. |
Sorry, something went wrong.
|
@dhermes those should be fine. Go for it. 👍 |
Sorry, something went wrong.
|
Good deal. Thanks for doing it for me (I know I could've RTFM instead of wasting your time). |
Sorry, something went wrong.
Considering how much of your time I've monopolized elsewhere, I'd say I owe you. |
Sorry, something went wrong.
|
As I was starting to do the rsa/pyasn1 implementation I realized GAE users are [covered] by using oauth2client.appengine.AppAssertionCredentials so we don't need to worry if they have support for either pyOpenSSL or PyCrypto. @jonparrott What does darth vendor do if a package can't be installed / imported in GAE? |
Sorry, something went wrong.
|
@dhermes nothing. pip handles the installation, not the vendor tool. Pip will happily stage a binary package into the lib directory. :( |
Sorry, something went wrong.
|
OK. I suppose we could try/except ImportError on the pyOpenSSL import. Though it seems strange to do for something in setup.py. |
Sorry, something went wrong.
|
Would the try:..except: in setup.py be to make the dependency on PyCrypto be "soft" FBO the GAE environment? |
Sorry, something went wrong.
|
What did you have in mind? i.e. Try and except what import? How would it help GAE? |
Sorry, something went wrong.
|
I'm responding to:
|
Sorry, something went wrong.
|
I meant try/except in our code, not in setup.py. |
Sorry, something went wrong.
|
setup.py doesn't run on app engine, it runs on the user's machine when they vendor the package. |
Sorry, something went wrong.
|
@jonparrott Do you think it's fine to just leave pyopenssl as a dep since on GAE the user has the fancy http://oauth2client.readthedocs.org/en/stable/source/oauth2client.appengine.html module (now moved to contrib) |
Sorry, something went wrong.
|
I think you're in the clear as long as you don't ever try to use the library within GAE code. |
Sorry, something went wrong.
|
@tseaver GAE is "no longer" a blocker for using pyopenssl. Remaining issues? |
Sorry, something went wrong.
I thought GAE was the only reason to keep the pyopenssl codepath around at all. Am I mistaken? |
Sorry, something went wrong.
|
Nope its Windows. Check out the description of this PR. |
Sorry, something went wrong.
|
I just scared myself into thinking that it'd be a blocker for GAE but forgot that GAE and GCE had custom credentials types |
Sorry, something went wrong.
|
Oops, I misspoke: I meant I thought the old codepath (PyCrypto) was being kept around FBO GAE. If that isn't so, then lets just punt and make pyOpenSSL the only way we do this. |
Sorry, something went wrong.
|
Got it. All good to merge? (PS I am planning on pushing this upstream to oauth2client at some point.) |
Sorry, something went wrong.
|
LGTM. I had lost track of the fact that you already dropped the old codepath. |
Sorry, something went wrong.
Swapping PyCrypto for pyOpenSSL.
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Source-Link: googleapis/synthtool@56da63e Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:993a058718e84a82fda04c3177e58f0a43281a996c7c395e0a56ccc4d6d210d7
* feat: support fine-grained permissions database roles in connect Add an optional `database_role` argument to `connect` for supplying the database role to connect as when using [fine-grained access controls](https://cloud.google.com/spanner/docs/access-with-fgac) * feat: support fine-grained permissions database roles in connect Add an optional `database_role` argument to `connect` for supplying the database role to connect as when using [fine-grained access controls](https://cloud.google.com/spanner/docs/access-with-fgac) * add missing newline to code block --------- Co-authored-by: Knut Olav Løite <koloite@gmail.com>
| Back | FazBrowse Home | New Git URL |
This was done because PyCrypto does not install easily on Windows. pyOpenSSL is managed by PyCA (the Python crypto authority) and has a mature release process.
This change was influenced by discussions about #1009.