Skip to content
This repository was archived by the owner on Jan 20, 2026. It is now read-only.
This repository was archived by the owner on Jan 20, 2026. It is now read-only.

service account authorization doesn't work with domain-restricted App Engine application #19

Closed

Description

@nlake44

b/10865628

My app with projection ID "appscale-staging" gives errors when trying to access data. I did the steps mentioned in
https://developers.google.com/datastore/docs/activate#google_cloud_datastore_from_other_platforms

And when I run a sample script I get the following error (with httplib.debuglevel set to 3):

root@appscale-image0:~# python test.py appscale-staging
connect: (accounts.google.com, 443)
send: 'POST /o/oauth2/token HTTP/1.1\r\nHost: accounts.google.com\r\nContent-Length: 643\r\ncontent-type: application/x-www-form-urlencoded\r\naccept-encoding: gzip, deflate\r\nuser-agent: Python-httplib2/0.8 (gzip)\r\n\r\n'
send: 'grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer&assertion=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIzNjQxODc0OTA2NDctaHZwMDNiNjE0bGttMmhqb2JscXZuZGI5bDQzNmE2dHNAZGV2ZWxvcGVyLmdzZXJ2aWNlYWNjb3VudC5jb20iLCJzY29wZSI6Imh0dHBzOi8vd3d3Lmdvb2dsZWFwaXMuY29tL2F1dGgvZGF0YXN0b3JlIGh0dHBzOi8vd3d3Lmdvb2dsZWFwaXMuY29tL2F1dGgvdXNlcmluZm8uZW1haWwiLCJhdWQiOiJodHRwczovL2FjY291bnRzLmdvb2dsZS5jb20vby9vYXV0aDIvdG9rZW4iLCJleHAiOjEzNzkxMTEwODksImlhdCI6MTM3OTEwNzQ4OX0.P_ePlrb6rDMZiEbgG5k3pU6lxx-5VryaYMK500Ma2-aZseYg-t4Uv6y6MeIQEbv45COv18-K-WOYuTZ0tScy_NXdW7dhfMB75GYeJ_kv8FmScg6bou_3Z6nEayvwy7aUkbig5YCqYkeqtHjB9WCOrNaskfoNAg27-C1TR2wcRFM'
reply: 'HTTP/1.1 200 OK\r\n'
header: Cache-Control: no-cache, no-store, max-age=0, must-revalidate
header: Pragma: no-cache
header: Expires: Fri, 01 Jan 1990 00:00:00 GMT
header: Date: Fri, 13 Sep 2013 21:24:47 GMT
header: Content-Type: application/json
header: Content-Encoding: gzip
header: Transfer-Encoding: chunked
header: X-Content-Type-Options: nosniff
header: X-Frame-Options: SAMEORIGIN
header: X-XSS-Protection: 1; mode=block
header: Server: GSE
header: Alternate-Protocol: 443:quic
connect: (www.googleapis.com, 443)
send: 'POST /datastore/v1beta1/datasets/appscale-staging/beginTransaction HTTP/1.1\r\nHost: www.googleapis.com\r\ncontent-length: 0\r\ncontent-type: application/x-protobuf\r\naccept-encoding: gzip, deflate\r\nauthorization: Bearer ya29.AHES6ZSBVZToloupANihvFflfnNvj1wGExzr8CX-ez7JU9I\r\nuser-agent: Python-httplib2/0.8 (gzip)\r\n\r\n'
reply: 'HTTP/1.1 403 Forbidden\r\n'
header: Content-Type: text/html; charset=UTF-8
header: Content-Encoding: gzip
header: Date: Fri, 13 Sep 2013 21:24:48 GMT
header: Expires: Fri, 13 Sep 2013 21:24:48 GMT
header: Cache-Control: private, max-age=0
header: X-Content-Type-Options: nosniff
header: X-Frame-Options: SAMEORIGIN
header: X-XSS-Protection: 1; mode=block
header: Content-Length: 33
header: Server: GSE
header: Alternate-Protocol: 443:quic
ERROR:root:Error while doing datastore operation
ERROR:root:RPCError: beginTransaction Unauthorized.
ERROR:root:HTTPError: 403 Forbidden

In the App Engine app I can go to the "ah-builtin-datastoreservice" version and see I'm getting 200's for BeginTransaction, so it looks like its doing something. Please advise on how to correct this. I have no problem when doing it with a newly created project.

Activity

  1. nlake44 commented on Sep 22, 2013

    @nlake44
    Author

    Initial report can be found here:
    #11

  2. proppy commented on Sep 23, 2013

    @proppy
    Contributor

    Updated the description to reflect the underlying issue.

    Service account authorization doesn't currently work with domain-restricted App Engine application since the client id is under a different domain.

    We can whitelist individual application to allow oauth from external domain, given that you understand the security implication, please comment on this issue with your application id if you would like to do it for your project.

  3. nlake44 commented on Sep 23, 2013

    @nlake44
    Author

    Please whitelist appscale-staging.

  4. proppy commented on Sep 23, 2013

    @proppy
    Contributor

    @nlake44 appscale-staging whitelisted for allowing other auth domains.

  5. proppy commented on Oct 22, 2013

    @proppy
    Contributor

    @eduardo-dedalus, please confirm that you understand the security application: account outside of your domain could auth with your application using OAuth depending on how your application is built.

  6. proppy commented on Jan 16, 2015

    @proppy
    Contributor
  7. eddavisson commented on Jan 16, 2015

    @eddavisson
    Contributor

    @markus-koehler, I'm happy to help with that. Can you send an email to eddavisson@google.com from one of the admin accounts on php-hello-world-824 and confirm that you understand the security implications: if you are using the OAuth API in your application, it will no longer enforce the domain restriction.

  8. eddavisson commented on Apr 6, 2016

    @eddavisson
    Contributor

    This is fixed in Cloud Datastore v1beta3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ 换网址