Kiểm soát quyền truy cập mạng vào tính năng Trợ giúp lập trình của Gemini bằng các quy định hạn chế về miền của người dùng
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Tài liệu này cung cấp hướng dẫn cho quản trị viên mạng để định cấu hình mạng nhằm hạn chế quyền truy cập vào Gemini Code Assist dựa trên miền của người dùng. Tính năng này cho phép các tổ chức kiểm soát những người dùng trong mạng của họ có thể sử dụng Gemini Code Assist, giúp tăng cường bảo mật và ngăn chặn truy cập trái phép.
Tổng quan
Bạn có thể định cấu hình Gemini Code Assist để thực thi các hạn chế về miền của người dùng bằng cách sử dụng phương pháp proxy Người trung gian (PITM). Việc này liên quan đến việc chèn một tiêu đề HTTP tuỳ chỉnh (X-GeminiCodeAssist-Allowed-Domains
) vào các yêu cầu được gửi đến Gemini Code Assist. Tiêu đề này chỉ định một danh sách các miền được phép và phần phụ trợ Gemini Code Assist chỉ xử lý các yêu cầu từ những người dùng có miền đã xác thực khớp với một trong các miền được phép.
Để định cấu hình một proxy trong IDE, hãy làm theo các bước sau:
VS Code
Chuyển đến File > Settings (Tệp > Cài đặt) (đối với Windows) hoặc Code > Settings > Settings (Mã > Cài đặt > Cài đặt) (đối với macOS).
Trong thẻ User (Người dùng), hãy chuyển đến Application (Ứng dụng) > Proxy (Uỷ quyền).
Trong hộp bên dưới mục Proxy, hãy nhập địa chỉ của máy chủ proxy. Ví dụ: http://localhost:3128
.
Không bắt buộc: Để định cấu hình Gemini Code Assist bỏ qua lỗi chứng chỉ, trong phần Proxy Strict SSL (Proxy SSL nghiêm ngặt), hãy chọn hoặc bỏ chọn hộp đánh dấu. Chế độ cài đặt này áp dụng cho tất cả các hồ sơ.
IntelliJ
Chuyển đến mục File > Settings (Tệp > Cài đặt) (đối với Windows) hoặc IntelliJ IDEA > Settings (IntelliJ IDEA > Cài đặt) (đối với macOS).
Chuyển đến phần Appearance & Behavior (Giao diện và hành vi) > System Settings (Cài đặt hệ thống) > HTTP Proxy (Proxy HTTP).
Chọn Cấu hình proxy thủ công, rồi chọn HTTP.
Trong trường Tên máy chủ, hãy nhập tên máy chủ của máy chủ proxy.
Trong trường Số cổng, hãy nhập số cổng của máy chủ proxy.
Không bắt buộc: Để định cấu hình Gemini Code Assist bỏ qua lỗi chứng chỉ, trong thanh bên, hãy nhấp vào Tools (Công cụ) > Server Certificates (Chứng chỉ máy chủ), sau đó chọn hoặc bỏ chọn Accept non-trusted certificates automatically (Tự động chấp nhận chứng chỉ không đáng tin cậy).
Để định cấu hình proxy PITM, hãy làm theo các bước sau:
Đảm bảo rằng mạng của bạn sử dụng một proxy PITM có khả năng chặn và sửa đổi lưu lượng truy cập HTTPS.
Định cấu hình proxy để chặn tất cả các yêu cầu gửi đi đến điểm cuối Gemini Code Assist (https://cloudcode-pa.googleapis.com
). Không dùng ký tự đại diện (*
) khi bạn chỉ định điểm cuối Gemini Code Assist.
Định cấu hình proxy để chèn tiêu đề X-GeminiCodeAssist-Allowed-Domains
vào mỗi yêu cầu. Tiêu đề phải chứa một danh sách các miền được phép phân tách bằng dấu phẩy (ví dụ: example.com
, yourcompany.net
).
Đảm bảo rằng tên miền được phân tách bằng dấu phẩy và không có biểu tượng @
.
Nếu tiêu đề không được phân giải thành ít nhất một miền hợp lệ, thì các quy tắc hạn chế sẽ không áp dụng. Ví dụ: tiêu đề trống sẽ không áp dụng bất kỳ hạn chế nào.
domain
sẽ không áp dụng bất kỳ hạn chế nào vì đây không phải là tên miền hợp lệ.
Khi người dùng cố gắng truy cập vào Gemini Code Assist từ một miền không có trong danh sách tiêu đề, họ sẽ thấy một thông báo cho biết quản trị viên đã hạn chế họ sử dụng Gemini Code Assist trên miền của họ.
Chặn SSL/TLS
Nếu proxy của bạn cần giải mã lưu lượng truy cập HTTPS để chèn tiêu đề, hãy đảm bảo rằng proxy được định cấu hình để chặn SSL/TLS. Việc này thường bao gồm:
Gemini Code Assist tự động xác thực tiêu đề X-GeminiCodeAssist-Allowed-Domains
và thực thi các quy định hạn chế.
Nếu tiêu đề không phân giải thành ít nhất một miền hợp lệ, thì quá trình xác thực sẽ không được thực hiện.
Nếu miền liên kết với hoạt động xác thực của người dùng không có trong danh sách cho phép, thì yêu cầu sẽ bị từ chối. Ví dụ: nếu người dùng đăng nhập bằng tài khoản gmail và chỉ example.com có trong danh sách cho phép, thì yêu cầu sẽ bị từ chối.
Bước tiếp theo
Để tìm hiểu thêm về cách chặn quyền truy cập vào tài khoản người dùng cá nhân, hãy xem bài viết Chặn quyền truy cập vào tài khoản người dùng cá nhân.
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-08-31 UTC.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-08-31 UTC."],[[["\u003cp\u003eNetwork administrators can restrict access to Gemini Code Assist based on user domains via a Person-in-the-Middle (PITM) proxy.\u003c/p\u003e\n"],["\u003cp\u003eA custom HTTP header, \u003ccode\u003eX-GeminiCodeAssist-Allowed-Domains\u003c/code\u003e, is injected into requests to specify a comma-separated list of allowed domains.\u003c/p\u003e\n"],["\u003cp\u003eThe PITM proxy must intercept HTTPS traffic and be configured to inject the custom header into each request.\u003c/p\u003e\n"],["\u003cp\u003eGemini Code Assist validates the \u003ccode\u003eX-GeminiCodeAssist-Allowed-Domains\u003c/code\u003e header, rejecting requests from users whose domains are not on the allowed list.\u003c/p\u003e\n"],["\u003cp\u003eIf the header doesn't resolve to at least one valid domain, then the validation won't be performed, meaning restrictions will not apply.\u003c/p\u003e\n"]]],[],null,["# Control Network Access to Gemini Code Assist with User Domain Restrictions\n\nThis document provides instructions for network administrators to configure\ntheir networks to restrict access to Gemini Code Assist based on\nuser domains. This feature allows organizations to control which users within\ntheir network can utilize Gemini Code Assist, enhancing security\nand preventing unauthorized access.\n\nOverview\n--------\n\nYou can configure Gemini Code Assist to enforce user domain\nrestrictions using a Person-in-the-Middle (PITM) proxy approach. This involves\ninjecting a custom HTTP header,\n`X-GeminiCodeAssist-Allowed-Domains`, into requests made to\nGemini Code Assist. The header specifies a list of allowed\ndomains, and the Gemini Code Assist backend only processes\nrequests from users whose authenticated domain matches one of the allowed\ndomains.\n\nConfigure a proxy in your IDE\n-----------------------------\n\nTo configure a proxy in your IDE, follow these steps: \n\n### VS Code\n\n1. Navigate to **File** \\\u003e **Settings** (for Windows), or **Code**\n \\\u003e **Settings** \\\u003e **Settings** (for macOS).\n\n2. In the **User** tab, navigate to **Application** \\\u003e **Proxy**.\n\n3. In the box under **Proxy** , enter the address of your proxy server. For\n example `http://localhost:3128`.\n\n4. Optional: To configure Gemini Code Assist to ignore\n certificate errors, under **Proxy Strict SSL**, select or deselect the\n checkbox. This setting applies to all profiles.\n\n### IntelliJ\n\n1. Navigate to **File** \\\u003e **Settings** (for Windows) or **IntelliJ\n IDEA** \\\u003e **Settings** (for macOS).\n\n2. Navigate to **Appearance \\& Behavior** \\\u003e **System Settings**\n \\\u003e **HTTP Proxy**.\n\n3. Select **Manual proxy configuration** , and then select **HTTP**.\n\n4. In the **Host name** field, enter the hostname of your proxy server.\n\n5. In the **Port number** field, enter the port number of your proxy server.\n\n6. Optional: To configure Gemini Code Assist to ignore\n certificate errors, in the sidebar, click **Tools** \\\u003e **Server\n Certificates** and then select or deselect **Accept non-trusted certificates\n automatically**.\n\nConfigure PITM proxy\n--------------------\n\nTo configure your PITM proxy, follow these steps:\n\n1. Make sure your network utilizes a PITM proxy capable of intercepting and\n modifying HTTPS traffic.\n\n2. Configure the proxy to intercept all outgoing requests to the\n Gemini Code Assist endpoint\n (`https://cloudcode-pa.googleapis.com`). Don't use wildcards (`*`) when you\n specify the Gemini Code Assist endpoint.\n\n3. Configure the proxy to inject the `X-GeminiCodeAssist-Allowed-Domains`\n header into each request. The header should contain a comma-separated list\n of allowed domains (e.g., `example.com`, `yourcompany.net`).\n Make sure that domain names are separated by commas and\n don't include the `@` symbol.\n\n If headers aren't resolved into at least one valid domain, restrictions\n won't apply. For example, an empty header won't apply any restrictions.\n `domain` won't apply any restrictions as it isn't a valid domain name.\n\nWhen a user tries to access Gemini Code Assist from a domain not\nincluded in the header list, they see a message telling them that they're\nrestricted from using Gemini Code Assist on their domain by their\nadministrator.\n\nSSL/TLS interception\n--------------------\n\nIf your proxy needs to decrypt HTTPS traffic to inject the header, make sure\nit's configured for SSL/TLS interception. This typically involves:\n\n- Generating a certificate for the proxy.\n\n- Installing the proxy's certificate on user devices to establish trust and\n avoid certificate errors.\n\nHeader validation\n-----------------\n\n- Gemini Code Assist automatically validates the\n `X-GeminiCodeAssist-Allowed-Domains` header and enforces the restrictions.\n\n- If the header doesn't resolve to at least one valid domain, the validation\n won't be performed.\n\n- If the domain associated with the user's authentication isn't in the allowed\n list, the request is rejected. For example if the user logs in with a gmail\n account and only example.com is on the allowed list, the request is rejected.\n\nWhat's next\n-----------\n\nTo learn more about blocking access to consumer accounts, see\n[Block access to consumer accounts](https://support.google.com/a/answer/1668854)."]]