Code Velocity
เครื่องมือสำหรับนักพัฒนา

การรับรองความถูกต้องของ Codex: การรักษาความปลอดภัยการเข้าถึง OpenAI สำหรับนักพัฒนา

·5 นาทีอ่าน·OpenAI·แหล่งที่มา
แชร์
กระบวนการรับรองความถูกต้องของ OpenAI Codex ที่แสดงตัวเลือกการลงชื่อเข้าใช้และมาตรการรักษาความปลอดภัยต่างๆ สำหรับนักพัฒนา

การปรับปรุงการรับรองความถูกต้องของ Codex: คู่มือสำหรับนักพัฒนา

Codex ของ OpenAI ซึ่งเป็นโมเดล AI ที่ทรงพลังสำหรับการสร้างความเข้าใจโค้ด ได้กลายเป็นเครื่องมือที่ขาดไม่ได้สำหรับนักพัฒนา ด้วยความสามารถที่ขยายออกไปในอินเทอร์เฟซต่างๆ ไม่ว่าจะเป็นแอปพลิเคชันเฉพาะ, ส่วนเสริม IDE ไปจนถึงอินเทอร์เฟซบรรทัดคำสั่ง (CLI) การทำความเข้าใจกลไกการรับรองความถูกต้องของมันจึงเป็นสิ่งสำคัญสำหรับการผสานรวมเวิร์กโฟลว์ที่ปลอดภัยและมีประสิทธิภาพ บทความนี้จะเจาะลึกวิธีการรับรองความถูกต้องหลักสำหรับ Codex สำรวจความแตกต่าง, ผลกระทบด้านความปลอดภัย และแนวทางปฏิบัติที่ดีที่สุดสำหรับนักพัฒนาและผู้ดูแลระบบ

ไม่ว่าคุณกำลังมองหาการใช้ประโยชน์จาก Codex สำหรับการสร้างต้นแบบอย่างรวดเร็ว, การรวมเข้ากับไปป์ไลน์ CI/CD ของคุณ หรือการจัดการการปรับใช้ในสภาพแวดล้อมองค์กร การเรียนรู้กระบวนการ การรับรองความถูกต้องของ Codex คือขั้นตอนแรก

การเลือกวิธีการเข้าสู่ระบบ Codex ของคุณ: ChatGPT กับคีย์ API

