Lộ trình đang học Current learning path

Developer Platform Developer Platform

Build và deploy apps trên Cloudflare. Build and deploy apps on Cloudflare.

Về trang lộ trình Track home

Phần 5: AI trên Developer Platform Part 5: AI on the Developer Platform · Bài 3/5 Lesson 3/5

Baseline bảo mật cho ứng dụng AI AI application security baseline

Giữ key ở Worker secrets, xác thực người dùng trước endpoint AI, rate limit input, validate tool input và áp dụng guardrails cho data/response nhạy cảm. Keep keys in Worker secrets, authenticate users before AI endpoints, rate-limit input, validate tool input, and apply guardrails to sensitive data and responses.

Các bước thực hiện Step-by-step

  1. Lưu provider key, gateway token và credential tool bằng `wrangler secret put`; không đưa chúng vào client bundle hoặc repo. Store provider keys, gateway tokens, and tool credentials with `wrangler secret put`; never put them in a client bundle or repository.
  2. Xác thực user/tenant trước AI endpoint và authorize mỗi action theo policy server-side. Authenticate the user or tenant before an AI endpoint and authorize every action with server-side policy.
  3. Rate limit endpoint theo identity và cost/risk; bảo vệ form/chat public bằng Turnstile khi phù hợp. Rate-limit the endpoint by identity and cost or risk; protect public chat or forms with Turnstile where appropriate.
  4. Validate mọi tool argument theo schema; deny-by-default cho action ghi, external request hoặc truy cập dữ liệu nhạy cảm. Validate every tool argument against a schema; deny by default for writes, external requests, or sensitive-data access.

Giải thích chi tiết Detailed explanation

Prompt injection không được giải quyết chỉ bằng prompt. Treat model output là untrusted input: nó không thể tự cấp quyền, chọn tool unrestricted hay vượt qua authorization của app. Prompt injection is not solved by a prompt alone. Treat model output as untrusted input: it must not grant itself access, choose an unrestricted tool, or bypass application authorization.

Lưu ý (best practices) Note (best practices)

Mọi key/token dùng để gọi model hay tool phải là secret. Validate input ở server và chỉ cấp khả năng cần thiết cho từng request; model output không phải authorization signal. Every key or token used to call a model or tool must be a secret. Validate input on the server and grant only the capability needed for each request; model output is not an authorization signal.

Nguồn: Source: Workers Best Practices Workers Best Practices

Ví dụ triển khai (Cloudflare Resources) Deployment examples (Cloudflare Resources)

Ví dụ chính thức từ Cloudflare Resources — gợi ý theo chủ đề bài học trong lộ trình này. Official examples from Cloudflare Resources — matched to this lesson within this path.

Tutorial Tutorial Developer Platform Developer Platform

Bảo vệ your forms Protect your forms

Tóm tắt thực hành: Bảo vệ your forms trên Turnstile. This tutorial will guide you through integrating Cloudflare Turnstile to protect your web forms, such as login, signup, or contact forms.

This tutorial will guide you through integrating Cloudflare Turnstile to protect your web forms, such as login, signup, or contact forms.

Tìm hiểu thêm Learn more
Tutorial Tutorial Application Services Application Services

Conditionally enforce Turnstile Conditionally enforce Turnstile

Tutorial này hướng dẫn cách conditionally enforce Turnstile based on the incoming request, such as a pre-shared secret in a header or a specific IP address.

This tutorial explains how to conditionally enforce Turnstile based on the incoming request, such as a pre-shared secret in a header or a specific IP address.

Tìm hiểu thêm Learn more

Xem thêm ví dụ trong lộ trình → More examples in this path →

Tài liệu Cloudflare Developers Cloudflare Developer docs

Sản phẩm liên quan Related products

Học xong hoặc muốn đổi hướng? Finished or want a different path?

Ba lộ trình độc lập — mỗi lộ trình chỉ gồm bài học và tài liệu trong phạm vi đó. Chọn lộ trình khác khi sẵn sàng, không cần học song song. Three independent paths — each includes only lessons and materials for that scope. Switch when you are ready; no need to study paths in parallel.

Chưa chắc — làm bài chọn lộ trình Not sure — use the path selector · So sánh cả ba lộ trình Compare all three paths