-
Notifications
You must be signed in to change notification settings - Fork 10.4k
[AIG]Initial authentication documentation #18072
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
9187b37
Initial authentication documentation
daisyfaithauma 3f47dc4
Added links to authentication
daisyfaithauma 14d0708
Update src/content/docs/ai-gateway/configuration/authentication.mdx
daisyfaithauma e50d2c4
Update src/content/docs/ai-gateway/configuration/authentication.mdx
daisyfaithauma 15aabf3
Update src/content/docs/ai-gateway/get-started.mdx
daisyfaithauma 94b2257
Update src/content/docs/ai-gateway/observability/logging/index.mdx
daisyfaithauma 6ad4ce9
Update src/content/docs/ai-gateway/get-started.mdx
daisyfaithauma 760bf27
Update src/content/docs/ai-gateway/get-started.mdx
daisyfaithauma 78ff3de
Update src/content/docs/ai-gateway/configuration/authentication.mdx
daisyfaithauma 818d677
Update authentication.mdx
kathayl 27164e8
Update get-started.mdx
kathayl 4fb4a44
Update index.mdx
kathayl edec4d1
Update authentication.mdx
kathayl c2f69dc
Update get-started.mdx
kathayl d513d58
Update index.mdx
kathayl 6e16f6a
added examples and changelog
daisyfaithauma 8d754b6
websockets changelog
daisyfaithauma 37827bf
Update authentication.mdx
kathayl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
src/content/docs/ai-gateway/configuration/authentication.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| --- | ||
| pcx_content_type: configuration | ||
| title: Authentication | ||
| sidebar: | ||
| order: 7 | ||
| head: [] | ||
| description: Add security by requiring a valid authorization token for each request. | ||
| --- | ||
|
|
||
| The Authenticated Gateway feature in AI Gateway adds security by requiring a valid authorization token for each request. This feature is especially useful when storing logs persistently, as it prevents unauthorized access and protects against "log bombing." With Authenticated Gateway enabled, only requests with the correct token are processed. | ||
|
|
||
| :::note[Note] | ||
| We recommend enabling Authenticated Gateway when opting to store logs with AI Gateway. | ||
| ::: | ||
|
|
||
| :::caution[Caution] | ||
daisyfaithauma marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| If Authenticated Gateway is enabled but a request does not include the required `cf-aig-authorization` header, the request will fail. This setting ensures that only verified requests pass through the gateway. To bypass the need for the `cf-aig-authorization` header, make sure to disable Authenticated Gateway. | ||
| ::: | ||
|
|
||
| ## Setting up Authenticated Gateway using the Dashboard | ||
|
|
||
| 1. Go to the Settings for the specific gateway you want to enable authentication for. | ||
| 2. Select **Create authentication token** to generate a custom token with the required `Run` permissions. Be sure to securely save this token, as it will not be displayed again. | ||
| 3. Include the `cf-aig-authorization` header with your API token in each request for this gateway. | ||
| 4. Return to the settings page and toggle on Authenticated Gateway. | ||
|
|
||
| ## Example request with OpenAI | ||
|
|
||
| ```bash | ||
| curl https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/openai/chat/completions \ | ||
| --header 'cf-aig-authorization: Bearer {CF_AIG_TOKEN}' \ | ||
| --header 'Authorization: Bearer OPENAI_TOKEN' \ | ||
| --header 'Content-Type: application/json' \ | ||
| --data '{"model": "gpt-3.5-turbo", "messages": [{"role": "user", "content": "What is Cloudflare?"}]}' | ||
| ``` | ||
|
|
||
| ## Setting Authenticated Gateway using the API | ||
|
|
||
| For API setup, see the [API documentation](/api/operations/aig-config-create-gateway/). | ||
|
|
||
| ## Expected behavior | ||
|
|
||
| The following table outlines gateway behavior based on the authentication settings and header status: | ||
|
|
||
| | Authentication Setting | Header Info | Gateway State | Response | | ||
| | ---------------------- | -------------- | ----------------------- | ------------------------------------------ | | ||
| | On | Header present | Authenticated gateway | Request succeeds | | ||
| | On | No header | Error | Request fails due to missing authorization | | ||
| | Off | Header present | Unauthenticated gateway | Request succeeds | | ||
| | Off | No header | Unauthenticated gateway | Request succeeds | | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.