OpenAI Codex มีสองเส้นทางการรับรองความถูกต้องที่แตกต่างกันเมื่อโต้ตอบกับโมเดล OpenAI ที่เป็นพื้นฐาน ซึ่งแต่ละเส้นทางได้รับการปรับแต่งสำหรับกรณีการใช้งานที่แตกต่างกันและให้ประโยชน์ที่ไม่เหมือนใคร:

  1. ลงชื่อเข้าใช้ด้วย ChatGPT: วิธีนี้จะเชื่อมโยงการใช้งาน Codex ของคุณกับการสมัครสมาชิก ChatGPT ที่มีอยู่ของคุณ เป็นการเข้าสู่ระบบที่จำเป็นสำหรับสภาพแวดล้อม Codex cloud และให้สิทธิ์การเข้าถึงคุณสมบัติเฉพาะ เช่น "โหมดเร็ว" ซึ่งพึ่งพาเครดิต ChatGPT เมื่อคุณรับรองความถูกต้องด้วยวิธีนี้ การใช้งานของคุณจะถูกควบคุมโดยสิทธิ์พื้นที่ทำงาน ChatGPT ของคุณ, การควบคุมการเข้าถึงตามบทบาท (RBAC) และการตั้งค่าการเก็บรักษาและถิ่นที่อยู่ของ ChatGPT Enterprise ที่คุณมี กระบวนการนี้มักจะเกี่ยวข้องกับการล็อกอินผ่านเบราว์เซอร์ โดยจะนำคุณไปยังการรับรองความถูกต้องให้เสร็จสิ้นก่อนที่จะส่งคืนโทเค็นการเข้าถึงไปยังไคลเอ็นต์ Codex ของคุณ (แอป, CLI หรือส่วนเสริม IDE)

  2. ลงชื่อเข้าใช้ด้วยคีย์ API: สำหรับนักพัฒนาที่ต้องการการควบคุมการใช้งานและการเรียกเก็บเงินที่ละเอียดยิ่งขึ้น หรือสำหรับการเข้าถึงแบบโปรแกรม การลงชื่อเข้าใช้ด้วยคีย์ API เป็นเส้นทางที่แนะนำ คีย์ API ซึ่งสามารถรับได้จาก แดชบอร์ด OpenAI ของคุณ จะเชื่อมโยงการใช้งาน Codex ของคุณโดยตรงกับบัญชี OpenAI Platform ของคุณ การเรียกเก็บเงินจะเกิดขึ้นในอัตรา API มาตรฐาน และการจัดการข้อมูลจะปฏิบัติตามการตั้งค่าการเก็บรักษาและการแบ่งปันข้อมูลขององค์กร API ของคุณ วิธีนี้เหมาะอย่างยิ่งสำหรับเวิร์กโฟลว์อัตโนมัติ เช่น งาน Continuous Integration/Continuous Deployment (CI/CD) ซึ่งการโต้ตอบของผู้ใช้โดยตรงสำหรับการเข้าสู่ระบบไม่สะดวก อย่างไรก็ตาม คุณสมบัติที่ขึ้นอยู่กับเครดิต ChatGPT อาจไม่สามารถใช้งานได้ผ่านการรับรองความถูกต้องด้วยคีย์ API

เป็นสิ่งสำคัญที่ต้องทราบว่าแม้ CLI และส่วนเสริม IDE ของ Codex จะรองรับทั้งสองวิธี แต่ส่วนต่อประสาน Codex cloud กำหนดให้ต้องลงชื่อเข้าใช้ด้วย ChatGPT เท่านั้น

นี่คือการเปรียบเทียบโดยย่อของทั้งสองวิธี:

คุณสมบัติลงชื่อเข้าใช้ด้วย ChatGPTลงชื่อเข้าใช้ด้วยคีย์ API
กรณีการใช้งานหลักการใช้งานแบบโต้ตอบ, Codex cloud, คุณสมบัติการสมัครสมาชิกการเข้าถึงแบบโปรแกรม, CI/CD, การเรียกเก็บเงินตามการใช้งาน
รูปแบบการเรียกเก็บเงินการสมัครสมาชิก ChatGPT / เครดิตอัตรา API มาตรฐานของ OpenAI Platform
การกำกับดูแลข้อมูลสิทธิ์พื้นที่ทำงาน ChatGPT, RBAC, การตั้งค่า Enterpriseการตั้งค่าข้อมูลองค์กร OpenAI Platform API
คุณสมบัติเข้าถึง 'โหมดเร็ว' (เครดิต ChatGPT)เข้าถึง API ได้เต็มรูปแบบ, ไม่มี 'โหมดเร็ว' (ใช้ราคามาตรฐาน)
อินเทอร์เฟซที่รองรับแอป Codex, CLI, ส่วนเสริม IDE, Codex Cloudแอป Codex, CLI, ส่วนเสริม IDE (ไม่รวม Codex Cloud)
คำแนะนำด้านความปลอดภัยแนะนำให้ใช้ MFA อย่างยิ่ง, บังคับใช้ในบางกรณีห้ามเปิดเผยคีย์ API ในสภาพแวดล้อมที่ไม่น่าเชื่อถือ

การรักษาความปลอดภัยบัญชี Codex Cloud ของคุณด้วย MFA

