From 97c158afd992f6167b5b657499217db1e6fcb550 Mon Sep 17 00:00:00 2001 From: Patrik Date: Sat, 12 Oct 2024 09:18:41 +0200 Subject: [PATCH] chore: improve Ory CLI usage in auth guide (#1918) --- docs/getting-started/_common/ory-cli.mdx | 66 +++++++++++++++---- docs/getting-started/integrate-auth/01_go.mdx | 13 ++-- .../getting-started/integrate-auth/05_php.mdx | 15 +++-- .../integrate-auth/10_expressjs.mdx | 31 ++++----- .../integrate-auth/15_nextjs.mdx | 48 ++++++++++---- .../20_flutter-web-redirect.mdx | 15 +++-- .../integrate-auth/25_react.mdx | 29 +++++--- .../getting-started/integrate-auth/30_vue.mdx | 46 ++++++------- .../integrate-auth/40_dotnet.mdx | 20 +++--- docs/guides/cli/20_proxy-and-tunnel.mdx | 9 --- 10 files changed, 172 insertions(+), 120 deletions(-) diff --git a/docs/getting-started/_common/ory-cli.mdx b/docs/getting-started/_common/ory-cli.mdx index 368ce3c98..584c8c4f2 100644 --- a/docs/getting-started/_common/ory-cli.mdx +++ b/docs/getting-started/_common/ory-cli.mdx @@ -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
+:::info -``` -.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). +

+ 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. +

-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. +

+ 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. +

-[![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 +`.projects.oryapis.com`. + +

+ 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. +

+ +```mdx-code-block +import Mermaid from "@site/src/theme/Mermaid" + +|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). +

+ To learn more about the Ory {props.isTunnel ? "Tunnel" : "Proxy"}, read the [dedicated section of the Ory CLI + documentation](../../guides/cli/proxy-and-tunnel). +

