Skip to content

Commit c13701b

Browse files
authored
docs: update hydra quickstart (#2001)
1 parent 24966c8 commit c13701b

File tree

9 files changed

+107
-50
lines changed

9 files changed

+107
-50
lines changed

docs/hydra/faq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ challenge will always instruct you to show the login UI.
236236
Hydra scales according to 12 factor principles. Just add another instance with the same config. Please check the
237237
[documentation section for 12 factor principles](https://www.ory.sh/docs/ecosystem/cloud-native).There is also some information on
238238
collecting statistics in the section on [prometheus](https://github.com/prometheus) in the
239-
[five minute tutorial](./5min-tutorial.mdx).
239+
[five minute tutorial](self-hosted/quickstart.mdx).
240240

241241
## Is it possible to disable/enable certain flows in Hydra?
242242

docs/hydra/self-hosted/configure-deploy.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ The goal of this chapter is to introduce you to a fully functional set up that i
77
Consent Provider reference implementation.
88

99
The goal of this section is to familiarize you with the specifics of setting up Ory Hydra in your environment. Before starting
10-
with this section, please check out the [tutorial](../5min-tutorial). It will teach you the most important flows and settings for
10+
with this section, please check out the [tutorial](quickstart.mdx). It will teach you the most important flows and settings for
1111
Hydra.
1212

1313
This guide will:

docs/hydra/self-hosted/deploy-hydra-example.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ Congratulations, you have installed and configured the PostgreSQL database. Next
153153
rm LICENSE`}</CodeBlock>
154154
```
155155

156-
4. Download the [Quickstart](../5min-tutorial) configuration files
156+
4. Download the [Quickstart](quickstart.mdx) configuration files
157157

158158
```mdx-code-block
159159
<CodeBlock className="language-shell">{`cd ../config

docs/hydra/self-hosted/gitlab.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Even though we're mostly using Ory Hydra in a docker-container, having the comma
1313
please install Ory Hydra as explained in the [installation-guide](./install). You'll also need
1414
[docker](https://docs.docker.com/get-docker/) and [docker-compose](https://docs.docker.com/compose/install/).
1515

16-
The [5-min-tutorial](../5min-tutorial) might be worth checking out upfront. It'll a give a nice quick overview of how OAuth2 is
16+
The [5-min-tutorial](quickstart.mdx) might be worth checking out upfront. It'll a give a nice quick overview of how OAuth2 is
1717
working within Ory Hydra with a minimal example. We assume basic knowledge, here.
1818

1919
If you don't yet have the source code of Ory Hydra, which we'll need for the `docker-compose` yaml-files and the

docs/hydra/self-hosted/kubernetes-helm-chart.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ curl http://example-idp.localhost/
206206
http://public.hydra.localhost/.well-known/openid-configuration
207207
```
208208

209-
Next, you can follow the [5 Minute Tutorial](../5min-tutorial), skipping the `git` and `docker-compose` set up sections. Assuming
209+
Next, you can follow the [5 Minute Tutorial](quickstart.mdx), skipping the `git` and `docker-compose` set up sections. Assuming
210210
you have Ory Hydra installed locally, you can rewrite commands from, for example,
211211

212212
```sh

docs/hydra/5min-tutorial.mdx renamed to docs/hydra/self-hosted/quickstart.mdx

Lines changed: 96 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,113 @@
11
---
2-
id: 5min-tutorial
3-
title: 5 minute tutorial
2+
id: quickstart
3+
title: Ory Hydra OAuth2 Server Quickstart
44
sidebar_label: Quickstart
55
---
66

7-
import CodeFromRemote from "@theme/CodeFromRemote"
8-
9-
This tutorial walks you through a quick setup of Ory Hydra Federation Server and an exemplary User Login & Consent App based on
7+
In this quickstart, you will set up Ory Hydra OAuth2 & OpenID Connect Server and an exemplary User Login & Consent App using
108
Docker Compose. You need to have the latest [Docker](https://www.docker.com) and [Docker Compose](https://docs.docker.com/compose)
11-
version installed, as well as [`jq`](https://stedolan.github.io/jq/download/).
9+
version and Git installed, as well as [`jq`](https://stedolan.github.io/jq/download/).
10+
11+
You do not want to self-host? Try
12+
[out common OAuth2 grants on the fully managed version of Ory Hydra](../../getting-started/ory-network-oauth2.mdx).
13+
14+
```mdx-code-block
15+
import CodeFromRemote from "@theme/CodeFromRemote"
16+
```
1217

1318
![OAuth2 Flow with Open Source OAuth2 Server Ory Hydra](_static/oauth2-flow.gif)
1419

20+
```mdx-code-block
1521
<p align="center">
1622
<iframe width="560" height="315" src="https://www.youtube.com/embed/tlO9p2E501A" frameborder="0" allowfullscreen />
1723
</p>
24+
```
25+
26+
To get started, clone the Ory Hydra locally:
27+
28+
```
29+
git clone https://github.com/ory/hydra.git
30+
cd hydra
31+
```
1832

19-
We will use the Docker Compose configuration in the Ory Hydra code base. Getting the Hydra source code is easy:
33+
Run the following command(s) to start the OAuth2 server:
2034

21-
- if you have Go 1.15+ installed: `go get -d github.com/ory/hydra`
22-
- if you have Git installed: `git clone https://github.com/ory/hydra.git`
23-
- otherwise: download the [Hydra source code](https://github.com/ory-am/hydra/archive/master.zip). and extract it somewhere
35+
````mdx-code-block
36+
import Tabs from '@theme/Tabs'
37+
import TabItem from '@theme/TabItem'
38+
import MacOS from '@site/src/components/Install/MacOS'
39+
import Linux from '@site/src/components/Install/Linux'
40+
import Windows from '@site/src/components/Install/Windows'
2441
25-
Change into the directory with the Hydra source code and run the following command to start the needed containers:
42+
<Tabs>
43+
<TabItem value="postgres-prod" label="PostgreSQL (prod)" default>
44+
45+
Run the latest Ory Hydra production build:
2646
2747
```sh
28-
docker-compose -f quickstart.yml \
48+
docker compose -f quickstart.yml \
2949
-f quickstart-postgres.yml \
30-
up --build
50+
up
3151
3252
Starting hydra_postgresd_1
3353
Starting hydra_hydra_1
3454
[...]
3555
```
3656
37-
This command adds support for PostgreSQL. If you wish to use another database backend, you can run this command to use MySQL:
57+
</TabItem>
58+
<TabItem value="postgres-dev" label="PostgreSQL (dev)">
59+
60+
61+
Run the current commit of Ory Hydra.
3862
3963
```sh
40-
docker-compose -f quickstart.yml \
41-
-f quickstart-mysql.yml \
42-
up --build
64+
docker compose -f quickstart.yml \
65+
-f quickstart-postgres.yml \
66+
up \
67+
--build
68+
69+
Starting hydra_postgresd_1
70+
Starting hydra_hydra_1
71+
[...]
4372
```
4473
45-
This one to use CockroachDB:
74+
Building the image will override the Ory Hydra production image on your local registry. To download the latest
75+
production image again, run:
4676
4777
```sh
48-
docker-compose -f quickstart.yml \
49-
-f quickstart-cockroach.yml \
50-
up --build
78+
docker compose -f quickstart.yml pull hydra --policy always
5179
```
5280
53-
Or simply omit the second file to default to SQLite:
5481
55-
```sh
56-
docker-compose -f quickstart.yml \
57-
up --build
82+
</TabItem>
83+
<TabItem value="mysql-prod" label="MySQL">
84+
85+
86+
```shell
87+
docker compose -f quickstart.yml \
88+
-f quickstart-mysql.yml \
89+
up
5890
```
5991
60-
This command makes Docker Compose start up a database server and a basic base Ory Hydra server that uses this database. If you
61-
need more details on this, please examine the `scripts/5-min-tutorial.sh` and `docker-compose*.yml` files.
92+
93+
</TabItem>
94+
<TabItem value="sqlite" label="SQLite" default>
95+
96+
97+
```shell
98+
docker compose -f quickstart.yml up
99+
```
100+
101+
102+
</TabItem>
103+
<TabItem value="observability" label="Observability">
104+
62105
63106
You may also extend the command above to enable distributed tracing. The tracing UI is exposed at
64107
[http://127.0.0.1:16686/search](http://127.0.0.1:16686/search):
65108
66109
```sh
67-
docker-compose -f quickstart.yml \
110+
docker compose -f quickstart.yml \
68111
-f quickstart-postgres.yml \
69112
-f quickstart-tracing.yml \
70113
up --build
@@ -74,32 +117,39 @@ Hydra provides an endpoint for Prometheus to scrape as a target. You can run the
74117
and status of Hydra is exposed at targets page in Prometheus [http://localhost:9090/targets](http://localhost:9090/targets):
75118
76119
```sh
77-
docker-compose -f quickstart.yml \
120+
docker compose -f quickstart.yml \
78121
-f quickstart-prometheus.yml \
79122
up --build
80123
```
81124
125+
126+
</TabItem>
127+
<TabItem value="hsm" label="HSM">
128+
129+
82130
If you want to test Hardware Security Module add `-f quickstart-hsm.yml`. For more information head over to
83-
[HSM support](./self-hosted/hsm-support.md).
131+
[HSM support](hsm-support.md).
84132
85133
```sh
86-
docker-compose -f quickstart.yml \
134+
docker compose -f quickstart.yml \
87135
-f quickstart-hsm.yml \
88136
up --build
89137
```
90138
91-
Let's confirm that everything is working by creating an OAuth 2.0 Client.
92139
93-
Note: The following commands run Hydra inside Docker. If you have the Ory Hydra CLI installed locally, you can omit
94-
`docker-compose -f quickstart.yml exec /hydra` in front of each command.
140+
</TabItem>
141+
</Tabs>
142+
````
143+
144+
Let's confirm that everything is working by creating an OAuth 2.0 Client.
95145

96146
The OAuth 2.0 client uses port `4444` and `4445`. The former is Ory Hydra's public endpoint, the latter its administrative
97-
endpoint. For more information head over to [Exposing Administrative and Public API Endpoints](./self-hosted/production).
147+
endpoint. For more information head over to [Exposing Administrative and Public API Endpoints](production.md).
98148

99149
Let's create the OAuth 2.0 Client:
100150

101151
```sh
102-
client=$(docker-compose -f quickstart.yml exec hydra \
152+
client=$(docker compose -f quickstart.yml exec hydra \
103153
hydra create client \
104154
--endpoint http://127.0.0.1:4445/ \
105155
--format json \
@@ -113,7 +163,7 @@ client_secret=$(echo $client | jq -r '.client_secret')
113163
Let's perform the client credentials grant:
114164

115165
```sh
116-
docker-compose -f quickstart.yml exec hydra \
166+
docker compose -f quickstart.yml exec hydra \
117167
hydra perform client-credentials \
118168
--endpoint http://127.0.0.1:4444/ \
119169
--client-id "$client_id" \
@@ -128,7 +178,7 @@ EXPIRY 2022-06-27 11:50:28.244046504 +0000 UTC m=+3599.059213960
128178
Let's perform token introspection on that token. Make sure to copy the token you just got and not the dummy value.
129179

130180
```sh
131-
docker-compose -f quickstart.yml exec hydra \
181+
docker compose -f quickstart.yml exec hydra \
132182
hydra introspect token \
133183
--format json-pretty \
134184
--endpoint http://127.0.0.1:4445/ \
@@ -151,7 +201,7 @@ Next, we will perform the OAuth 2.0 Authorization Code Grant. For that, we must
151201
that grant:
152202

153203
```sh
154-
code_client=$(docker-compose -f quickstart.yml exec hydra \
204+
code_client=$(docker compose -f quickstart.yml exec hydra \
155205
hydra create client \
156206
--endpoint http://127.0.0.1:4445 \
157207
--grant-type authorization_code,refresh_token \
@@ -171,7 +221,7 @@ The following command starts a server that serves an example web application. Th
171221
Authorization Code Flow using Ory Hydra. The web server runs on [http://127.0.0.1:5555](http://127.0.0.1:5555).
172222

173223
```sh
174-
docker-compose -f quickstart.yml exec hydra \
224+
docker compose -f quickstart.yml exec hydra \
175225
hydra perform authorization-code \
176226
--client-id $code_client_id \
177227
--client-secret $code_client_secret \
@@ -195,22 +245,24 @@ Great! You installed Ory Hydra, connected the CLI, created a client and complete
195245
clean up this set up in order to avoid conflicts with other tutorials from this guide:
196246
197247
```sh
198-
docker-compose -f quickstart.yml kill
199-
docker-compose -f quickstart.yml rm -f -v
248+
docker compose -f quickstart.yml kill
249+
docker compose -f quickstart.yml rm -f -v
200250
```
201251
202252
## Quickstart configuration
203253
204254
In this tutorial we use a simplified configuration. You can find it in
205255
[`contrib/quickstart/5-min/hydra.yml`](https://github.com/ory/hydra/blob/master/contrib/quickstart/5-min/hydra.yml). The
206-
configuration gets loaded in docker-compose as specified in the
256+
configuration gets loaded in docker compose as specified in the
207257
[`quickstart.yml`](https://github.com/ory/hydra/blob/master/quickstart.yml).
208258
259+
```mdx-code-block
209260
<CodeFromRemote
210261
lang="js"
211262
link="https://github.com/ory/hydra/blob/master/contrib/quickstart/5-min/hydra.yml"
212263
src="https://raw.githubusercontent.com/ory/hydra/master/contrib/quickstart/5-min/hydra.yml"
213264
/>
265+
```
214266
215-
Have a look at the [reference configuration](./reference/configuration.mdx) for further information on all possible configuration
267+
Have a look at the [reference configuration](../reference/configuration.mdx) for further information on all possible configuration
216268
options.

src/sidebar.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ const selfhostingSidebar = [
786786
label: "Ory Hydra",
787787
items: [
788788
"hydra/self-hosted/install",
789-
"hydra/5min-tutorial",
789+
"hydra/self-hosted/quickstart",
790790
"hydra/self-hosted/deploy-hydra-example",
791791
"hydra/self-hosted/upgrade",
792792
{

vercel.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,6 +1168,11 @@
11681168
"source": "/docs/identities/sign-in/saml",
11691169
"destination": "/docs/kratos/organizations/",
11701170
"permanent": false
1171+
},
1172+
{
1173+
"source": "/docs/hydra/5min-tutorial",
1174+
"destination": "/docs/hydra/self-hosted/quickstart",
1175+
"permanent": false
11711176
}
11721177
]
11731178
}

0 commit comments

Comments
 (0)