เนื่องจาก Codex มีปฏิสัมพันธ์โดยตรงกับฐานข้อมูลโค้ดของคุณ ความต้องการด้านความปลอดภัยของมันมักจะเกินกว่าคุณสมบัติอื่นๆ ของ ChatGPT การยืนยันตัวตนแบบหลายปัจจัย (MFA) เป็นมาตรการป้องกันที่สำคัญสำหรับบัญชี Codex cloud ของคุณ

หากคุณใช้ผู้ให้บริการล็อกอินโซเชียล (เช่น Google, Microsoft, Apple) คุณสามารถและควรเปิดใช้งาน MFA ผ่านการตั้งค่าความปลอดภัยที่เกี่ยวข้อง สำหรับผู้ใช้ที่เข้าสู่ระบบด้วยอีเมลและรหัสผ่าน การตั้งค่า MFA บนบัญชีของคุณเป็นสิ่งจำเป็นก่อนที่คุณจะสามารถเข้าถึง Codex cloud ได้ แม้ว่าบัญชีของคุณจะรองรับวิธีการเข้าสู่ระบบหลายวิธี และหนึ่งในนั้นคืออีเมล/รหัสผ่าน คุณต้องกำหนดค่า MFA

ผู้ใช้ระดับองค์กรที่ได้รับประโยชน์จาก Single Sign-On (SSO) ควรพึ่งพาผู้ดูแลระบบ SSO ขององค์กรเพื่อบังคับใช้ MFA สำหรับผู้ใช้ทุกคน สร้างความมั่นคงและมาตรการรักษาความปลอดภัยที่แข็งแกร่งทั่วทั้งองค์กร มาตรการเชิงรุกนี้ช่วยลดความเสี่ยงของการเข้าถึงสภาพแวดล้อมการพัฒนาและทรัพย์สินทางปัญญาของคุณโดยไม่ได้รับอนุญาตได้อย่างมาก

การจัดการการแคชการเข้าสู่ระบบและการจัดเก็บข้อมูลรับรอง

เพื่อความสะดวกของผู้ใช้ Codex จะแคชรายละเอียดการเข้าสู่ระบบของคุณในเครื่อง ไม่ว่าคุณจะลงชื่อเข้าใช้ด้วย ChatGPT หรือคีย์ API แอปพลิเคชัน Codex, CLI และส่วนเสริม IDE จะใช้ข้อมูลรับรองที่แคชไว้ร่วมกัน ซึ่งหมายความว่าเมื่อรับรองความถูกต้องแล้ว โดยทั่วไปคุณไม่จำเป็นต้องลงชื่อเข้าใช้ซ้ำสำหรับเซสชันถัดไป อย่างไรก็ตาม การออกจากระบบจากอินเทอร์เฟซหนึ่งจะทำให้เซสชันที่ใช้ร่วมกันไม่ถูกต้อง ทำให้ต้องมีการรับรองความถูกต้องอีกครั้ง

Codex จัดเก็บข้อมูลรับรองเหล่านี้ไว้ในหนึ่งในสองตำแหน่ง:

  • ไฟล์ข้อความธรรมดาที่ ~/.codex/auth.json (หรือไดเรกทอรี CODEX_HOME)
  • ที่เก็บข้อมูลรับรองดั้งเดิมของระบบปฏิบัติการของคุณ

คุณสามารถกำหนดค่าตำแหน่งที่ Codex CLI จัดเก็บข้อมูลรับรองเหล่านี้ได้โดยใช้การตั้งค่า cli_auth_credentials_store โดยเลือกได้ระหว่าง "file", "keyring" (สำหรับที่เก็บข้อมูลรับรอง OS) หรือ "auto" (ซึ่งจะพยายามใช้ keyring ก่อน จากนั้นจะกลับไปใช้ file)