::: diff --git a/docs/getting-started/integrate-auth/01_go.mdx b/docs/getting-started/integrate-auth/01_go.mdx index 9e07c305b..68f02dabd 100644 --- a/docs/getting-started/integrate-auth/01_go.mdx +++ b/docs/getting-started/integrate-auth/01_go.mdx @@ -23,7 +23,7 @@ import { useLatestTag } from '@site/src/hooks' First, create a Go app. Run these commands: -```shell-session +```shell mkdir your-project cd your-project @@ -43,7 +43,7 @@ Run this command to install the Ory SDK which allows you to interact with Ory AP Follow [this guide](../../guides/cli/01_installation.mdx) to install the Ory CLI on your machine. -### Why do I Need the Ory CLI? +### Why do I need the Ory CLI ```mdx-code-block import OryCLI from '../_common/ory-cli.mdx' @@ -100,8 +100,8 @@ With all of the pieces in place, it's time to test your application. Follow thes 1. Start your Go app: -```shell-session - go run . +```shell +go run . ``` 2. Export the SDK configuration URL for the desired Ory project. You can use the provided playground project for testing, or @@ -119,9 +119,10 @@ import SdkEnvVar from '@site/src/components/SdkEnvVar' ``` -3. Run the Ory proxy to mirror the Ory API endpoints on your application's domain (`localhost`): +3. Run the Ory proxy to mirror the Ory API endpoints on your application's domain (`localhost`). Upon first start, the Ory Proxy + will ask you to log into your Ory Console account. -```shell-session +```shell ory proxy http://localhost:3000 ``` diff --git a/docs/getting-started/integrate-auth/05_php.mdx b/docs/getting-started/integrate-auth/05_php.mdx index 61785246d..2c2ca236b 100644 --- a/docs/getting-started/integrate-auth/05_php.mdx +++ b/docs/getting-started/integrate-auth/05_php.mdx @@ -20,7 +20,7 @@ import webm from '../_static/php/screencast.webm' First we create a new PHP project: -```shell-session +```shell mkdir your-project cd your-project touch index.php @@ -30,19 +30,19 @@ touch index.php To interact with Ory's APIs we install the [Ory SDK](https://packagist.org/packages/ory/client): -```shell-session +```shell composer require ory/client ``` To simplify URLs handling we install the [bramus/router](https://packagist.org/packages/bramus/router) -```shell-session +```shell composer require bramus/router ``` To install Ory CLI follow [this guide](https://www.ory.sh/docs/guides/ory-cli-install-use) -### Why do I Need the Ory CLI? +### Why do I need the Ory CLI ```mdx-code-block import OryCLI from '../_common/ory-cli.mdx' @@ -86,7 +86,7 @@ import appPHP from '!!raw-loader!../../../code-examples/protect-page-login/php/a Start your HTTP server and access the proxy URL -```shell-session +```shell php -S 127.0.0.1:3000 ``` @@ -96,7 +96,10 @@ import SdkEnvVar from '@site/src/components/SdkEnvVar' ``` -```shell-session +Next open a new terminal window and start the Ory Proxy. Upon first start, the Ory Proxy will ask you to log into your Ory Console +account. + +```shell ory proxy http://localhost:3000 ``` diff --git a/docs/getting-started/integrate-auth/10_expressjs.mdx b/docs/getting-started/integrate-auth/10_expressjs.mdx index cfa7c0e64..73a3435aa 100644 --- a/docs/getting-started/integrate-auth/10_expressjs.mdx +++ b/docs/getting-started/integrate-auth/10_expressjs.mdx @@ -20,7 +20,7 @@ import webm from '../_static/expressjs/screencast.webm' First we create a new Express.js project: -```shell-session +```shell mkdir your-project cd your-project @@ -28,23 +28,15 @@ npx express-generator npm i ``` -## Install Ory SDK - -To interact with Ory's APIs we install the Ory SDK: - -```shell-session -npm i --save @ory/client -``` +## Install Ory SDK and CLI -## Install Ory CLI - -The last step is setting up the Ory CLI. +To interact with Ory's APIs we install the Ory SDK and CLI: ```shell -npm i --save @ory/cli +npm i --save @ory/client @ory/cli ``` -### Why do I Need the Ory CLI? +### Why do I need the Ory CLI ```mdx-code-block import OryCLI from '../_common/ory-cli.mdx' @@ -68,8 +60,8 @@ Now that the Ory CLI is installed, let's add it as a `npm run` script to our pro "dependencies": { ``` -This requires the express app (`npm run start`) to run on port 3000. The browser / user uses however the port 4000 -([http://localhost:4000](http://localhost:4000)) to access the app. +This requires the express app (`npm run start`) to run on port 3000. However, the app has to be accessed through the port 4000 +([http://localhost:4000](http://localhost:4000)). ## Require login to access the home page @@ -87,7 +79,7 @@ import CodeBlock from '@theme/CodeBlock' Great, that's it. Let's run your application. Start the Express.js server -```shell-session +```shell npm run start ``` @@ -99,9 +91,10 @@ import SdkEnvVar from '@site/src/components/SdkEnvVar' ``` -Next open a new terminal window and start the Ory Proxy: +Next open a new terminal window and start the Ory Proxy. Upon first start, the Ory Proxy will ask you to log into your Ory Console +account. -```shell-session +```shell npm run proxy ``` @@ -116,7 +109,7 @@ import ToProd from '../_common/going-to-prod.mdx' ``` -```js {2,4-7} +```js var sdk = require("@ory/client") var ory = new sdk.FrontendApi( diff --git a/docs/getting-started/integrate-auth/15_nextjs.mdx b/docs/getting-started/integrate-auth/15_nextjs.mdx index 7b70faac5..f73beaa89 100644 --- a/docs/getting-started/integrate-auth/15_nextjs.mdx +++ b/docs/getting-started/integrate-auth/15_nextjs.mdx @@ -4,11 +4,11 @@ title: Integrate authentication into Next.js sidebar_label: Next.js --- +```mdx-code-block import Tabs from "@theme/Tabs" import TabItem from "@theme/TabItem" import CodeTabs from "@site/src/theme/Code/CodeTabs" -```mdx-code-block import Teaser from '../_common/teaser.mdx' import mp4 from '../_static/nextjs/screencast.mp4' import webm from '../_static/nextjs/screencast.webm' @@ -22,6 +22,7 @@ import webm from '../_static/nextjs/screencast.webm' ## Create Next.js app +```mdx-code-block +``` First we create a new Next.js 13 project: -```shell-session +```shell npx create-next-app@latest --typescript cd ``` @@ -46,22 +48,27 @@ cd ✔ What import alias would you like configured? … @ ``` +```mdx-code-block +``` First we create a new Next.js project: -```shell-session +```shell npx create-next-app@12.1 --typescript cd ``` +```mdx-code-block +``` ### Install Ory +```mdx-code-block {label: 'Next.js 12', value: '12'} ]}> +``` Ory provides integration tools that quickly combine Ory with Next.js. Let's install Ory's SDK, used to make API calls to Ory, and Ory's Integration Tools for JavaScript frameworks: -```shell-session +```shell npm i --save @ory/integrations @ory/client ``` @@ -97,14 +105,16 @@ going to production with a custom domain. More details in the "Go to production" ::: +```mdx-code-block +``` Ory provides integration tools that quickly combine Ory with Next.js. Let's install Ory's SDK, used to make API calls to Ory, and Ory's Integration Tools for JavaScript frameworks: -```shell-session +```shell npm i --save @ory/integrations @ory/client ``` @@ -127,11 +137,14 @@ going to production with a custom domain. More details in the "Go to production" ::: +```mdx-code-block +``` ### Require login to access the home page +```mdx-code-block +``` Next we add a session check to the default home page of the Next.js example application.The highlighted code is what we added to check whether the user is signed in, and redirect them to the login page if not: @@ -149,8 +163,10 @@ import homePage from '!!raw-loader!../../../code-examples/protect-page-login/nex {homePage} ``` +```mdx-code-block +``` Next we add a session check to the default home page of the Next.js example application.The highlighted code is what we added to check whether the user is signed in, and redirect them to the login page if not: @@ -159,13 +175,14 @@ check whether the user is signed in, and redirect them to the login page if not: import homePage12 from '!!raw-loader!../../../code-examples/protect-page-login/nextjs-12/pages/index.tsx' {homePage12} -``` +``` ### Run your Next.js app +```mdx-code-block +``` Great, that's it. Let's run your application. Set up your environment variables to connect with Ory's APIs -```shell-session +```shell export NEXT_PUBLIC_ORY_SDK_URL=https://$PROJECT_SLUG.projects.oryapis.com ``` and start the Next.js development server: -```shell-session +```shell npm run dev ``` -Then open [http://localhost:3000](http://localhost:3000) in your browser. are presented with Ory's Sign In page. Let's click on -sign up and create your first user. +Then open [http://localhost:3000](http://localhost:3000) in your browser. You are presented with Ory's Sign In page. Let's click +on sign up and create your first user. +```mdx-code-block +``` Great, that's it. Let's run your application. Set up your environment variables to connect with Ory's APIs @@ -202,15 +222,17 @@ import SdkEnvVar12 from '@site/src/components/SdkEnvVar' and start the Next.js development server: -```shell-session +```shell npm run dev ``` -Then open [http://localhost:3000](http://localhost:3000) in your browser. are presented with Ory's Sign In page. Let's click on -sign up and create your first user. +Then open [http://localhost:3000](http://localhost:3000) in your browser. You are presented with Ory's Sign In page. Let's click +on sign up and create your first user. +```mdx-code-block +``` ## Go to production diff --git a/docs/getting-started/integrate-auth/20_flutter-web-redirect.mdx b/docs/getting-started/integrate-auth/20_flutter-web-redirect.mdx index 597e8e635..b8b324d4a 100644 --- a/docs/getting-started/integrate-auth/20_flutter-web-redirect.mdx +++ b/docs/getting-started/integrate-auth/20_flutter-web-redirect.mdx @@ -42,12 +42,12 @@ import CodeBlock from '@theme/CodeBlock' Follow [this guide](../../guides/cli/01_installation.mdx) to install the Ory CLI on your machine. -### Why do I Need the Ory CLI? +### Why do I need the Ory CLI ```mdx-code-block import OryCLI from '../_common/ory-cli.mdx' - + ``` ## Create the authentication service @@ -67,7 +67,7 @@ import auth from '!!raw-loader!../../../code-examples/protect-page-login/flutter ## Add environment variables -Create a `.env` file in the root of the project to hold the `ORY_BASE_URL` variable. The value of the variable is the Ory proxy +Create a `.env` file in the root of the project to hold the `ORY_BASE_URL` variable. The value of the variable is the Ory Tunnel URL, for example `http://localhost:3005`. ```shell-session @@ -98,7 +98,7 @@ Run the following steps to get your application running: 1. Start your flutter web server ```shell-session -flutter run -d web-server --web-port 4005 +flutter run -d web-server --web-port 3000 ``` 2. Export the SDK configuration URL for the desired Ory project. You can use the provided playground project for testing, or @@ -116,13 +116,14 @@ import SdkEnvVar from '@site/src/components/SdkEnvVar' ``` -3. Run the Ory tunnel to expose Ory API under the same top-level domain as your application (`localhost`): +3. Run the Ory tunnel to expose Ory API under the same top-level domain as your application (`localhost`). Upon first start, the + Ory Tunnel will ask you to log into your Ory Console account. ```shell-session -ory tunnel --port 3005 http://localhost:4005 +ory tunnel --port 4000 http://localhost:3000 ``` -4. Open [http://localhost:4005](http://localhost:4005) to access the application. As the initial call is made by an +4. Open [http://localhost:3000](http://localhost:4005) to access the application. As the initial call is made by an unauthenticated user, the session check doesn't detect a valid session and redirects to the login page of the defined Ory project.

