-
-
Notifications
You must be signed in to change notification settings - Fork 380
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: improve Ory CLI usage in auth guide (#1918)
- Loading branch information
Showing
10 changed files
with
172 additions
and
120 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,24 +1,64 @@ | ||
Ory CLI provides a convenient way to configure and manage projects. Additionally, the CLI contains Ory Proxy - a reverse proxy | ||
that rewrites cookies to match the domain your application is currently on. | ||
The Ory security model uses HTTP cookies to manage sessions, tokens, and cookies. Because of browser security measures like | ||
[CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS), Ory APIs must be exposed on the same domain as your application. | ||
|
||
Ory Proxy is a reverse proxy deployed in front of your application. The Proxy mirrors Ory endpoints on the same domain as the | ||
application you're running and rewrites cookies to match the domain your application is currently on. | ||
In the case of this example the application runs on your local machine. The cookie domain is `localhost`. | ||
|
||
As a result, the origin of the cookies is set correctly to the domain you run the app on instead of <br /> | ||
:::info | ||
|
||
``` | ||
<your-project-slug>.projects.oryapis.com | ||
``` | ||
When developing locally, use either `localhost` or `127.0.0.1`, but not both. Although technically these mean the same thing, | ||
they're different cookie domains. | ||
|
||
Using both interchangeably in your code causes problems, as Ory APIs will not receive the cookies when they are set on a different | ||
domain. | ||
|
||
::: | ||
|
||
This behavior is necessary to avoid issues with the browser [CORS policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS). | ||
<p> | ||
Ory CLI provides a convenient way to configure and manage projects. Additionally, the CLI provides Ory{" "} | ||
{props.isTunnel ? "Tunnel" : "Proxy"} - a reverse proxy that rewrites cookies to match the domain your application is currently | ||
on. | ||
</p> | ||
|
||
By using the Proxy, you can easily connect the application you're developing locally to Ory Network and consume the APIs without | ||
additional configuration or the self-hosting any Ory services. | ||
<p> | ||
To make Ory APIs and your application available on the same domain, Ory {props.isTunnel ? "Tunnel" : "Proxy"} mirrors Ory | ||
endpoints and rewrites cookies to match the domain correct domain. | ||
</p> | ||
|
||
[![Ory Proxy mirrors Ory's APIs](https://mermaid.ink/img/pako:eNptkMFKxEAMhl8l5GIXdm1BT3MQWlxEEBxWL8JchjbaYqcZMlO0bPfdna71sGBOP-H7EpIj1twQKvwQ61t4OpgBUlVZJfwVSDaw293ND_tXaGP0Ks97rm3fcojqtiiKGXT2LBNo4e9p8-vqs-I6EZYANkJ-zTLlM5T6cYGvwpLCBf3vgpvzgjJ741Gg9H41ykU4UPA8BJr1OuaiWeEWHYmzXZNOOy6IwdiSI4MqxcbKp0EznBI3-sZG2jddZEH1bvtAW7Rj5JdpqFFFGekPuu9sepNbqdMP2FdlPQ)](https://mermaid-js.github.io/mermaid-live-editor/edit#pako:eNptkMFKxEAMhl8l5GIXdm1BT3MQWlxEEBxWL8JchjbaYqcZMlO0bPfdna71sGBOP-H7EpIj1twQKvwQ61t4OpgBUlVZJfwVSDaw293ND_tXaGP0Ks97rm3fcojqtiiKGXT2LBNo4e9p8-vqs-I6EZYANkJ-zTLlM5T6cYGvwpLCBf3vgpvzgjJ741Gg9H41ykU4UPA8BJr1OuaiWeEWHYmzXZNOOy6IwdiSI4MqxcbKp0EznBI3-sZG2jddZEH1bvtAW7Rj5JdpqFFFGekPuu9sepNbqdMP2FdlPQ) | ||
As a result, the domain of the cookies is set correctly to the domain you run the app on instead of | ||
`<your-project-slug>.projects.oryapis.com`. | ||
|
||
<p> | ||
By using the {props.isTunnel ? "Tunnel" : "Proxy"}, you can easily connect the application you're developing locally to Ory | ||
Network and consume the APIs without additional configuration or the self-hosting any Ory services. | ||
</p> | ||
|
||
```mdx-code-block | ||
import Mermaid from "@site/src/theme/Mermaid" | ||
<Mermaid | ||
chart={props.isTunnel ? | ||
`graph LR | ||
B(Browser) -->|GET http://localhost:4000| T(Ory Tunnel) | ||
T -->|Response| B | ||
T <-->|mirrors| API(Ory's APIs) | ||
B -->|GET http://localhost:3000| A(Your App) | ||
A-->|Response|B | ||
` : | ||
`graph LR | ||
B(Browser) -->|GET http://localhost:4000| P(Ory Proxy) | ||
P <-->|mirrors at /.ory/| API(Ory's APIs) | ||
P -->|GET http://localhost:3000| A(Your App) | ||
A-->|Response|P | ||
P-->|Response|B | ||
`} | ||
/> | ||
``` | ||
|
||
:::tip | ||
|
||
To learn more about the Ory Proxy, read the [dedicated section of the Ory CLI documentation](../../guides/cli/proxy-and-tunnel). | ||
<p> | ||
To learn more about the Ory {props.isTunnel ? "Tunnel" : "Proxy"}, read the [dedicated section of the Ory CLI | ||
documentation](../../guides/cli/proxy-and-tunnel). | ||
</p> | ||
|
||
::: |
This file contains 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 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 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.