แนวทางปฏิบัติที่ดีที่สุดด้านความปลอดภัย: หากคุณเลือกการจัดเก็บข้อมูลแบบไฟล์ ให้ปฏิบัติต่อ ~/.codex/auth.json ด้วยความระมัดระวังสูงสุด คล้ายกับรหัสผ่านที่ละเอียดอ่อน ไฟล์นี้มีโทเค็นการเข้าถึงที่สามารถให้สิทธิ์การเข้าถึงโดยไม่ได้รับอนุญาต ห้ามนำไฟล์นี้ไปคอมมิตในระบบควบคุมเวอร์ชัน, วางลงในฟอรัมสาธารณะ, หรือแบ่งปันผ่านการสนทนาโดยเด็ดขาด เพื่อเพิ่มความปลอดภัย โดยทั่วไปแนะนำให้ใช้ตัวเลือก keyring เนื่องจากใช้การจัดการข้อมูลรับรองในตัวของระบบปฏิบัติการที่ปลอดภัยกว่า

การจัดการการรับรองความถูกต้องขั้นสูงสำหรับองค์กร

สำหรับองค์กรที่ปรับใช้ Codex ในหลายๆ ทีม การควบคุมดูแลระบบที่แข็งแกร่งเป็นสิ่งจำเป็นสำหรับการรักษาความปลอดภัยและการปฏิบัติตามข้อกำหนด OpenAI มีคุณสมบัติที่จะช่วยให้ผู้ดูแลระบบบังคับใช้วิธีการเข้าสู่ระบบเฉพาะและข้อจำกัดพื้นที่ทำงาน

ผู้ดูแลระบบสามารถใช้การตั้งค่าต่างๆ เช่น forced_login_method เพื่อบังคับให้ผู้ใช้ทุกคนในสภาพแวดล้อมที่มีการจัดการต้องเข้าสู่ระบบด้วย "chatgpt" หรือ "api" key สิ่งนี้ช่วยให้มั่นใจถึงการปฏิบัติตามนโยบายความปลอดภัยภายในหรือรูปแบบการเรียกเก็บเงิน นอกจากนี้ สำหรับการเข้าสู่ระบบด้วย ChatGPT การตั้งค่า forced_chatgpt_workspace_id ยังช่วยให้ผู้ดูแลระบบสามารถจำกัดผู้ใช้ให้อยู่ในพื้นที่ทำงาน ChatGPT ที่ได้รับการอนุมัติและเฉพาะเจาะจง

การควบคุมเหล่านี้โดยทั่วไปจะถูกนำไปใช้ผ่าน การกำหนดค่าแบบจัดการ แทนที่จะเป็นการตั้งค่าผู้ใช้แต่ละราย เพื่อให้มั่นใจถึงการบังคับใช้นโยบายที่สอดคล้องกัน หากข้อมูลรับรองที่ใช้งานอยู่ของผู้ใช้ไม่เป็นไปตามข้อจำกัดที่กำหนดค่าไว้ Codex จะทำการล็อกเอาต์และออกจากระบบโดยอัตโนมัติ รักษาความสมบูรณ์ของสภาพแวดล้อมที่มีการจัดการ

การเข้าสู่ระบบอุปกรณ์แบบ Headless และชุด CA แบบกำหนดเอง

นักพัฒนามักจะทำงานในสภาพแวดล้อมที่หลากหลาย รวมถึงเซิร์ฟเวอร์ระยะไกลหรือเครื่องแบบ Headless ที่ไม่มีส่วนต่อประสานผู้ใช้แบบกราฟิก เมื่อใช้ Codex CLI หาก UI การเข้าสู่ระบบแบบเบราว์เซอร์มาตรฐานมีปัญหา (เช่น เนื่องจากสภาพแวดล้อมแบบ Headless หรือการบล็อกเครือข่าย) OpenAI มีทางเลือกอื่น

