מדיניות של ניהול זהויות והרשאות גישה (IAM), שמציינת אמצעי בקרת גישה למשאבי Google Cloud.
Policy הוא אוסף של bindings. binding מקשר members אחד או יותר, או חשבונות משתמשים, ל-role יחיד. חשבונות משתמשים, חשבונות שירות, קבוצות Google ודומיינים (כמו G Suite) יכולים לשמש כחשבונות משתמשים. role היא רשימת הרשאות בעלת שם. כל role יכול להיות תפקיד מוגדר מראש ב-IAM או תפקיד בהתאמה אישית שנוצר על ידי משתמש.
בחלק מסוגי המשאבים ב-Google Cloud, אפשר לציין ב-binding גם condition, שהוא ביטוי לוגי שמאפשר גישה למשאב רק אם הערך של הביטוי הוא true. תנאי יכול להוסיף אילוצים על סמך מאפיינים של הבקשה, של המשאב או של שניהם. במסמכי העזרה של IAM מוסבר אילו משאבים תומכים בתנאים במדיניות IAM שלהם.
הערכים החוקיים הם 0, 1 ו-3. בקשות עם ערך לא חוקי יידחו.
כל פעולה שמשפיעה על קישורי תפקידים מותנים חייבת לציין את הגרסה 3. הדרישה הזו חלה על הפעולות הבאות:
אחזור מדיניות שכוללת קישור תפקיד מותנה
הוספה של קישור תפקיד מותנה למדיניות
שינוי של קישור תפקיד מותנה במדיניות
הסרה של קישור תפקיד, עם או בלי תנאי, ממדיניות שכוללת תנאים
חשוב: אם משתמשים בתנאים של IAM, צריך לכלול את השדה etag בכל קריאה ל-setIamPolicy. אם משמיטים את השדה הזה, IAM מאפשר להחליף את מדיניות הגרסה 3 במדיניות הגרסה 1, וכל התנאים במדיניות הגרסה 3 אבדו.
אם מדיניות לא כוללת תנאים, אפשר לציין כל גרסה תקינה בפעולות על המדיניות הזו או להשאיר את השדה ללא הגדרה.
שיוך של רשימת members, או חשבונות משתמשים, ל-role. אפשר גם לציין condition שקובע איך ומתי ה-bindings יחולו. כל אחד מה-bindings חייב להכיל לפחות חשבון משתמש אחד.
השדה bindings ב-Policy יכול להפנות עד 1,500 חשבונות משתמשים, ועד 250 מחשבונות המשתמשים האלה יכולים להיות קבוצות Google. כל מופע של חשבון משתמש נספר במגבלות האלה. לדוגמה, אם ה-bindings מקצים 50 תפקידים שונים ל-user:alice@example.com, ולא לחשבון משתמש אחר, תוכלו להוסיף עוד 1,450 חשבונות משתמשים ל-bindings ב-Policy.
השדה etag משמש לבקרת בו-זמניות אופטימיסטית, כדי למנוע מצב שבו עדכונים בו-זמניים של מדיניות יחליפו אחד את השני. מומלץ מאוד שהמערכות ישתמשו ב-etag במחזור הקריאה-שינוי-כתיבה כדי לבצע עדכוני מדיניות, כדי למנוע תנאי תחרות: etag מוחזר בתגובה ל-getIamPolicy, והמערכות אמורות להוסיף את תג ה-etag הזה לבקשה ל-setIamPolicy כדי לוודא שהשינוי שלהן יחול על אותה גרסת המדיניות.
חשוב: אם משתמשים בתנאים של IAM, צריך לכלול את השדה etag בכל קריאה ל-setIamPolicy. אם משמיטים את השדה הזה, IAM מאפשר להחליף את מדיניות הגרסה 3 במדיניות הגרסה 1, וכל התנאים במדיניות הגרסה 3 אבדו.
התפקיד שהוקצה לרשימת members, או לחשבונות המשתמשים. לדוגמה, roles/viewer, roles/editor או roles/owner.
סקירה כללית על התפקידים וההרשאות ב-IAM מופיעה במסמכי העזרה של IAM. כאן תוכלו למצוא רשימה של התפקידים המוגדרים מראש שזמינים.
members[]
string
חשבונות המשתמשים שמבקשים גישה למשאב ב-Google Cloud. members יכול לקבל את הערכים הבאים:
allUsers: מזהה מיוחד שמייצג את כל מי שמשתמש באינטרנט, עם או בלי חשבון Google.
allAuthenticatedUsers: מזהה מיוחד שמייצג כל מי שאומת באמצעות חשבון Google או חשבון שירות. לא כולל זהויות שמגיעות מספקי זהויות חיצוניים (IdPs) דרך איחוד שירותי אימות הזהות.
user:{emailid}: כתובת אימייל שמייצגת חשבון Google ספציפי. לדוגמה, alice@example.com .
serviceAccount:{emailid}: כתובת אימייל שמייצגת חשבון שירות של Google. לדוגמה, my-other-app@appspot.gserviceaccount.com.
serviceAccount:{projectid}.svc.id.goog[{namespace}/{kubernetes-sa}]: מזהה של חשבון שירות ב-Kubernetes. לדוגמה, my-project.svc.id.goog[my-namespace/my-kubernetes-sa].
group:{emailid}: כתובת אימייל שמייצגת קבוצה ב-Google. לדוגמה, admins@example.com.
domain:{domain}: דומיין G Suite (ראשי) שמייצג את כל המשתמשים בדומיין הזה. לדוגמה, google.com או example.com.
principal://iam.googleapis.com/locations/global/workforcePools/{pool_id}/subject/{subject_attribute_value}: זהות יחידה במאגר זהויות של כוח עבודה.
principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/group/{groupId}: כל הזהויות של כוח העבודה בקבוצה.
principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/attribute.{attribute_name}/{attribute_value}: כל הזהויות של כוח העבודה עם ערך מאפיין ספציפי.
principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/*: כל הזהויות במאגר זהויות של כוח עבודה.
principal://iam.googleapis.com/projects/{projectNumber}/locations/global/workloadIdentityPools/{pool_id}/subject/{subject_attribute_value}: זהות אחת במאגר זהויות של כוח עבודה.
principalSet://iam.googleapis.com/projects/{projectNumber}/locations/global/workloadIdentityPools/{pool_id}/group/{groupId}: קבוצה במאגר הזהויות של כוח העבודה.
principalSet://iam.googleapis.com/projects/{projectNumber}/locations/global/workloadIdentityPools/{pool_id}/attribute.{attribute_name}/{attribute_value}: כל הזהויות במאגר זהויות של כוח עבודה עם מאפיין מסוים.
principalSet://iam.googleapis.com/projects/{projectNumber}/locations/global/workloadIdentityPools/{pool_id}/*: כל הזהויות במאגר הזהויות של כוח העבודה.
deleted:user:{emailid}?uid={uniqueid}: כתובת אימייל (פלוס מזהה ייחודי) שמייצגת משתמש שנמחק לאחרונה. לדוגמה, alice@example.com?uid=123456789012345678901. אם המשתמש יתאושש, הערך הזה יחזור ל-user:{emailid} והמשתמש שחזר ישמור על התפקיד בקישור.
deleted:serviceAccount:{emailid}?uid={uniqueid}: כתובת אימייל (פלוס מזהה ייחודי) שמייצגת חשבון שירות שנמחק לאחרונה. לדוגמה, my-other-app@appspot.gserviceaccount.com?uid=123456789012345678901. אם מבטלים את המחיקה של חשבון השירות, הערך הזה חוזר לערך serviceAccount:{emailid} וחשבון השירות שלא נמחק שומר על התפקיד בקישור.
deleted:group:{emailid}?uid={uniqueid}: כתובת אימייל (פלוס מזהה ייחודי) שמייצגת קבוצת Google שנמחקה לאחרונה. לדוגמה, admins@example.com?uid=123456789012345678901. אם הקבוצה תתאושש, הערך הזה יחזור ל-group:{emailid} והקבוצה המשוחזרת תמשיך לשמור על התפקיד שלה בקישור.
deleted:principal://iam.googleapis.com/locations/global/workforcePools/{pool_id}/subject/{subject_attribute_value}: זהות יחידה שנמחקה במאגר זהויות של כוח עבודה. לדוגמה, deleted:principal://iam.googleapis.com/locations/global/workforcePools/my-pool-id/subject/my-subject-attribute-value.
אם התנאי מקבל את הערך true, הקישור הזה חל על הבקשה הנוכחית.
אם התנאי מקבל את הערך false, הקישור הזה לא חל על הבקשה הנוכחית. עם זאת, קישור תפקידים אחר עשוי להקצות את אותו תפקיד לחשבון משתמש אחד או יותר בקישור הזה.
מייצג ביטוי טקסטואלי בסינטקס של Common Expression Language (CEL). CEL היא שפת ביטויים שדומה ל-C. התחביר והסמנטיקה של CEL מתועדים בכתובת https://github.com/google/cel-spec.
דוגמה (השוואה):
title: "Summary size limit"
description: "Determines if a summary is less than 100 chars"
expression: "document.summary.size() < 100"
דוגמה (שוויון):
title: "Requestor is owner"
description: "Determines if requestor is the document owner"
expression: "document.owner == request.auth.claims.email"
דוגמה (לוגיקה):
title: "Public documents"
description: "Determine whether the document should be publicly visible"
expression: "document.type != 'private' && document.type != 'internal'"
דוגמה (מניפולציה של נתונים):
title: "Notification string"
description: "Create a notification string with a timestamp."
expression: "'New message received at ' + string(document.create_time)"
המשתנים והפונקציות הספציפיים שאפשר להפנות אליהם בתוך ביטוי נקבעים על ידי השירות שמעריך אותו. מידע נוסף זמין במסמכי התיעוד של השירות.
ייצוג טקסטואלי של ביטוי בתחביר של Common Expression Language.
title
string
זה שינוי אופציונלי. כותרת לביטוי, כלומר מחרוזת קצרה שמתארת את המטרה שלו. אפשר להשתמש באפשרות הזו, למשל, בממשקי משתמש שמאפשרים להזין את הביטוי.
description
string
זה שינוי אופציונלי. תיאור הביטוי. זהו טקסט ארוך יותר שמתאר את הביטוי, למשל כשמעבירים מעליו את העכבר בממשק המשתמש.
location
string
זה שינוי אופציונלי. מחרוזת שמציינת את המיקום של הביטוי לדיווח על שגיאות, למשל שם קובץ ומיקום בקובץ.
AuditConfig
הגדרת הביקורת של שירות. ההגדרה קובעת אילו סוגי הרשאות יירשמו ביומן, ואילו זהויות, אם בכלל, פטורות מהרשמה ביומן. אובייקט AuditConfig חייב לכלול לפחות אובייקט AuditLogConfig אחד.
אם יש הגדרות AuditConfig גם ל-allServices וגם לשירות ספציפי, האיחוד של שתי הגדרות AuditConfig ישמש את השירות הזה: סוגי היומנים (log_types) שצוינו בכל הגדרת AuditConfig יופעלו, והחברי-הקבוצה שמוגדרים כפטורים (exemptedMembers) בכל הגדרת AuditLogConfig יהיו פטורים.
ב-sampleservice, המדיניות הזו מפעילה את הרישום ביומן של DATA_READ, DATA_WRITE ו-ADMIN_READ. הוא גם פטורה את jose@example.com מרישום ביומן של DATA_READ ואת aliya@example.com מרישום ביומן של DATA_WRITE.
[[["התוכן קל להבנה","easyToUnderstand","thumb-up"],["התוכן עזר לי לפתור בעיה","solvedMyProblem","thumb-up"],["סיבה אחרת","otherUp","thumb-up"]],[["התוכן קשה להבנה","hardToUnderstand","thumb-down"],["שגיאות בקוד לדוגמה או במידע","incorrectInformationOrSampleCode","thumb-down"],["חסרים לי פרטים או דוגמאות","missingTheInformationSamplesINeed","thumb-down"],["בעיה בתרגום","translationIssue","thumb-down"],["סיבה אחרת","otherDown","thumb-down"]],["עדכון אחרון: 2025-06-09 (שעון UTC)."],[[["\u003cp\u003eIAM policies manage access control for Google Cloud resources through a collection of bindings.\u003c/p\u003e\n"],["\u003cp\u003eA binding in an IAM policy links one or more principals (members) to a single role, with principals including user accounts, service accounts, Google groups, and domains.\u003c/p\u003e\n"],["\u003cp\u003eIAM policies can also contain a condition, which is a logical expression that must evaluate to true for the binding to apply, enabling constraint-based access.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eetag\u003c/code\u003e field in the policy JSON is crucial for optimistic concurrency control, especially when using IAM Conditions, to prevent simultaneous updates from overwriting each other.\u003c/p\u003e\n"],["\u003cp\u003eAudit configurations (\u003ccode\u003eauditConfigs\u003c/code\u003e) within an IAM policy allow for specifying which types of permissions are logged, and can also list exempted members for specific types of logging.\u003c/p\u003e\n"]]],[],null,["# Policy\n\n- [JSON representation](#SCHEMA_REPRESENTATION)\n- [Binding](#Binding)\n - [JSON representation](#Binding.SCHEMA_REPRESENTATION)\n- [Expr](#Expr)\n - [JSON representation](#Expr.SCHEMA_REPRESENTATION)\n- [AuditConfig](#AuditConfig)\n - [JSON representation](#AuditConfig.SCHEMA_REPRESENTATION)\n- [AuditLogConfig](#AuditLogConfig)\n - [JSON representation](#AuditLogConfig.SCHEMA_REPRESENTATION)\n- [LogType](#LogType)\n\nAn Identity and Access Management (IAM) policy, which specifies access controls for Google Cloud resources.\n\nA `Policy` is a collection of `bindings`. A `binding` binds one or more `members`, or principals, to a single `role`. Principals can be user accounts, service accounts, Google groups, and domains (such as G Suite). A `role` is a named list of permissions; each `role` can be an IAM predefined role or a user-created custom role.\n\nFor some types of Google Cloud resources, a `binding` can also specify a `condition`, which is a logical expression that allows access to a resource only if the expression evaluates to `true`. A condition can add constraints based on attributes of the request, the resource, or both. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).\n\n**JSON example:** \n\n {\n \"bindings\": [\n {\n \"role\": \"roles/resourcemanager.organizationAdmin\",\n \"members\": [\n \"user:mike@example.com\",\n \"group:admins@example.com\",\n \"domain:google.com\",\n \"serviceAccount:my-project-id@appspot.gserviceaccount.com\"\n ]\n },\n {\n \"role\": \"roles/resourcemanager.organizationViewer\",\n \"members\": [\n \"user:eve@example.com\"\n ],\n \"condition\": {\n \"title\": \"expirable access\",\n \"description\": \"Does not grant access after Sep 2020\",\n \"expression\": \"request.time \u003c timestamp('2020-10-01T00:00:00.000Z')\",\n }\n }\n ],\n \"etag\": \"BwWWja0YfJA=\",\n \"version\": 3\n }\n\n**YAML example:** \n\n bindings:\n - members:\n - user:mike@example.com\n - group:admins@example.com\n - domain:google.com\n - serviceAccount:my-project-id@appspot.gserviceaccount.com\n role: roles/resourcemanager.organizationAdmin\n - members:\n - user:eve@example.com\n role: roles/resourcemanager.organizationViewer\n condition:\n title: expirable access\n description: Does not grant access after Sep 2020\n expression: request.time \u003c timestamp('2020-10-01T00:00:00.000Z')\n etag: BwWWja0YfJA=\n version: 3\n\nFor a description of IAM and its features, see the [IAM documentation](https://cloud.google.com/iam/docs/).\n\nBinding\n-------\n\nAssociates `members`, or principals, with a `role`.\n\nExpr\n----\n\nRepresents a textual expression in the Common Expression Language (CEL) syntax. CEL is a C-like expression language. The syntax and semantics of CEL are documented at \u003chttps://github.com/google/cel-spec\u003e.\n\nExample (Comparison): \n\n title: \"Summary size limit\"\n description: \"Determines if a summary is less than 100 chars\"\n expression: \"document.summary.size() \u003c 100\"\n\nExample (Equality): \n\n title: \"Requestor is owner\"\n description: \"Determines if requestor is the document owner\"\n expression: \"document.owner == request.auth.claims.email\"\n\nExample (Logic): \n\n title: \"Public documents\"\n description: \"Determine whether the document should be publicly visible\"\n expression: \"document.type != 'private' && document.type != 'internal'\"\n\nExample (Data Manipulation): \n\n title: \"Notification string\"\n description: \"Create a notification string with a timestamp.\"\n expression: \"'New message received at ' + string(document.create_time)\"\n\nThe exact variables and functions that may be referenced within an expression are determined by the service that evaluates it. See the service documentation for additional information.\n\nAuditConfig\n-----------\n\nSpecifies the audit configuration for a service. The configuration determines which permission types are logged, and what identities, if any, are exempted from logging. An AuditConfig must have one or more AuditLogConfigs.\n\nIf there are AuditConfigs for both `allServices` and a specific service, the union of the two AuditConfigs is used for that service: the log_types specified in each AuditConfig are enabled, and the exemptedMembers in each AuditLogConfig are exempted.\n\nExample Policy with multiple AuditConfigs: \n\n {\n \"auditConfigs\": [\n {\n \"service\": \"allServices\",\n \"auditLogConfigs\": [\n {\n \"logType\": \"DATA_READ\",\n \"exemptedMembers\": [\n \"user:jose@example.com\"\n ]\n },\n {\n \"logType\": \"DATA_WRITE\"\n },\n {\n \"logType\": \"ADMIN_READ\"\n }\n ]\n },\n {\n \"service\": \"sampleservice.googleapis.com\",\n \"auditLogConfigs\": [\n {\n \"logType\": \"DATA_READ\"\n },\n {\n \"logType\": \"DATA_WRITE\",\n \"exemptedMembers\": [\n \"user:aliya@example.com\"\n ]\n }\n ]\n }\n ]\n }\n\nFor sampleservice, this policy enables DATA_READ, DATA_WRITE and ADMIN_READ logging. It also exempts `jose@example.com` from DATA_READ logging, and `aliya@example.com` from DATA_WRITE logging.\n\nAuditLogConfig\n--------------\n\nProvides the configuration for logging a type of permissions. Example: \n\n {\n \"auditLogConfigs\": [\n {\n \"logType\": \"DATA_READ\",\n \"exemptedMembers\": [\n \"user:jose@example.com\"\n ]\n },\n {\n \"logType\": \"DATA_WRITE\"\n }\n ]\n }\n\nThis enables 'DATA_READ' and 'DATA_WRITE' logging, while exempting [jose@example.com](mailto:jose@example.com) from DATA_READ logging.\n\nLogType\n-------\n\nThe list of valid permission types for which logging can be configured. Admin writes are always logged, and are not configurable."]]