Skip to content

PubSub: Subscribing to a Pub/Sub topic requires additional permissions as a result of the release of google-cloud-pubsub 1.0.1 #9339

@jceresini

Description

@jceresini

Prior to todays release of the pubsub client, we were able to subscribe with only roles/pubsub.subscriber on the subscription we were trying to subscribe to. Now there is a call to get the subscription, which isn't permitted by that role.

It looks like this commit introduced the issue:
https://github.com/googleapis/google-cloud-python/pull/9268/files#diff-1004b3646a787f6b0438604df260553aR387

So after that release, our application broke (we happened to do a release a few hours after yours that picked up the latest pubsub library from pypi) because it did not have permission to get the subscription's metadata. After investigating for a while we were able to resolve the issue by adding roles/pubsub.viewer to the subscription in question. We had to enable Pub/Sub audit logs to get enough details to identify what was going on. Here's an example of the log that pointed us to the permission we were missing:

 {
   "protoPayload": {
     "@type": "type.googleapis.com/google.cloud.audit.AuditLog",
     "status": {
       "code": 7,
       "message": "PERMISSION_DENIED"
     },
     "authenticationInfo": {
       "principalEmail": "xxx@xxx.iam.gserviceaccount.com"
     },
     "requestMetadata": {
       "callerIp": "xxx",
       "callerSuppliedUserAgent": "grpc-python/1.24.0 grpc-c/8.0.0 (manylinux; chttp2; ganges),gzip(gfe)",
       "callerNetwork": "//compute.googleapis.com/projects/xxx/global/networks/__unknown__",
       "requestAttributes": {
         "time": "2019-09-27T22:41:46.042805867Z",
         "auth": {}
       },
       "destinationAttributes": {}
     },
     "serviceName": "pubsub.googleapis.com",
     "methodName": "google.pubsub.v1.Subscriber.GetSubscription",
     "authorizationInfo": [
       {
         "resource": "projects/xxx/subscriptions/xxx",
         "permission": "pubsub.subscriptions.get",
         "resourceAttributes": {}
       }
     ],
     "resourceName": "projects/xxx/subscriptions/xxx",
     "request": {
       "subscription": "projects/xxx/subscriptions/xxx",
       "@type": "type.googleapis.com/google.pubsub.v1.GetSubscriptionRequest"
     }
   },
   "insertId": "xxx",
   "resource": {
     "type": "pubsub_subscription",
     "labels": {
       "project_id": "xxx",
       "subscription_id": "projects/xxx/subscriptions/xxx"
     }
   },
   "severity": "ERROR",
   "logName": "projects/xxx/logs/cloudaudit.googleapis.com%2Fdata_access",
 }

Metadata

Metadata

Assignees

Labels

api: pubsubIssues related to the Pub/Sub API.priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions