Per informazioni dettagliate sulla creazione di espressioni in Common Expression Language (CEL) per i livelli di accesso personalizzati, consulta la specifica del livello di accesso personalizzato.
Console
Per creare un livello di accesso personalizzato:
Apri la pagina Gestore contesto accesso nella Google Cloud console.
Se ti viene chiesto, seleziona la tua organizzazione.
Nella parte superiore della pagina Gestore contesto accesso, fai clic su Nuovo.
Nel riquadro Nuovo livello di accesso:
Nella casella Titolo livello di accesso, inserisci un titolo per il livello di accesso.
Il titolo deve contenere al massimo 50 caratteri, deve iniziare con una lettera e può contenere solo numeri, lettere, trattini bassi e spazi.
In Crea condizioni in, seleziona Modalità avanzata.
Nella sezione Condizioni, inserisci le espressioni per il livello di accesso personalizzato. La condizione deve risolvere in un singolo valore booleano.
LEVEL_NAME è un nome univoco per il livello di accesso. Deve iniziare con una lettera e includere solo lettere, numeri e trattini bassi. Il nome può contenere un massimo di 50 caratteri.
TITLE è il titolo breve e leggibile del livello di accesso.
FILE è un file .yaml che contiene l'espressione CEL formattata come una singola coppia chiave-valore:expression: "CEL_EXPRESSION".
Per esempi e ulteriori informazioni sul supporto del linguaggio CEL (Common Expression Language) e sui livelli di accesso personalizzati, consulta le specifiche del livello di accesso personalizzato.
DESCRIPTION (facoltativo) è una descrizione leggibile del livello di accesso.
POLICY_NAME è il nome numerico delle norme di accesso della tua organizzazione.
Quando utilizzi lo strumento a riga di comando gcloud per creare un livello di accesso personalizzato, devi fornire un file .yaml per l'opzione custom-level-spec. Il file .yaml definisce un'espressione CEL che risolve in un singolo valore booleano. Il file .yaml deve contenere una singola coppia chiave-valore formattata come expression: "CEL_EXPRESSION". Il valore di expression deve essere una stringa.
File YAML di esempio
expression:"device.encryption_status == DeviceEncryptionStatus.ENCRYPTED && (origin.region_code in ['US'] || device.is_admin_approved_device)"
Comando di esempio
gcloudaccess-context-managerlevelscreateCustom_Trust\--custom-level-spec=customspec.yaml\--description="Custom access level for corp."\--title="Custom Trust Level"\--policy=1521580097614100
Per il campo custom, crea un oggetto che includa le espressioni CEL per il tuo livello di accesso personalizzato. L'espressione completa deve risolvere in un valore booleano. I campi title e description sono facoltativi.
Esempio
{"name":"example_custom_level","title":"Example custom level","description":"An example custom access level.","custom":{"expr":{"expression":"device.is_corp_owned == true || (device.os_type != OsType.OS_UNSPECIFIED && device.is_admin_approved_device == true)","title":"Check for known devices","description":"Permits requests from corp-owned devices and admin-approved devices with a known OS."}}}
Per creare un livello di accesso personalizzato, chiama
CreateAccessLevel.
Per il campo access_level, includi un'istanza di AccessLevel.
Campi
name
Tipo
string
Descrizione
Obbligatorio.
Il nome della risorsa per il livello di accesso. POLICY_ID è il nome numerico del criterio di accesso della tua organizzazione. SHORT_NAME
deve iniziare con una lettera e
deve includere solo lettere, numeri e trattini bassi.
Formato:
accessPolicies/policy_id/accessLevels/short_name
title
Tipo
string
Descrizione
Un'etichetta leggibile per il livello di accesso. I livelli di accesso
devono avere nomi univoci.
description
Tipo
string
Descrizione
Una descrizione del livello di accesso.
custom
Tipo
string
Descrizione
Le espressioni CEL per il tuo livello di accesso personalizzato. L'espressione completa deve risolvere in un valore booleano.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 UTC."],[[["\u003cp\u003eThis feature to create custom access levels is only available with a paid enterprise security subscription, which you can sign up for if interested.\u003c/p\u003e\n"],["\u003cp\u003eCustom access levels are created using Common Expression Language (CEL) expressions, and after they are created can be managed like basic access levels.\u003c/p\u003e\n"],["\u003cp\u003eCustom access levels can be created in the Google Cloud console by entering a title, selecting Advanced Mode, and entering CEL expressions.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003egcloud\u003c/code\u003e command-line tool allows for the creation of custom access levels using a \u003ccode\u003e.yaml\u003c/code\u003e file containing a single CEL expression.\u003c/p\u003e\n"],["\u003cp\u003eCustom access levels can also be created using REST and RPC methods by including an instance of the \u003ccode\u003eAccessLevel\u003c/code\u003e object, with the CEL expression, in the request.\u003c/p\u003e\n"]]],[],null,["# Creating a custom access level\n\n| **Note:** This feature is available only as part of a paid enterprise security subscription. You can [sign up](https://go.chronicle.security/beyondcorp-upgrade) if interested.\n\nAfter a custom access level is created, it can\nbe [managed in the same manner as basic access levels](/access-context-manager/docs/manage-access-levels).\n\nFor details about building Common Expression Language (CEL) expressions for\ncustom access levels, refer to the\n[custom access level specification](/access-context-manager/docs/custom-access-level-spec). \n\n### Console\n\nTo create a custom access level:\n\n1. Open the **Access Context Manager** page in the Google Cloud console.\n\n [Open the Access Context Manager page](https://console.cloud.google.com/security/access-level)\n2. If you are prompted, select your organization.\n\n3. At the top of the **Access Context Manager** page, click **New**.\n\n4. In the **New Access Level** pane:\n\n 1. In the **Access level title** box, enter a title for the access level.\n The title must be at most 50 characters, start with a letter, and can\n contain only numbers, letters, underscores, and spaces.\n\n 2. Following **Create Conditions in** , select **Advanced Mode**.\n\n 3. In the **Conditions** section, enter the expressions for your custom\n access level. The condition must resolve to a single boolean value.\n\n For examples and more information about Common Expression Language\n (CEL) support and custom access levels, see the [Custom access level\n specification](/access-context-manager/docs/custom-access-level-spec).\n 4. Click **Save**.\n\n### gcloud\n\n### Before you begin\n\n- If it doesn't exist yet, [create an access policy](/access-context-manager/docs/create-access-policy) for your organization.\n\nTo create a custom access level using the `gcloud` command-line tool, use the\n[`gcloud access-context-manager levels create`](/sdk/gcloud/reference/access-context-manager/levels/create) command. \n\n```bash\ngcloud access-context-manager levels create LEVEL_NAME \\\n --title=TITLE \\\n --custom-level-spec=FILE \\\n --description=DESCRIPTION \\\n --policy=POLICY_NAME\n```\n\nWhere:\n\n- \u003cvar translate=\"no\"\u003eLEVEL_NAME\u003c/var\u003e is a unique name for the access level. It must\n begin with a letter and include only letters, numbers, and\n underscores. The name can be a maximum of 50 characters.\n\n- \u003cvar translate=\"no\"\u003eTITLE\u003c/var\u003e is the short, human-readable title for the access\n level.\n\n- \u003cvar translate=\"no\"\u003eFILE\u003c/var\u003e is a .yaml file that contains your CEL expression\n formatted as a single key-value pair:\n `expression: \"`\u003cvar translate=\"no\"\u003eCEL_EXPRESSION\u003c/var\u003e`\"`.\n\n For examples and more information about Common Expression Language (CEL)\n support and custom access levels, see the\n [Custom access level specification](/access-context-manager/docs/custom-access-level-spec).\n- \u003cvar translate=\"no\"\u003eDESCRIPTION\u003c/var\u003e (optional) is a human-readable description of the\n access level.\n\n- \u003cvar translate=\"no\"\u003ePOLICY_NAME\u003c/var\u003e is the numeric name of your organization's\n access policy.\n\nOptionally, you can include any of the\n[`gcloud`-wide flags](/sdk/gcloud/reference).\n\n### `custom-level-spec` YAML file\n\nWhen you use the `gcloud` command-line tool to create a custom access level, you must provide\na .yaml file for the `custom-level-spec` option. The .yaml file defines\na CEL expression that resolves to a single boolean value. The .yaml file\nmust contain a single key-value pair formatted as\n`expression: \"`\u003cvar translate=\"no\"\u003eCEL_EXPRESSION\u003c/var\u003e`\"`. The value for `expression` must\nbe a string.\n\n#### Example YAML file\n\n expression: \"device.encryption_status == DeviceEncryptionStatus.ENCRYPTED && (origin.region_code in ['US'] || device.is_admin_approved_device)\"\n\n### Example command\n\n gcloud access-context-manager levels create Custom_Trust \\\n --custom-level-spec=customspec.yaml \\\n --description=\"Custom access level for corp.\" \\\n --title=\"Custom Trust Level\" \\\n --policy=1521580097614100\n\n### REST\n\n### Before you begin\n\n- If it doesn't exist yet, [create an access policy](/access-context-manager/docs/create-access-policy) for your organization.\n\nTo create a custom access level, use the\n[`accessPolicies.accessLevels.create`](/access-context-manager/docs/reference/rest/v1/accessPolicies.accessLevels/create)\nmethod.\n\nRequest body\n------------\n\nIn the request body for the call, include an instance of the `AccessLevel`\nobject. \n\n {\n \"name\": string,\n \"title\": string,\n \"description\": string,\n \"custom\": {\n \"expr\": {\n \"expression\": string,\n \"title\": string,\n \"description\": string\n }\n }\n }\n\nFor the `custom` field, create an object that includes the CEL expressions\nfor your custom access level. The complete expression must resolve to a\nboolean value. The `title` and `description` fields are optional.\n\n### Example\n\n {\n \"name\": \"example_custom_level\",\n \"title\": \"Example custom level\",\n \"description\": \"An example custom access level.\",\n \"custom\": {\n \"expr\": {\n \"expression\": \"device.is_corp_owned == true || (device.os_type != OsType.OS_UNSPECIFIED && device.is_admin_approved_device == true)\",\n \"title\": \"Check for known devices\",\n \"description\": \"Permits requests from corp-owned devices and admin-approved devices with a known OS.\"\n }\n }\n }\n\n### RPC\n\n### Before you begin\n\n- If it doesn't exist yet, [create an access policy](/access-context-manager/docs/create-access-policy) for your organization.\n\nTo create a custom access level, call\n[`CreateAccessLevel`](/access-context-manager/docs/reference/rpc/google.identity.accesscontextmanager.v1#accesscontextmanager).\n\nFor the `access_level` field, include an instance of `AccessLevel`."]]