From 83aec01d79aa2771aa3b66ac357937a1f4ca2fab Mon Sep 17 00:00:00 2001 From: wassimoo <12980387+wassimoo@users.noreply.github.com> Date: Thu, 6 Nov 2025 14:20:06 +0100 Subject: [PATCH 1/5] chore: update Go module dependencies and fix documentation URL --- code-examples/protect-page-login/go/go.mod | 6 ++--- code-examples/protect-page-login/go/go.sum | 25 +++---------------- docs/getting-started/integrate-auth/01_go.mdx | 2 +- 3 files changed, 8 insertions(+), 25 deletions(-) diff --git a/code-examples/protect-page-login/go/go.mod b/code-examples/protect-page-login/go/go.mod index 3e122d0114..e9e77f9e65 100644 --- a/code-examples/protect-page-login/go/go.mod +++ b/code-examples/protect-page-login/go/go.mod @@ -1,7 +1,7 @@ module github.com/ory/docs/code-examples/go -go 1.17 +go 1.25.3 -require github.com/ory/client-go v1.15.5 +require github.com/ory/client-go v1.22.8 -require golang.org/x/oauth2 v0.23.0 // indirect +require golang.org/x/oauth2 v0.32.0 // indirect diff --git a/code-examples/protect-page-login/go/go.sum b/code-examples/protect-page-login/go/go.sum index 725238c3a7..b5c1fecdde 100644 --- a/code-examples/protect-page-login/go/go.sum +++ b/code-examples/protect-page-login/go/go.sum @@ -1,21 +1,4 @@ -cloud.google.com/go/compute/metadata v0.3.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/ory/client-go v1.15.5 h1:WZ2p9O2H8J6vMa6e1oj0+RA9GQt4Laa7sY4rA0/D7wk= -github.com/ory/client-go v1.15.5/go.mod h1:kF9vH8mfpLJvgJus6dOjSXZ6KoswiwwcJ25hP7w2O8k= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs= -golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +github.com/ory/client-go v1.22.8 h1:v1NCqmKIKFQFYQihWUJuksvxILujvVA8HUOCAs5Lxr0= +github.com/ory/client-go v1.22.8/go.mod h1:o/1hF5MKq3gyn9nUWZF/VVz35nitCzsGfIwl5SXVJ1Y= +golang.org/x/oauth2 v0.32.0 h1:jsCblLleRMDrxMN29H3z/k1KliIvpLgCkE6R8FXXNgY= +golang.org/x/oauth2 v0.32.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA= diff --git a/docs/getting-started/integrate-auth/01_go.mdx b/docs/getting-started/integrate-auth/01_go.mdx index 1ffff2d7d9..87179409fb 100644 --- a/docs/getting-started/integrate-auth/01_go.mdx +++ b/docs/getting-started/integrate-auth/01_go.mdx @@ -119,7 +119,7 @@ go run . npx @ory/cli tunnel --dev http://localhost:3000 ``` -3. Open [http://localhost:4000](http://localhost:4000) to access the application. Since the initial call is made by an +3. Open [http://localhost:3000](http://localhost:3000) to access the application. Since 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.

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 `Dashboard` page with the session data. From b6a0ba1c1040ff5ed47663465a2c1eb9723a6944 Mon Sep 17 00:00:00 2001 From: wassimoo <12980387+wassimoo@users.noreply.github.com> Date: Thu, 6 Nov 2025 15:00:26 +0100 Subject: [PATCH 2/5] docs: add README for Protect page login example in Go and update tunnel command --- code-examples/protect-page-login/go/README.md | 33 +++++++++++++++++++ docs/getting-started/integrate-auth/01_go.mdx | 2 +- 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 code-examples/protect-page-login/go/README.md diff --git a/code-examples/protect-page-login/go/README.md b/code-examples/protect-page-login/go/README.md new file mode 100644 index 0000000000..eef8abe9bd --- /dev/null +++ b/code-examples/protect-page-login/go/README.md @@ -0,0 +1,33 @@ +# Protect page login Example in Go + +This example demonstrates protecting a page in a Go web server using the Ory SDK and Ory Account Experience. + +For the full step-by-step guide, see: [Integrate authentication into Go](https://www.ory.sh/docs/getting-started/integrate-auth/go) + +## Prerequisites + +- Go 1.20+ +- Node.js (to run Ory CLI via `npx`) +- An Ory Network project and the Ory CLI logged in + +## Run locally + +1. Build and run the server: + +```bash +go build -o server +./server +``` + +2. In another terminal, start the Ory Tunnel pointing to your local app: + +```bash +npx @ory/cli tunnel --dev http://localhost:3000 --project +``` + +3. Open http://localhost:3000 in your browser. You will be redirected to the Ory Account Experience for sign-in, and then returned to the protected page. + +## Notes + +- The server reads the tunnel port from `TUNNEL_PORT` (defaults to `4000`) and app port from `PORT` (defaults to `3000`). +- This example’s middleware uses `ToSession` to validate the user session and redirects unauthenticated users to the login UI served via the Ory Tunnel. diff --git a/docs/getting-started/integrate-auth/01_go.mdx b/docs/getting-started/integrate-auth/01_go.mdx index 87179409fb..fc6e426919 100644 --- a/docs/getting-started/integrate-auth/01_go.mdx +++ b/docs/getting-started/integrate-auth/01_go.mdx @@ -116,7 +116,7 @@ go run . will ask you to log into your Ory Console account. ```shell -npx @ory/cli tunnel --dev http://localhost:3000 +npx @ory/cli tunnel --dev http://localhost:3000 --project ``` 3. Open [http://localhost:3000](http://localhost:3000) to access the application. Since the initial call is made by an From 3cbafd08b191ae609c987c8674f2c7d475079a82 Mon Sep 17 00:00:00 2001 From: wassimoo <12980387+wassimoo@users.noreply.github.com> Date: Thu, 6 Nov 2025 15:56:23 +0100 Subject: [PATCH 3/5] docs: add additional note on server configuration in Protect page login example README --- code-examples/protect-page-login/go/README.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/code-examples/protect-page-login/go/README.md b/code-examples/protect-page-login/go/README.md index eef8abe9bd..bd6dd98688 100644 --- a/code-examples/protect-page-login/go/README.md +++ b/code-examples/protect-page-login/go/README.md @@ -1,8 +1,10 @@ # Protect page login Example in Go -This example demonstrates protecting a page in a Go web server using the Ory SDK and Ory Account Experience. +This example demonstrates protecting a page in a Go web server using the Ory SDK +and Ory Account Experience. -For the full step-by-step guide, see: [Integrate authentication into Go](https://www.ory.sh/docs/getting-started/integrate-auth/go) +For the full step-by-step guide, see: +[Integrate authentication into Go](https://www.ory.sh/docs/getting-started/integrate-auth/go) ## Prerequisites @@ -25,9 +27,12 @@ go build -o server npx @ory/cli tunnel --dev http://localhost:3000 --project ``` -3. Open http://localhost:3000 in your browser. You will be redirected to the Ory Account Experience for sign-in, and then returned to the protected page. +3. Open http://localhost:3000 in your browser. You will be redirected to the Ory + Account Experience for sign-in, and then returned to the protected page. ## Notes -- The server reads the tunnel port from `TUNNEL_PORT` (defaults to `4000`) and app port from `PORT` (defaults to `3000`). -- This example’s middleware uses `ToSession` to validate the user session and redirects unauthenticated users to the login UI served via the Ory Tunnel. +- The server reads the tunnel port from `TUNNEL_PORT` (defaults to `4000`) and + app port from `PORT` (defaults to `3000`). +- This example’s middleware uses `ToSession` to validate the user session and + redirects unauthenticated users to the login UI served via the Ory Tunnel. From a71fdd5c874024f839df46398e9dc906f2119efc Mon Sep 17 00:00:00 2001 From: wassimoo <12980387+wassimoo@users.noreply.github.com> Date: Fri, 7 Nov 2025 16:51:12 +0100 Subject: [PATCH 4/5] docs: update title in README for Protect page with login example in Go --- code-examples/protect-page-login/go/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code-examples/protect-page-login/go/README.md b/code-examples/protect-page-login/go/README.md index bd6dd98688..9f3bfe2d7d 100644 --- a/code-examples/protect-page-login/go/README.md +++ b/code-examples/protect-page-login/go/README.md @@ -1,4 +1,4 @@ -# Protect page login Example in Go +# Protect page with login example in Go This example demonstrates protecting a page in a Go web server using the Ory SDK and Ory Account Experience. From 8f99fc99f7cff75086e710542f08a744ee28dc49 Mon Sep 17 00:00:00 2001 From: Wassim <12980387+wassimoo@users.noreply.github.com> Date: Mon, 10 Nov 2025 09:57:56 +0100 Subject: [PATCH 5/5] docs: update README title to reflect Ory Authentication example in Go --- code-examples/protect-page-login/go/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code-examples/protect-page-login/go/README.md b/code-examples/protect-page-login/go/README.md index 9f3bfe2d7d..2969b21d7b 100644 --- a/code-examples/protect-page-login/go/README.md +++ b/code-examples/protect-page-login/go/README.md @@ -1,4 +1,4 @@ -# Protect page with login example in Go +# Ory Authentication Example with Go This example demonstrates protecting a page in a Go web server using the Ory SDK and Ory Account Experience.