การรับรองความถูกต้องด้วยรหัสอุปกรณ์ (ปัจจุบันอยู่ในช่วงเบต้า) เป็นโซลูชันที่แนะนำสำหรับสถานการณ์ดังกล่าว หลังจากเปิดใช้งานคุณสมบัตินี้ในการตั้งค่าความปลอดภัยของ ChatGPT ของคุณ (ส่วนตัวหรือผู้ดูแลระบบพื้นที่ทำงาน) คุณสามารถเลือก "ลงชื่อเข้าใช้ด้วยรหัสอุปกรณ์" ในการเข้าสู่ระบบ CLI แบบโต้ตอบ หรือรัน codex login --device-auth โดยตรง สิ่งนี้จะสร้างรหัสที่คุณสามารถป้อนบนอุปกรณ์อื่นที่มีเบราว์เซอร์ เพื่อให้แน่ใจว่าการเข้าถึงที่ปลอดภัยโดยไม่ต้องมีเบราว์เซอร์ในเครื่อง

สำหรับองค์กรที่ทำงานอยู่เบื้องหลังพร็อกซี TLS ขององค์กร หรือใช้ Certificate Authorities (CAs) รูทส่วนตัว การสื่อสารที่ปลอดภัยมักจะต้องใช้ชุด CA แบบกำหนดเอง Codex รองรับสิ่งนี้โดยอนุญาตให้คุณตั้งค่าตัวแปรสภาพแวดล้อม CODEX_CA_CERTIFICATE ไปยังพาธของชุด PEM ของคุณก่อนที่จะเข้าสู่ระบบ สิ่งนี้ทำให้มั่นใจได้ว่าการเชื่อมต่อที่ปลอดภัยทั้งหมด ซึ่งรวมถึงการเข้าสู่ระบบ, คำขอ HTTPS และการเชื่อมต่อ WebSocket จะเชื่อถือ CA ขององค์กรของคุณ รักษาการปฏิบัติตามข้อกำหนดและความปลอดภัยทั่วทั้งโครงสร้างพื้นฐานของคุณ คุณสามารถค้นหารายละเอียดเพิ่มเติมเกี่ยวกับแนวทางปฏิบัติที่ดีที่สุดทั่วไปสำหรับการเชื่อมต่อโมเดล AI ในสภาพแวดล้อมที่ปลอดภัยได้ในแหล่งข้อมูล เช่น คู่มือการสร้างพร้อมต์สำหรับ Codex

ด้วยการทำความเข้าใจและนำคุณสมบัติการรับรองความถูกต้องและความปลอดภัยเหล่านี้ไปใช้อย่างถูกต้อง นักพัฒนาและองค์กรสามารถรวม OpenAI Codex เข้ากับเวิร์กโฟลว์ของตนได้อย่างมั่นใจ ใช้ประโยชน์จากพลังของมันในขณะที่ยังคงควบคุมการเข้าถึงและข้อมูลได้อย่างแข็งแกร่ง

แหล่งที่มา

https://developers.openai.com/codex/auth/

คำถามที่พบบ่อย