From there, you can create a new account or sign in using an existing identity. When you sign in, the session becomes valid and the application shows the `Home` page with the session data. diff --git a/docs/getting-started/integrate-auth/25_react.mdx b/docs/getting-started/integrate-auth/25_react.mdx index 0b309b5fb..7166619c5 100644 --- a/docs/getting-started/integrate-auth/25_react.mdx +++ b/docs/getting-started/integrate-auth/25_react.mdx @@ -20,17 +20,25 @@ import webm from '../_static/react/screencast.webm' First we create a new React project: -```shell-session +```shell npx create-react-app my_project --template typescript cd my_project ``` -## Install Ory SDK +## Install Ory SDK and CLI -Use `npm` to install the Ory SDK: +To interact with Ory's APIs we install the Ory SDK and CLI: -```shell-session -npm i --save @ory/client +```shell +npm i --save @ory/client @ory/cli +``` + +### Why do I need the Ory CLI + +```mdx-code-block +import OryCLI from '../_common/ory-cli.mdx' + + ``` ## Require login to access the app page @@ -68,13 +76,14 @@ CLI. It's like a microservice - an authentication API server on your domain! To get your project's SDK URL, go to , and copy the URL from the **API Endpoints** field. -```shell-session +```shell export ORY_SDK_URL=https://$PROJECT_SLUG.projects.oryapis.com ``` -and then start the Ory Tunnel: +In a new terminal window, start the Ory Tunnel. Upon first start, the Ory Tunnel will ask you to log into your Ory Console +account. -``` +```shell npx @ory/cli tunnel --dev http://localhost:3000 ``` @@ -94,8 +103,8 @@ import SdkEnvVar from '@site/src/components/SdkEnvVar' and start the React development server: -```shell-session -npm run start +```shell +npm start ``` Then open [http://localhost:3000](http://localhost:3000) in your browser. After loading, you now are presented with Ory's Sign In diff --git a/docs/getting-started/integrate-auth/30_vue.mdx b/docs/getting-started/integrate-auth/30_vue.mdx index 3ccd309b2..633d43c9f 100644 --- a/docs/getting-started/integrate-auth/30_vue.mdx +++ b/docs/getting-started/integrate-auth/30_vue.mdx @@ -20,17 +20,25 @@ import webm from '../_static/vue/screencast.webm' First, create a new Vue.js project. Run: -```shell-session +```shell npx @vue/cli create ory-spa --preset "Default (Vue 3)" cd ory-spa ``` -## Install Ory SDK +## Install Ory SDK and CLI -Use `npm` to install the Ory SDK: +To interact with Ory's APIs we install the Ory SDK and CLI: -```shell-session -npm i --save @ory/client +```shell +npm i --save @ory/client @ory/cli +``` + +### Why do I need the Ory CLI + +```mdx-code-block +import OryCLI from '../_common/ory-cli.mdx' + + ``` ## Check for session in component @@ -52,31 +60,15 @@ import CodeBlock from '@theme/CodeBlock' ## Run Ory APIs on `localhost` -The Ory security model uses HTTP cookies to manage sessions, tokens, and cookies. To do that, Ory APIs must be exposed on the same -domain as your application. - -In the case of this example, the domain of your application, which runs on your local machine, is `localhost`. - -:::info - -When developing locally, use either `localhost` or `127.0.0.1`, but not both. Although technically these mean the same thing, -they're different hostnames. - -Using both interchangeably in your code can cause problems with the origin of HTTP cookies sent by the application. When that -happens Ory APIs might not be able to read the cookies sent by your app. - -::: - -To get your application that runs locally and Ory APIs on the same domain, use Ory Tunnel - a development tool bundled with Ory -CLI. It's like a microservice - an authentication API server on your domain! +In a new terminal window, run the Ory Tunnel: -```shell-session +```shell npx @ory/cli tunnel --dev http://localhost:8080 ``` Ory APIs are now mirrored on `http://localhost:4000`. Use that URL as the `baseUrl` for the `@ory/client` SDK (see -`HelloWorld.vue` code above). The `--dev` flag disables security checks for easier integration and should not be used when -deploying the Tunnel to a staging environment. +`HelloWorld.vue` code above). The `--dev` flag disables security checks for easier integration and should not be used when running +the Tunnel in an insecure environment like public networks. ## Run your Vue.js app @@ -92,7 +84,7 @@ import SdkEnvVar from '@site/src/components/SdkEnvVar' Next, start the Next.js development server: -```shell-session +```shell npm run serve ``` @@ -130,7 +122,7 @@ import handlerApi from '!!raw-loader!../../../code-examples/auth-api/expressjs/i Finally, start the server: -```shell-session +```shell node index.js ``` diff --git a/docs/getting-started/integrate-auth/40_dotnet.mdx b/docs/getting-started/integrate-auth/40_dotnet.mdx index 0e4ad31a8..b294015a8 100644 --- a/docs/getting-started/integrate-auth/40_dotnet.mdx +++ b/docs/getting-started/integrate-auth/40_dotnet.mdx @@ -28,13 +28,13 @@ You can find the code of the sample application Follow [this guide](../../guides/cli/01_installation.mdx) to install the Ory CLI on your machine. -### Why do I Need the Ory CLI? +### Why do I need the Ory CLI -Ory CLI provides a convenient way to configure and manage projects. Additionally, the CLI contains Ory Tunnel, which exposes Ory -APIs under the same top-level domain as your application to ensure that there are no CORS issues. This allows the application that -runs on your machine to connect to Ory APIs. +```mdx-code-block +import OryCLI from '../_common/ory-cli.mdx' -[![Ory Tunnel](https://mermaid.ink/img/pako:eNq9U7FOxDAM_RUrCwNUvQGWDEitQOgG4CS6IHUJqXuNaJPiOCCE-HeS9uA47iSY6BDV9vOL_Ry_Ce0aFFJ4fApoNV4YtSY11BbipwI7G4YHpNkeFbHRZlSWoQTloST34g9FixS9d4GgGEdQvI-oEuKWXqEK1mJ_gGK13ECOfDJ8bWdQmZ2fHxcSri4r6JhHmee906rvnGd5tlgsZliRYJUE3aF-BI_eG7dhqCaG1fJgMPpjOIuZrTI9NtuUrNj1pRuyUgJhYwg1A7v9gk5jQbnHvs2iUM9GY4ytjc0fvktXbmo92NKfGLYtJY5f4TeOEcisOwbXwpQ3IrWOhtjN2ngmxVERULbJHcHEMJ36p0g-aB3la0M_o77J9Zs021n920g31e7OdMf5OdQkHoJ2ltHG5ytOxIA0KNPEZXlL0FpwhwPWQsbfRtFjLWr7HnFpa-5erRaSKeCJCGOj-HOxhGxV77-8l41hR19OnMzreSWnzXz_ADSbKoU?type=png)](https://mermaid-js.github.io/mermaid-live-editor/edit#pako:eNq9U7FOxDAM_RUrCwNUvQGWDEitQOgG4CS6IHUJqXuNaJPiOCCE-HeS9uA47iSY6BDV9vOL_Ry_Ce0aFFJ4fApoNV4YtSY11BbipwI7G4YHpNkeFbHRZlSWoQTloST34g9FixS9d4GgGEdQvI-oEuKWXqEK1mJ_gGK13ECOfDJ8bWdQmZ2fHxcSri4r6JhHmee906rvnGd5tlgsZliRYJUE3aF-BI_eG7dhqCaG1fJgMPpjOIuZrTI9NtuUrNj1pRuyUgJhYwg1A7v9gk5jQbnHvs2iUM9GY4ytjc0fvktXbmo92NKfGLYtJY5f4TeOEcisOwbXwpQ3IrWOhtjN2ngmxVERULbJHcHEMJ36p0g-aB3la0M_o77J9Zs021n920g31e7OdMf5OdQkHoJ2ltHG5ytOxIA0KNPEZXlL0FpwhwPWQsbfRtFjLWr7HnFpa-5erRaSKeCJCGOj-HOxhGxV77-8l41hR19OnMzreSWnzXz_ADSbKoU) + +``` ## Create ASP.NET app @@ -70,7 +70,7 @@ var builder = WebApplication.CreateBuilder(args); // add-lines-start // configure http port explicitly to override generated settings from launchSettings.json builder.WebHost.ConfigureKestrel(opt => { - var port = builder.Configuration.GetValue("APP_PORT", 5001); + var port = builder.Configuration.GetValue("APP_PORT", 3000); opt.ListenAnyIP(port); }); // add-lines-end @@ -109,7 +109,7 @@ var builder = WebApplication.CreateBuilder(args); // configure http port explicitly to override generated settings from launchSettings.json builder.WebHost.ConfigureKestrel(opt => { - var port = builder.Configuration.GetValue("APP_PORT", 5001); + var port = builder.Configuration.GetValue("APP_PORT", 3000); opt.ListenAnyIP(port); }); @@ -208,7 +208,7 @@ var builder = WebApplication.CreateBuilder(args); // configure http port explicitly to override generated settings from launchSettings.json builder.WebHost.ConfigureKestrel(opt => { - var port = builder.Configuration.GetValue("APP_PORT", 5001); + var port = builder.Configuration.GetValue("APP_PORT", 3000); opt.ListenAnyIP(port); }); @@ -281,10 +281,10 @@ With all of the pieces in place, it's time to test your application. Follow thes 2. Run Ory Tunnel to mirror the Ory API endpoints on your application's domain (`localhost`): ```shell-session - ory tunnel --project playground --dev http://localhost:5001 + ory tunnel --project playground --dev http://localhost:3000 ``` -3. Open [localhost:5001](http://localhost:5001) to access the application. As the initial call is made by an unauthenticated user, +3. Open [localhost:3000](http://localhost:3000) to access the application. As the initial call is made by an unauthenticated user, the middleware doesn't detect a valid session and redirects to the login page of the defined Ory project. 4. From there, you can create a new account or sign in using an existing identity. When you sign in, the session becomes valid and the application shows the `Index` page with the session data. diff --git a/docs/guides/cli/20_proxy-and-tunnel.mdx b/docs/guides/cli/20_proxy-and-tunnel.mdx index cd9c4a36d..30d3884c4 100644 --- a/docs/guides/cli/20_proxy-and-tunnel.mdx +++ b/docs/guides/cli/20_proxy-and-tunnel.mdx @@ -230,15 +230,6 @@ This is an example of a JWT with session and identity data: } ``` -### Use Ory Proxy when self-hosting - -You can use Ory Proxy in a production setup when self-hosting Ory components. Set the entry point URL to the domain where you want -to expose the app through the Ory Proxy: - -```shell -ory proxy --project --workspace http://localhost:3000 https://my-domain.com -``` - ### Use Ory Proxy with virtual and dedicated servers To use Ory Proxy with an application deployed on a VM or a Dedicated Server, run the application server and Ory Proxy in parallel.