{"action":"created","comment":{"url":"https://api.github.com/repos/istio/istio/pulls/comments/197890289","pull_request_review_id":131722459,"id":197890289,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5Nzg5MDI4OQ==","diff_hunk":"@@ -46,19 +46,91 @@ const (\n \t// RbacConfigName is the name of the RbacConfig custom resource that controls the RBAC behavior.\n \tRbacConfigName = \"rbac-config\"\n \n-\tsourceIP        = \"source.ip\"\n-\tsourceService   = \"source.service\"\n-\tdestinationIP   = \"destination.ip\"\n-\tdestinationPort = \"destination.port\"\n-\tuserHeader      = \":user\"\n-\tmethodHeader    = \":method\"\n-\tpathHeader      = \":path\"\n-\t//TODO(yangminzhu): Update the key after the final header name of service is decided.\n-\tserviceHeader       = \":service\"\n-\trequestHeaderPrefix = \"request.header[\"\n-\trequestHeaderSuffix = \"]\"\n+\t// attributes that could be used in both ServiceRole and ServiceRoleBinding.\n+\tattributeIP     = \"ip\"\n+\tattributeHeader = \"header:\" // header name is after the colon, e.g. \"header:User-Agent\".\n+\n+\t// attributes that could be used in a ServiceRole constraint.\n+\tattributePort      = \"port\"\n+\tattributeLabel     = \"label:\"          // label name is after the colon, e.g. \"label:version\".\n+\tattributeName      = \"name\"            // short service name, e.g. \"productpage\".\n+\tattributeNamespace = \"namespace\"       // e.g. \"default\".\n+\tattributeSA        = \"service-account\" // e.g. \"bookinfo-productpage\"\n+\n+\t// TODO(yangminzhu): Add authn related attributes.\n+\n+\tuserHeader   = \":user\"\n+\tmethodHeader = \":method\"\n+\tpathHeader   = \":path\"\n )\n \n+// serviceMetadata is a collection of different kind of information about a service.\n+type serviceMetadata struct {\n+\tname       string            // full qualified service name.\n+\tlabels     map[string]string // labels of the service instance\n+\tattributes map[string]string // additional attributes of the service\n+}\n+\n+func createServiceMetadata(attr *model.ServiceAttributes, in *model.ServiceInstance) *serviceMetadata {\n+\treturn &serviceMetadata{\n+\t\tname:   in.Service.Hostname.String(),\n+\t\tlabels: in.Labels,\n+\t\tattributes: map[string]string{\n+\t\t\tattributeName:      attr.Name,\n+\t\t\tattributeNamespace: attr.Namespace,\n+\t\t\tattributeSA:        in.ServiceAccount,\n+\t\t},\n+\t}\n+}\n+\n+// shouldMatchAttribute returns true if the given attribute should be matched just in the plugin.\n+// This is because we already have enough information to finish this in the plugin.\n+func shouldMatchAttribute(attr string) bool {\n+\tswitch attr {\n+\tcase attributeName, attributeNamespace, attributeSA:","path":"pilot/pkg/networking/plugin/authz/rbac.go","position":null,"original_position":56,"commit_id":"5e102713ec32a90647ccf9ed92d9d5a424c2c85e","original_commit_id":"7f304cd6384f6a101618767cfcb08482bb346fb8","user":{"login":"liminw","id":20001914,"node_id":"MDQ6VXNlcjIwMDAxOTE0","avatar_url":"https://avatars3.githubusercontent.com/u/20001914?v=4","gravatar_id":"","url":"https://api.github.com/users/liminw","html_url":"https://github.com/liminw","followers_url":"https://api.github.com/users/liminw/followers","following_url":"https://api.github.com/users/liminw/following{/other_user}","gists_url":"https://api.github.com/users/liminw/gists{/gist_id}","starred_url":"https://api.github.com/users/liminw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liminw/subscriptions","organizations_url":"https://api.github.com/users/liminw/orgs","repos_url":"https://api.github.com/users/liminw/repos","events_url":"https://api.github.com/users/liminw/events{/privacy}","received_events_url":"https://api.github.com/users/liminw/received_events","type":"User","site_admin":false},"body":"I understand there is no attribute concept in Pilot. However, \"attribute\" is Istio concept. Istio users have good understanding of attributes, and they are the standard way to describe the requests and environments. In our local RBAC proposal, we proposed to let users use attributes directly to describe the constraints and principal properties. The examples you gave above should be written as follows:\r\n```\r\n  services: [\"productpage.default.svc.local\"]\r\n  methods: [\"GET\"]\r\n  constraints:\r\n  - key: destination.name\r\n    values: [\"productpage\"]\r\n  - key: destination.labels[\"version\"]\r\n    values: [\"v1\", \"v2\"]\r\n```","created_at":"2018-06-25T18:07:40Z","updated_at":"2018-06-25T18:07:41Z","html_url":"https://github.com/istio/istio/pull/6554#discussion_r197890289","pull_request_url":"https://api.github.com/repos/istio/istio/pulls/6554","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/istio/istio/pulls/comments/197890289"},"html":{"href":"https://github.com/istio/istio/pull/6554#discussion_r197890289"},"pull_request":{"href":"https://api.github.com/repos/istio/istio/pulls/6554"}},"in_reply_to_id":197593521},"pull_request":{"url":"https://api.github.com/repos/istio/istio/pulls/6554","id":196864767,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk2ODY0NzY3","html_url":"https://github.com/istio/istio/pull/6554","diff_url":"https://github.com/istio/istio/pull/6554.diff","patch_url":"https://github.com/istio/istio/pull/6554.patch","issue_url":"https://api.github.com/repos/istio/istio/issues/6554","number":6554,"state":"open","locked":false,"title":"authz: add attributes support in ServiceRole","user":{"login":"yangminzhu","id":2189160,"node_id":"MDQ6VXNlcjIxODkxNjA=","avatar_url":"https://avatars2.githubusercontent.com/u/2189160?v=4","gravatar_id":"","url":"https://api.github.com/users/yangminzhu","html_url":"https://github.com/yangminzhu","followers_url":"https://api.github.com/users/yangminzhu/followers","following_url":"https://api.github.com/users/yangminzhu/following{/other_user}","gists_url":"https://api.github.com/users/yangminzhu/gists{/gist_id}","starred_url":"https://api.github.com/users/yangminzhu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yangminzhu/subscriptions","organizations_url":"https://api.github.com/users/yangminzhu/orgs","repos_url":"https://api.github.com/users/yangminzhu/repos","events_url":"https://api.github.com/users/yangminzhu/events{/privacy}","received_events_url":"https://api.github.com/users/yangminzhu/received_events","type":"User","site_admin":false},"body":"See #6377","created_at":"2018-06-22T23:19:57Z","updated_at":"2018-06-25T18:07:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"896a58629997a4a7c40d9f5121ca23495d520378","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":659652351,"node_id":"MDU6TGFiZWw2NTk2NTIzNTE=","url":"https://api.github.com/repos/istio/istio/labels/approved","name":"approved","color":"bfdadc","default":false},{"id":905361383,"node_id":"MDU6TGFiZWw5MDUzNjEzODM=","url":"https://api.github.com/repos/istio/istio/labels/area/security/aaa","name":"area/security/aaa","color":"0e8a16","default":false},{"id":491318011,"node_id":"MDU6TGFiZWw0OTEzMTgwMTE=","url":"https://api.github.com/repos/istio/istio/labels/cla:%20yes","name":"cla: yes","color":"bfdadc","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/istio/istio/pulls/6554/commits","review_comments_url":"https://api.github.com/repos/istio/istio/pulls/6554/comments","review_comment_url":"https://api.github.com/repos/istio/istio/pulls/comments{/number}","comments_url":"https://api.github.com/repos/istio/istio/issues/6554/comments","statuses_url":"https://api.github.com/repos/istio/istio/statuses/5e102713ec32a90647ccf9ed92d9d5a424c2c85e","head":{"label":"yangminzhu:dest_attr","ref":"dest_attr","sha":"5e102713ec32a90647ccf9ed92d9d5a424c2c85e","user":{"login":"yangminzhu","id":2189160,"node_id":"MDQ6VXNlcjIxODkxNjA=","avatar_url":"https://avatars2.githubusercontent.com/u/2189160?v=4","gravatar_id":"","url":"https://api.github.com/users/yangminzhu","html_url":"https://github.com/yangminzhu","followers_url":"https://api.github.com/users/yangminzhu/followers","following_url":"https://api.github.com/users/yangminzhu/following{/other_user}","gists_url":"https://api.github.com/users/yangminzhu/gists{/gist_id}","starred_url":"https://api.github.com/users/yangminzhu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yangminzhu/subscriptions","organizations_url":"https://api.github.com/users/yangminzhu/orgs","repos_url":"https://api.github.com/users/yangminzhu/repos","events_url":"https://api.github.com/users/yangminzhu/events{/privacy}","received_events_url":"https://api.github.com/users/yangminzhu/received_events","type":"User","site_admin":false},"repo":{"id":122268122,"node_id":"MDEwOlJlcG9zaXRvcnkxMjIyNjgxMjI=","name":"istio","full_name":"yangminzhu/istio","owner":{"login":"yangminzhu","id":2189160,"node_id":"MDQ6VXNlcjIxODkxNjA=","avatar_url":"https://avatars2.githubusercontent.com/u/2189160?v=4","gravatar_id":"","url":"https://api.github.com/users/yangminzhu","html_url":"https://github.com/yangminzhu","followers_url":"https://api.github.com/users/yangminzhu/followers","following_url":"https://api.github.com/users/yangminzhu/following{/other_user}","gists_url":"https://api.github.com/users/yangminzhu/gists{/gist_id}","starred_url":"https://api.github.com/users/yangminzhu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yangminzhu/subscriptions","organizations_url":"https://api.github.com/users/yangminzhu/orgs","repos_url":"https://api.github.com/users/yangminzhu/repos","events_url":"https://api.github.com/users/yangminzhu/events{/privacy}","received_events_url":"https://api.github.com/users/yangminzhu/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/yangminzhu/istio","description":"An open platform to connect, manage, and secure microservices.","fork":true,"url":"https://api.github.com/repos/yangminzhu/istio","forks_url":"https://api.github.com/repos/yangminzhu/istio/forks","keys_url":"https://api.github.com/repos/yangminzhu/istio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yangminzhu/istio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yangminzhu/istio/teams","hooks_url":"https://api.github.com/repos/yangminzhu/istio/hooks","issue_events_url":"https://api.github.com/repos/yangminzhu/istio/issues/events{/number}","events_url":"https://api.github.com/repos/yangminzhu/istio/events","assignees_url":"https://api.github.com/repos/yangminzhu/istio/assignees{/user}","branches_url":"https://api.github.com/repos/yangminzhu/istio/branches{/branch}","tags_url":"https://api.github.com/repos/yangminzhu/istio/tags","blobs_url":"https://api.github.com/repos/yangminzhu/istio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yangminzhu/istio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yangminzhu/istio/git/refs{/sha}","trees_url":"https://api.github.com/repos/yangminzhu/istio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yangminzhu/istio/statuses/{sha}","languages_url":"https://api.github.com/repos/yangminzhu/istio/languages","stargazers_url":"https://api.github.com/repos/yangminzhu/istio/stargazers","contributors_url":"https://api.github.com/repos/yangminzhu/istio/contributors","subscribers_url":"https://api.github.com/repos/yangminzhu/istio/subscribers","subscription_url":"https://api.github.com/repos/yangminzhu/istio/subscription","commits_url":"https://api.github.com/repos/yangminzhu/istio/commits{/sha}","git_commits_url":"https://api.github.com/repos/yangminzhu/istio/git/commits{/sha}","comments_url":"https://api.github.com/repos/yangminzhu/istio/comments{/number}","issue_comment_url":"https://api.github.com/repos/yangminzhu/istio/issues/comments{/number}","contents_url":"https://api.github.com/repos/yangminzhu/istio/contents/{+path}","compare_url":"https://api.github.com/repos/yangminzhu/istio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yangminzhu/istio/merges","archive_url":"https://api.github.com/repos/yangminzhu/istio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yangminzhu/istio/downloads","issues_url":"https://api.github.com/repos/yangminzhu/istio/issues{/number}","pulls_url":"https://api.github.com/repos/yangminzhu/istio/pulls{/number}","milestones_url":"https://api.github.com/repos/yangminzhu/istio/milestones{/number}","notifications_url":"https://api.github.com/repos/yangminzhu/istio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yangminzhu/istio/labels{/name}","releases_url":"https://api.github.com/repos/yangminzhu/istio/releases{/id}","deployments_url":"https://api.github.com/repos/yangminzhu/istio/deployments","created_at":"2018-02-20T23:07:28Z","updated_at":"2018-02-20T23:07:34Z","pushed_at":"2018-06-23T02:16:22Z","git_url":"git://github.com/yangminzhu/istio.git","ssh_url":"git@github.com:yangminzhu/istio.git","clone_url":"https://github.com/yangminzhu/istio.git","svn_url":"https://github.com/yangminzhu/istio","homepage":"https://istio.io","size":38882,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"istio:master","ref":"master","sha":"ab75e2434143678db39610a78ff5a81938e77d63","user":{"login":"istio","id":23534644,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIzNTM0NjQ0","avatar_url":"https://avatars1.githubusercontent.com/u/23534644?v=4","gravatar_id":"","url":"https://api.github.com/users/istio","html_url":"https://github.com/istio","followers_url":"https://api.github.com/users/istio/followers","following_url":"https://api.github.com/users/istio/following{/other_user}","gists_url":"https://api.github.com/users/istio/gists{/gist_id}","starred_url":"https://api.github.com/users/istio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/istio/subscriptions","organizations_url":"https://api.github.com/users/istio/orgs","repos_url":"https://api.github.com/users/istio/repos","events_url":"https://api.github.com/users/istio/events{/privacy}","received_events_url":"https://api.github.com/users/istio/received_events","type":"Organization","site_admin":false},"repo":{"id":74175805,"node_id":"MDEwOlJlcG9zaXRvcnk3NDE3NTgwNQ==","name":"istio","full_name":"istio/istio","owner":{"login":"istio","id":23534644,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIzNTM0NjQ0","avatar_url":"https://avatars1.githubusercontent.com/u/23534644?v=4","gravatar_id":"","url":"https://api.github.com/users/istio","html_url":"https://github.com/istio","followers_url":"https://api.github.com/users/istio/followers","following_url":"https://api.github.com/users/istio/following{/other_user}","gists_url":"https://api.github.com/users/istio/gists{/gist_id}","starred_url":"https://api.github.com/users/istio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/istio/subscriptions","organizations_url":"https://api.github.com/users/istio/orgs","repos_url":"https://api.github.com/users/istio/repos","events_url":"https://api.github.com/users/istio/events{/privacy}","received_events_url":"https://api.github.com/users/istio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/istio/istio","description":"An open platform to connect, manage, and secure microservices.","fork":false,"url":"https://api.github.com/repos/istio/istio","forks_url":"https://api.github.com/repos/istio/istio/forks","keys_url":"https://api.github.com/repos/istio/istio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/istio/istio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/istio/istio/teams","hooks_url":"https://api.github.com/repos/istio/istio/hooks","issue_events_url":"https://api.github.com/repos/istio/istio/issues/events{/number}","events_url":"https://api.github.com/repos/istio/istio/events","assignees_url":"https://api.github.com/repos/istio/istio/assignees{/user}","branches_url":"https://api.github.com/repos/istio/istio/branches{/branch}","tags_url":"https://api.github.com/repos/istio/istio/tags","blobs_url":"https://api.github.com/repos/istio/istio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/istio/istio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/istio/istio/git/refs{/sha}","trees_url":"https://api.github.com/repos/istio/istio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/istio/istio/statuses/{sha}","languages_url":"https://api.github.com/repos/istio/istio/languages","stargazers_url":"https://api.github.com/repos/istio/istio/stargazers","contributors_url":"https://api.github.com/repos/istio/istio/contributors","subscribers_url":"https://api.github.com/repos/istio/istio/subscribers","subscription_url":"https://api.github.com/repos/istio/istio/subscription","commits_url":"https://api.github.com/repos/istio/istio/commits{/sha}","git_commits_url":"https://api.github.com/repos/istio/istio/git/commits{/sha}","comments_url":"https://api.github.com/repos/istio/istio/comments{/number}","issue_comment_url":"https://api.github.com/repos/istio/istio/issues/comments{/number}","contents_url":"https://api.github.com/repos/istio/istio/contents/{+path}","compare_url":"https://api.github.com/repos/istio/istio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/istio/istio/merges","archive_url":"https://api.github.com/repos/istio/istio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/istio/istio/downloads","issues_url":"https://api.github.com/repos/istio/istio/issues{/number}","pulls_url":"https://api.github.com/repos/istio/istio/pulls{/number}","milestones_url":"https://api.github.com/repos/istio/istio/milestones{/number}","notifications_url":"https://api.github.com/repos/istio/istio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/istio/istio/labels{/name}","releases_url":"https://api.github.com/repos/istio/istio/releases{/id}","deployments_url":"https://api.github.com/repos/istio/istio/deployments","created_at":"2016-11-18T23:57:21Z","updated_at":"2018-06-25T17:50:52Z","pushed_at":"2018-06-25T18:01:30Z","git_url":"git://github.com/istio/istio.git","ssh_url":"git@github.com:istio/istio.git","clone_url":"https://github.com/istio/istio.git","svn_url":"https://github.com/istio/istio","homepage":"https://istio.io","size":39851,"stargazers_count":8862,"watchers_count":8862,"language":"Go","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1216,"mirror_url":null,"archived":false,"open_issues_count":795,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":1216,"open_issues":795,"watchers":8862,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/istio/istio/pulls/6554"},"html":{"href":"https://github.com/istio/istio/pull/6554"},"issue":{"href":"https://api.github.com/repos/istio/istio/issues/6554"},"comments":{"href":"https://api.github.com/repos/istio/istio/issues/6554/comments"},"review_comments":{"href":"https://api.github.com/repos/istio/istio/pulls/6554/comments"},"review_comment":{"href":"https://api.github.com/repos/istio/istio/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/istio/istio/pulls/6554/commits"},"statuses":{"href":"https://api.github.com/repos/istio/istio/statuses/5e102713ec32a90647ccf9ed92d9d5a424c2c85e"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"liminw"}}