Skip to content

Commit

Permalink
Implement the .../service-accounts/.../scopes endpoint in metadata se…
Browse files Browse the repository at this point in the history
…rver (#338)
  • Loading branch information
jmarshall authored May 27, 2024
1 parent a9a79d2 commit d7191ed
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions batch/batch/cloud/gcp/worker/metadata_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ async def user_email(request: web.Request):
return web.Response(text=request.app[AppKeys.USER_CREDENTIALS].email)


async def user_scopes(request: web.Request):
text = '\n'.join(request.app[AppKeys.USER_CREDENTIALS]._scopes)
return web.Response(text=f'{text}\n')


async def user_token(request: web.Request):
access_token = await request.app[AppKeys.USER_CREDENTIALS]._get_access_token()
return web.json_response({
Expand Down Expand Up @@ -101,6 +106,7 @@ def create_app(
web.get('/computeMetadata/v1/instance/service-accounts/{gsa}', user_service_account),
web.get('/computeMetadata/v1/instance/service-accounts/{gsa}/', user_service_account),
web.get('/computeMetadata/v1/instance/service-accounts/{gsa}/email', user_email),
web.get('/computeMetadata/v1/instance/service-accounts/{gsa}/scopes', user_scopes),
web.get('/computeMetadata/v1/instance/service-accounts/{gsa}/token', user_token),
])

Expand Down

0 comments on commit d7191ed

Please sign in to comment.