Skip to content
This repository has been archived by the owner on Jan 18, 2025. It is now read-only.

Update GCE AppAssertionCredentials #476

Closed
wants to merge 39 commits into from
Closed

Conversation

elibixby
Copy link
Contributor

This provides several much needed updates to GCE App Assertion Credentials

  1. Properly populates token expiry
  2. Retrieves credentials scopes from the metadata server
  3. Allows credentials to use custom service accounts by providing an optional email field
  4. Implements serialization/deserialization for this email field
  5. Provides a project_id property using metadata server in preparation for a pull request addressing Allow GCE credentials to sign blobs #471

* Now tracks Token Expire times
* Adds project_id property in preparation for googleapis#471 PR
* Allows usage of custom service accounts from in GCE accordance with
  the [beta
capabilities](https://cloud.google.com/compute/docs/authentication#createcutomserviceaccount)
* Now properly knows scopes of the service account
# used by this class.
self.scope = util.scopes_to_string(scope)

self.scopes = None

This comment was marked as spam.

@elibixby
Copy link
Contributor Author

I am still in the process of adding tests for this PR. Do Not Merge.

* consolidates requests for email field
* provides a "expiresAt" field

Will revert to v1 endpoint if GCE eng team says that there are plans to
deprecate 0.1

Additionally made scopes an `@property` to avoid false readings of no
scopes
'instance/service-accounts/default/')
META = _METADATA_ROOT + 'token'
_DEFAULT_EMAIL_METADATA = _METADATA_ROOT + 'email'
_METADATA_ROOT = 'http://metadata.google.internal/0.1/meta-data'

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

* added a service_account_info property with more detailed information
  and to share code between service_account_email and _refresh_scopes

@property
def serialization_data(self):
return self.service_account_info

This comment was marked as spam.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.02%) to 97.544% when pulling ae03714 on elibixby:master into 3ca2ca7 on google:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.02%) to 97.544% when pulling eed5f04 on elibixby:master into 3ca2ca7 on google:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.01%) to 97.577% when pulling d2f1bbb on elibixby:master into 3ca2ca7 on google:master.

return False
self.access_token, self.token_expiry = _get_access_token(
http_request,
self._service_account_info['email']

This comment was marked as spam.

@nathanielmanistaatgoogle
Copy link
Contributor

Be prepared at the end of the review to squash commits.

@elibixby
Copy link
Contributor Author

elibixby commented Apr 1, 2016

https://github.com/blog/2141-squash-your-commits

Is this option available to you now? Or do I still have to manually squash?

@nathanielmanistaatgoogle
Copy link
Contributor

A repository setting to require all pull requests to be one commit each probably is available to us, but I'm not sure that we'd want to enable it for all changes. Some are still appropriate to be done in multiple commits.

@@ -16,60 +16,117 @@

Utilities for making it easier to use OAuth 2.0 on Google Compute Engine.
"""

This comment was marked as spam.

elibixby added 2 commits April 4, 2016 16:52
* Remove deserialization arg from constructor
@elibixby
Copy link
Contributor Author

elibixby commented Apr 5, 2016

@nathanielmanistaatgoogle Fixes pushed


__author__ = '[email protected] (Joe Gregorio)'

logger = logging.getLogger(__name__)

# URI Template for the endpoint that returns access_tokens.
_METADATA_ROOT = ('http://metadata.google.internal/computeMetadata/v1/'
'instance/service-accounts/default/')
META = _METADATA_ROOT + 'token'

This comment was marked as spam.

@elibixby
Copy link
Contributor Author

elibixby commented Apr 5, 2016

@nathanielmanistaatgoogle More fixes.

@elibixby
Copy link
Contributor Author

@nathanielmanistaatgoogle @dhermes Bump.

@elibixby
Copy link
Contributor Author

After discussion with @jonparrott I'm going to break this into 3 smaller PRs:

  • add a metadata module that takes care of caching paths
  • Move gce.AppAssertionCredentials to use the metadata module
  • Add credentials.scopes and support for custom emails

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants