-
Notifications
You must be signed in to change notification settings - Fork 7
Add secure/brand auth in production doc #341
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
Changes from 1 commit
5dbc688
25996af
9f16a1d
5b48dd0
252cfbe
f60fabf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,127 @@ | ||||||||
| --- | ||||||||
| title: "Secure Auth in Production" | ||||||||
| description: "How to secure and brand your auth flows in production" | ||||||||
| --- | ||||||||
|
|
||||||||
| # Secure and Brand the Auth Flow in Production | ||||||||
|
|
||||||||
| To keep your users safe, Arcade.dev performs a session verification check when a tool is authorized for the first time. This check verifies that the user who is authorizing the tool is the same user who started the authorization flow, which helps prevent phishing attacks. | ||||||||
|
|
||||||||
| There are two ways to secure your auth flows with Arcade.dev: | ||||||||
| - Use the **Arcade session verifier** for development (enabled by default) | ||||||||
| - Implement a **custom session verifier** for production | ||||||||
|
|
||||||||
| This setting is configured in the Arcade Dashboard. | ||||||||
|
|
||||||||
|
|
||||||||
| ## Use the Arcade session verifier | ||||||||
|
|
||||||||
| If you're building a proof-of-concept app or a solo project, use the Arcade session verifier. This option is on by default when you create a new Arcade.dev account. | ||||||||
nbarbettini marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||
|
|
||||||||
| When you authorize a tool, you'll be prompted to sign in to your Arcade.dev account. If you are already signed in (to the Arcade Dashboard, for example), this verification will succeed silently. | ||||||||
|
|
||||||||
| <Note> | ||||||||
| Arcade's default OAuth apps can *only* be used with the Arcade session verifier. | ||||||||
| If you are building a multi-user production app, you must obtain your own OAuth app credentials and add them to Arcade. | ||||||||
| For example, [configure Google auth in the Arcade Dashboard](https://docs.arcade.dev/home/auth-providers/google#access-the-arcade-dashboard). | ||||||||
| </Note> | ||||||||
|
|
||||||||
| The Arcade.dev session verifier helps keep your auth flows secure while you are building and testing your agent or app. When you're ready to share your work with others, implement a [custom session verifier](#set-up-a-custom-session-verifier) so your users don't need to sign in to Arcade.dev. | ||||||||
nbarbettini marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||
|
|
||||||||
|
|
||||||||
| ## Set up a custom session verifier | ||||||||
|
|
||||||||
| In a production application or agent, user sessions are verified by your code, not Arcade.dev. To enable this, build a custom verifier route and add the URL to the Arcade Dashboard. | ||||||||
nbarbettini marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||
|
|
||||||||
| When your users authorize a tool, Arcade.dev will redirect the user's browser to your verifier route with some information in the query string. Your custom verifier route must send a response back to Arcade.dev to confirm the user's session details. | ||||||||
|
|
||||||||
| If you need help, start a [GitHub discussion](https://github.com/ArcadeAI/arcade-ai/discussions) and we'll be happy to assist. | ||||||||
nbarbettini marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||
|
|
||||||||
| import { Steps, Tabs } from "nextra/components"; | ||||||||
|
|
||||||||
| <Steps> | ||||||||
|
|
||||||||
| ### Build a new route | ||||||||
|
|
||||||||
| Create a public route in your app or API that can accept a browser redirect (HTTP 303) from Arcade.dev after a user has authorized a tool. | ||||||||
|
|
||||||||
| The route must gather the following information: | ||||||||
|
|
||||||||
| - The `flow_id` from the current URL's query string | ||||||||
| - The unique ID of the user currently signed in. This varies depending on how your app is built, but it is typically retrieved from a session cookie or other secure storage. It **must** match the user ID that your code specified at the start of the authorization flow. | ||||||||
nbarbettini marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||
|
|
||||||||
|
|
||||||||
| ### Verify the user's session details | ||||||||
|
|
||||||||
| Use the Arcade SDK (or our REST API) to verify the user's session details. | ||||||||
|
|
||||||||
| <Warning> | ||||||||
| Because this request uses your Arcade API key, it *must not* be made from the client side (a browser or desktop app). This code must be run on a server. | ||||||||
| </Warning> | ||||||||
|
|
||||||||
| <Tabs items={["REST"]} storageKey="preferredLanguage"> | ||||||||
| <Tabs.Tab> | ||||||||
| ```text | ||||||||
| POST https://cloud.arcade.dev/api/v1/oauth/confirm_user | ||||||||
| Authorization: Bearer <arcade_api_key> | ||||||||
| Content-Type: application/json | ||||||||
|
|
||||||||
| { | ||||||||
| "flow_id": "<flow_id from the query string>", | ||||||||
| "user_id": "<the current user's ID>" | ||||||||
| } | ||||||||
| ``` | ||||||||
| </Tabs.Tab> | ||||||||
| </Tabs> | ||||||||
|
Comment on lines
+63
to
+76
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We will get this into the client libs soon, yes?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, next on my list. That will result in more tabs here |
||||||||
|
|
||||||||
| **Valid Response** | ||||||||
|
|
||||||||
| If the session details are valid, the response will contain some information about the auth flow: | ||||||||
|
|
||||||||
| <Tabs items={["REST"]} storageKey="preferredLanguage"> | ||||||||
| <Tabs.Tab> | ||||||||
| ```text | ||||||||
| HTTP 200 OK | ||||||||
| Content-Type: application/json | ||||||||
|
|
||||||||
| { | ||||||||
| // Can be used to look up the auth flow's status in the Arcade API | ||||||||
| "auth_id": "ac_2zKml...", | ||||||||
|
|
||||||||
| // Optional: URL to redirect the user to after the authorization flow is complete | ||||||||
| "next_uri": "https://..." | ||||||||
| } | ||||||||
| ``` | ||||||||
| </Tabs.Tab> | ||||||||
| </Tabs> | ||||||||
|
|
||||||||
| You can optionally redirect the user's browser to the `next_uri`, which will display a generic "success" page. Or, you can redirect to your application as needed. | ||||||||
|
|
||||||||
| **Invalid Response** | ||||||||
|
|
||||||||
| If the session details are invalid, it means the user is not the same user who started the authorization flow. | ||||||||
|
|
||||||||
| <Tabs items={["REST"]} storageKey="preferredLanguage"> | ||||||||
| <Tabs.Tab> | ||||||||
| ```text | ||||||||
| HTTP 400 Bad Request | ||||||||
| Content-Type: application/json | ||||||||
|
|
||||||||
| { | ||||||||
| "code": 400, | ||||||||
| "msg": "An error occurred during verification" | ||||||||
| } | ||||||||
| ``` | ||||||||
| </Tabs.Tab> | ||||||||
| </Tabs> | ||||||||
|
|
||||||||
| ### Add your custom verifier route to Arcade | ||||||||
|
|
||||||||
| In the Arcade Dashboard, pick the **Custom verifier** option and add the URL of your verifier route. | ||||||||
|
|
||||||||
|
Comment on lines
+121
to
+122
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO: Add screenshot soon
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: if This will be under a menu item, let's expand it!
Suggested change
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @torresmateo Will do, I will update this after the Dashboard ships. |
||||||||
| <Note> | ||||||||
| Arcade's default OAuth apps *only* support the Arcade session verifier. | ||||||||
| Authorization flows using Arcade's default OAuth apps will use the Arcade session verifier even if you have a custom verifier route set up. | ||||||||
| </Note> | ||||||||
|
|
||||||||
| </Steps> | ||||||||
Uh oh!
There was an error while loading. Please reload this page.