Skip to content

Commit 4b418ec

Browse files
authored
Merge branch 'master' into patch-1
2 parents 82b3474 + 993e962 commit 4b418ec

31 files changed

Lines changed: 1789 additions & 4483 deletions

File tree

CONTRIBUTING.md

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
- [FAQ](#faq)
1111
- [How can I contribute?](#how-can-i-contribute)
1212
- [Communication](#communication)
13-
- [Contribute examples](#contribute-examples)
13+
- [Contribute examples or community projects](#contribute-examples-or-community-projects)
1414
- [Contribute code](#contribute-code)
1515
- [Contribute documentation](#contribute-documentation)
1616
- [Disclosing vulnerabilities](#disclosing-vulnerabilities)
@@ -125,34 +125,16 @@ the projects that you are interested in.
125125

126126
Also, [follow us on Twitter](https://twitter.com/orycorp).
127127

128-
## Contribute examples
128+
## Contribute examples or community projects
129129

130-
One of the most impactful ways to contribute is by adding examples. You can find
131-
an overview of examples using Ory services on the
132-
[documentation examples page](https://www.ory.sh/docs/examples). Source code for
133-
examples can be found in most cases in the
134-
[ory/examples](https://github.com/ory/examples) repository.
130+
One of the most impactful ways to contribute is by adding code examples or other
131+
Ory-related code. You can find an overview of community code in the
132+
[awesome-ory](https://github.com/ory/awesome-ory) repository.
135133

136134
_If you would like to contribute a new example, we would love to hear from you!_
137135

138-
Please [open an issue](https://github.com/ory/examples/issues/new/choose) to
139-
describe your example before you start working on it. We would love to provide
140-
guidance to make for a pleasant contribution experience. Go through this
141-
checklist to contribute an example:
142-
143-
1. Create a GitHub issue proposing a new example and make sure it's different
144-
from an existing one.
145-
1. Fork the repo and create a feature branch off of `master` so that changes do
146-
not get mixed up.
147-
1. Add a descriptive prefix to commits. This ensures a uniform commit history
148-
and helps structure the changelog. Please refer to this
149-
[Convential Commits configuration](https://github.com/ory/docs/blob/master/.github/workflows/conventional_commits.yml)
150-
for the list of accepted prefixes. You can read more about the Conventional
151-
Commit specification
152-
[at their site](https://www.conventionalcommits.org/en/v1.0.0/).
153-
1. Create a `README.md` that explains how to use the example. (Use
154-
[the README template](https://github.com/ory/examples/blob/master/_common/README.md)).
155-
1. Open a pull request and maintainers will review and merge your example.
136+
Please [open a pull request at awesome-ory](https://github.com/ory/awesome-ory/)
137+
to add your example or Ory-related project to the awesome-ory README.
156138

157139
## Contribute code
158140

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Express.js Authentication Example
2+
3+
This example demonstrates how to implement authentication in an Express.js
4+
application using Ory.
5+
6+
## Prerequisites
7+
8+
- Node.js installed on your machine
9+
- An Ory Network account with a project set up
10+
- Your Ory Project ID
11+
12+
## Getting Started
13+
14+
### 1. Install Dependencies
15+
16+
First, install the necessary dependencies by running:
17+
18+
```bash
19+
npm install
20+
```
21+
22+
### 2. Start the Application
23+
24+
You can start the application with:
25+
26+
```bash
27+
npm run dev
28+
```
29+
30+
### 3. Run the Ory Proxy
31+
32+
To ensure cookies are on the same domain, run the Ory Proxy with your project
33+
ID:
34+
35+
```bash
36+
ORY_PROJECT_ID=<Project_ID> npm run proxy
37+
```
38+
39+
Replace `<Project_ID>` with your actual Ory Project ID from the Ory Console.
40+
41+
Now head to http://localhost:4000 to test.

code-examples/protect-page-login/expressjs/app.js

Lines changed: 0 additions & 42 deletions
This file was deleted.

code-examples/protect-page-login/expressjs/bin/www

Lines changed: 0 additions & 86 deletions
This file was deleted.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const app = require("express")()
2+
// highlight-next-line
3+
const sdk = require("@ory/client-fetch")
4+
5+
// highlight-start
6+
const ory = new sdk.FrontendApi(
7+
new sdk.Configuration({
8+
basePath: process.env.ORY_SDK_URL || "http://localhost:4000/.ory",
9+
}),
10+
)
11+
// highlight-end
12+
13+
// highlight-start
14+
const requireAuth = async (req, res, next) => {
15+
try {
16+
const session = await ory.toSession({ cookie: req.header("cookie") })
17+
req.session = session
18+
next()
19+
} catch (error) {
20+
res.redirect("/.ory/ui/login")
21+
}
22+
}
23+
// highlight-end
24+
25+
app.get("/", requireAuth, (req, res) => {
26+
// highlight-next-line
27+
res.json(req.session)
28+
})
29+
30+
const port = process.env.PORT || 3000
31+
app.listen(port, () => console.log(`Server is running on port ${port}`))

0 commit comments

Comments
 (0)