What are the primary authentication methods for OpenAI Codex, and what are their key differences?
OpenAI Codex offers two main authentication methods: 'Sign in with ChatGPT' and 'Sign in with an API key.' Signing in with ChatGPT grants access based on your existing ChatGPT subscription, applying your workspace permissions, RBAC, and ChatGPT Enterprise data retention/residency settings. This method is required for Codex cloud and provides access to features like 'fast mode' powered by ChatGPT credits. Conversely, signing in with an API key provides usage-based access, billed through your OpenAI Platform account at standard API rates. This method follows your API organization’s data-sharing settings and is recommended for programmatic workflows like CI/CD jobs, offering greater flexibility and granular control over usage. While the CLI and IDE extension support both, Codex cloud exclusively requires ChatGPT sign-in.
Why is Multi-Factor Authentication (MFA) considered crucial for securing a Codex cloud account, and how can users enable it?
Multi-Factor Authentication (MFA) is crucial for securing Codex cloud accounts because Codex interacts directly with sensitive codebase, necessitating robust security measures beyond standard ChatGPT features. MFA adds an essential layer of protection by requiring a second form of verification, significantly reducing the risk of unauthorized access even if a password is compromised. Users can enable MFA via their social login provider (Google, Microsoft, Apple) if they use one. If logging in with email and password, MFA *must* be set up on the account before accessing Codex cloud. Enterprise users accessing via Single Sign-On (SSO) should have MFA enforced by their organization's SSO administrator, ensuring comprehensive security across the development environment.
How does Codex manage and store login credentials, and what are the security best practices for handling them?
Codex caches login details locally, either in a plaintext file at `~/.codex/auth.json` or within your operating system's native credential store. The CLI and IDE extension share these cached credentials for convenience. For sign-in with ChatGPT, active sessions automatically refresh tokens to maintain continuity. Users can control storage location using the `cli_auth_credentials_store` setting, choosing 'file', 'keyring' (OS credential store), or 'auto'. When using file-based storage, it is critical to treat `~/.codex/auth.json` with the same care as a password: never commit it to version control, paste it into public forums, or share it in chat, as it contains sensitive access tokens. The 'keyring' option is generally more secure as it leverages OS-level protection.
What administrative controls are available for managing Codex authentication in managed environments, and how are they applied?
In managed environments, administrators can enforce specific authentication policies for Codex users through configuration settings. The `forced_login_method` parameter can restrict users to either 'chatgpt' or 'api' key login, ensuring compliance with organizational security or billing policies. Additionally, for ChatGPT logins, the `forced_chatgpt_workspace_id` setting allows administrators to restrict users to a particular ChatGPT workspace, enhancing governance and data segregation. These settings are typically applied via managed configuration, rather than individual user setups, ensuring consistent policy enforcement across the enterprise. If a user's active credentials don't match the enforced restrictions, Codex will automatically log them out and exit, maintaining a secure and controlled environment.
What options exist for logging into the Codex CLI on headless devices or in environments where the browser-based UI is problematic?
For scenarios involving headless devices, remote environments, or local networking configurations that block the OAuth callback, Codex offers alternative login methods for its CLI. The preferred method is 'device code authentication' (currently in beta). To use this, users must first enable device code login in their ChatGPT security settings (personal account) or workspace permissions (for administrators). Then, when interacting with the CLI, they can choose 'Sign in with Device Code' from the interactive UI or directly run `codex login --device-auth`. This method provides a code that can be entered on a separate device with a browser, allowing authentication without a local browser UI. If device code authentication is not feasible, fallback methods might involve manual token pasting or configuration adjustments as guided by support.
How does the choice of authentication method (ChatGPT vs. API Key) impact data handling and retention policies in Codex?
The chosen authentication method significantly dictates the data handling and retention policies applied to your Codex usage. When you 'Sign in with ChatGPT,' your Codex activities adhere to the data-handling policies, RBAC (Role-Based Access Control), and enterprise retention and residency settings configured for your ChatGPT workspace. This ensures consistency with your established ChatGPT Enterprise agreement. Conversely, if you 'Sign in with an API key,' your usage follows the data retention and sharing settings established for your OpenAI Platform API organization. This distinction is crucial for organizations requiring specific compliance or data governance frameworks, as it determines how your code interactions and other data generated by Codex are processed and stored by OpenAI.
Can Codex be used with custom CA bundles for secure communication over corporate networks?
Yes, Codex supports the use of custom CA bundles, which is essential for environments operating behind corporate TLS proxies or utilizing private root CAs. To enable this, users need to set the `CODEX_CA_CERTIFICATE` environment variable to the path of their PEM bundle before initiating a login or any other Codex operation. If `CODEX_CA_CERTIFICATE` is not set, Codex will default to using `SSL_CERT_FILE`. This custom CA setting uniformly applies across all secure communication channels, including the login process, standard HTTPS requests, and secure websocket connections, ensuring that all data exchanges comply with the corporate network's security policies and are properly trusted within the organizational infrastructure.

อัปเดตข่าวสาร

รับข่าว AI ล่าสุดในกล่องจดหมายของคุณ

แชร์