{title}
-- by @{author} -
+{title}
++ by{" "} + + @{author} + +
+{title}
} - {description &&{description}
} + {title &&{title}
} + {description && ( +{description}
+ )}+ {title} +
++ {description} +
+Quickstart guides
++ No code examples are available for this product yet. +
+ )} +Authentication overview
++ This section explains how authentication works in{" "} + {productLabel}. +
+ + {product === "network" && ( ++ Because you're using Ory Network, authentication flows are fully + managed and hosted for you. +
+ )} + + {product === "oel" && ( ++ In Ory Enterprise License, you run the control plane yourself but get + enterprise support and features. +
+ )} + + {product === "oss" && ( ++ With Ory Open Source, you assemble and operate the components on your + own infrastructure. +
+ )} + > + ) +} diff --git a/src/components/Shared/hydra/01_tracing.mdx b/src/components/Shared/hydra/01_tracing.mdx new file mode 100644 index 0000000000..9c1985b5b1 --- /dev/null +++ b/src/components/Shared/hydra/01_tracing.mdx @@ -0,0 +1,127 @@ +Configuring Distributed Tracing (DT) will enable you to obtain a visualization +of the call paths that take place in order to process a request made to Ory. +It's yet another tool that you can use to aid you in profiling, debugging and +ultimately understanding your deployment of Ory better. + +## Tracing options + +You have the option to use a tracing backend or follow existing traces. Ory +supports the following tracing backends: + +- [OpenTelemetry](https://github.com/open-telemetry) +- [Jaeger](https://github.com/jaegertracing/jaeger) +- [Elastic APM](https://github.com/elastic/apm) +- [Datadog](https://github.com/DataDog) +- [Zipkin](https://github.com/openzipkin/zipkin) +- [Instana](https://www.instana.com/) + +To follow existing traces: If you have deployed Ory behind a proxy that has +initiated a trace, Ory will attempt to join that trace by examining the request +headers for tracing context. + +### What an Ory trace includes + +In DT speak, a trace is comprised of one or more spans which are logical units +of work. Each Ory span is encapsulated with the following state: + +- A name +- A start time +- A finish time +- A set of zero or more tags + +Ory creates the following spans: + +- Top level span (_named after the request path_) for the requested endpoint. + Span tags: - http method - http status code - error IFF status code >= 400 +- Child span will be created if bcrypt (_e.g. when the token endpoint is + called_) is called. Span tags: - bcrypt work factor +- All SQL database interactions. Spans/tags will vary depending on the database + driver used. + +This is still evolving and subject to change as tracing support continues to +expand in Ory. If you see something that's missing/wrong, please +[create an issue](https://github.com/ory/docs/issues). + +### Local setup + +The +[provided docker-compose file](https://github.com/ory/hydra/blob/master/quickstart-tracing.yml) +in the Hydra repository (other ory services have the same docker-compose file) +has tracing configuration which you can use to play around with - just uncomment +the desired tracing provider. We will use Jaeger as an example. + +Simply run + +```sh +docker-compose -f quickstart.yml \ + -f quickstart-tracing.yml \ + up --build +``` + +Grab a coffee or stretch while you wait for everything to come up. You will then +be able to navigate to the Jaeger UI which you have exposed on port `16686` at +http://localhost:16686/search. You can now start making requests and inspect +traces! + +As an example, here is a trace created by making a bad request to the +`POST /clients` endpoint: + + + +At a glance, you are able to see that: + +- The request failed +- The request took ~80ms +- It resulted in a 409 +- The hash comparison to validate the client's credentials took a whopping 70ms. + Bcrypt is expensive! +- The various database operations performed + +:::note + +To see spans around database interactions, you must be using a SQL backend, such +as MySQL or Postgres. + +::: + +There is a more complex example to show you the interactions between Kratos, +Oathkeeper and Kratos to check if the user is allowed the access the requested +resource : + + + +As previously said, you can see the interactions between the different services +and SQL database interactions. + +### Tracing configurations + +You can configure tracing inside the configuration file (follow the same schema +for all services) or via environment variables. + +There is an example of a configuration file with tracing enabled: + +```yaml +tracing: + provider: jaeger # use any of the supported tracing providers + service_name: ory:kratos # if not set, the service name will be the service's name + providers: + jaeger: # per provider configuration + local_agent_address: jaeger:6831 + sampling: + server_url: http://jaeger:5778/sampling +``` + +:::note + +Please refer to the configuration reference for the full list of options. + +::: + +The CLI will also provide you with the list of tracing configurations and their +supported values. Simply run: + +``` +docker exec -it hydra_hydra_1 hydra serve --help +``` + +And read the section on `DEBUG CONTROLS`. diff --git a/src/components/Shared/hydra/_static/complex_trace.png b/src/components/Shared/hydra/_static/complex_trace.png new file mode 100644 index 0000000000..635d716810 Binary files /dev/null and b/src/components/Shared/hydra/_static/complex_trace.png differ diff --git a/src/components/Shared/hydra/_static/oauth2-flow.gif b/src/components/Shared/hydra/_static/oauth2-flow.gif new file mode 100644 index 0000000000..7054ddea93 Binary files /dev/null and b/src/components/Shared/hydra/_static/oauth2-flow.gif differ diff --git a/src/components/Shared/hydra/_static/ory-network-oauth2/oauth2-ory.mp4 b/src/components/Shared/hydra/_static/ory-network-oauth2/oauth2-ory.mp4 new file mode 100644 index 0000000000..8c558b293d Binary files /dev/null and b/src/components/Shared/hydra/_static/ory-network-oauth2/oauth2-ory.mp4 differ diff --git a/src/components/Shared/hydra/_static/ory-network-oauth2/oauth2-ory.webm b/src/components/Shared/hydra/_static/ory-network-oauth2/oauth2-ory.webm new file mode 100644 index 0000000000..e762e0ae9e Binary files /dev/null and b/src/components/Shared/hydra/_static/ory-network-oauth2/oauth2-ory.webm differ diff --git a/src/components/Shared/hydra/_static/sample_trace.png b/src/components/Shared/hydra/_static/sample_trace.png new file mode 100644 index 0000000000..51987091d0 Binary files /dev/null and b/src/components/Shared/hydra/_static/sample_trace.png differ diff --git a/src/components/Shared/hydra/index.mdx b/src/components/Shared/hydra/index.mdx new file mode 100644 index 0000000000..2228ab47e4 --- /dev/null +++ b/src/components/Shared/hydra/index.mdx @@ -0,0 +1,111 @@ +OAuth2 is the industry-standard protocol that enables secure machine-to-machine +communication and grants limited access to data and services on behalf of users. +OpenID Connect, built on top of OAuth2, is required to become a social sign-in +provider. + +Ory OAuth2 and OpenID Connect, built on top of the widely deployed open-source +[Ory Hydra Federation Server](https://github.com/ory/hydra) is available out of +the box in the Ory Network and is the perfect solution for securely connecting +users, applications, and services. Whether you need single sign-on (SSO), mobile +and third-party application authorization, API access management, +server-to-server communication, or federated identity, you can find a solution +based on Ory OAuth2 and OpenID Connect. + +## Features + +Ory OAuth2 and OpenID Connect comes with a range of features that make it the +ideal solution for securely connecting users, applications, and services. + +### Certified OpenID Connect implementation + +Ory OAuth2 and OpenID Connect is a +[Certified OpenID Connect Implementation](https://openid.net/developers/certified/) +that meets all requirements set by the OpenID Foundation. You can trust Ory +OAuth2 and OpenID Connect to meet the highest standards of security and +reliability. + +### Flexible user management + +Ory OAuth2 and OpenID Connect is connected to Ory Identities by default, but +unlike many other OAuth2 service providers, Ory's service is a headless API that +doesn't force you to use a specific user management system. This means that Ory +OAuth2 and OpenID Connect is the perfect fit if you want to become an OAuth2 +provider and already have an existing user management system. + +### Low latency + +Ory OAuth2 and OpenID Connect is optimized for low latency, ensuring that your +applications can authenticate users and access resources as quickly as possible. +This is especially important for high-traffic applications or those that require +real-time data access. + +### Global deployment + +Ory OAuth2 and OpenID Connect is deployed in data centers around the world, +ensuring that your applications can access the service with minimal latency from +anywhere in the world. With global deployment, you can easily serve users in +multiple regions and meet data sovereignty requirements. + +### Security-first architecture + +Ory OAuth2 and OpenID Connect has a security-first architecture that neutralizes +common attack vectors, as well as numerous less exploited security risks. The +architecture and workflows are designed to meet the highest security standards +and comply with industry best practices. + +### Cryptographic key storage + +In addition to OAuth2 functionality, Ory OAuth2 and OpenID Connect offers safe +storage for cryptographic keys that can be used, for example, to sign JSON Web +Tokens. + +## Benefits + +Ory OAuth2 and OpenID Connect provides a number of key benefits that make it the +ideal choice for securely connecting users, applications, and services. With Ory +OAuth2 and OpenID Connect, you can: + +- **Reduce development time:** With Ory OAuth2 and OpenID Connect, you can get + up and running quickly with a fully featured OAuth2 and OpenID Connect + provider that meets all industry standards and covers a wide range of use + cases. +- **Ensure regulatory compliance:** Ory OAuth2 and OpenID Connect is designed to + comply with the latest security standards and regulatory requirements, making + it easy to meet your compliance needs. +- **Improve user experience:** With support for SSO and mobile authentication, + Ory OAuth2 and OpenID Connect makes it easy for users to access your + applications securely and quickly. +- **Scale with ease:** Ory OAuth2 and OpenID Connect is built on a cloud-native + architecture that makes it easy to deploy and scale the service to meet your + needs, whether you're serving thousands or millions of users. +- **Minimize security risks:** Ory OAuth2 and OpenID Connect's security-first + architecture and cryptographic key storage help minimize security risks, + ensuring that your users and data are protected from unauthorized access and + malicious attacks. + +## Use cases + +Ory OAuth2 and OpenID Connect can be used for a wide range of use cases, +including: + +- Single sign-on (SSO): Allow users to authenticate with a single set of + credentials across multiple applications, eliminating the need for multiple + logins. +- Mobile and third-party application authorization: Enable applications to + request authorization to access resources on behalf of users. This lets users + give apps limited access to their resources without sharing their credentials. +- API access management: Use OAuth2 to verify the identity of clients that try + to access APIs and enforce appropriate access control policies based on this + identification. +- Server-to-server communication: Authorize communication between servers + without a user present. +- Federated identity: Become an identity provider, authenticate users, and + provide access to applications just like Google, Facebook, or GitHub. + +## Next steps + +See +[Ory Network OAuth2 quickstart guide](/docs/network/hydra/quickstarts/ory-network-oauth2) +to learn how to set up your own OAuth2 and OpenID Connect provider in just a few +minutes. The guide walks you through the process of setting up Ory OAuth2 and +OpenID Connect and configuring a sample application to use the service. diff --git a/src/components/Shared/hydra/ory-network-oauth2.mdx b/src/components/Shared/hydra/ory-network-oauth2.mdx new file mode 100644 index 0000000000..e37c7a28f2 --- /dev/null +++ b/src/components/Shared/hydra/ory-network-oauth2.mdx @@ -0,0 +1,150 @@ +[Ory OAuth2 & OpenID Connect](https://www.ory.com/hydra) (based on +[Ory Hydra](https://github.com/ory/hydra)) is available in the Ory Network out +of the box. This means that you can use OIDC, Authorization Code Grant, Client +Credentials Grant, and more, without additional configuration. + +Following this guide allows you to experience the most commonly used OAuth2 +flows and see how they work in Ory Network. The examples will take you through +the following steps: + +- Creating OAuth2 clients in the Ory Network with the Ory CLI +- Using the Authorization Code Grant with federation to Ory Identities for user + authentication and UI views (login page, consent page) supplied by the Ory + Account Experience +- Using the Client Credentials Grant +- Performing token introspection using the Ory CLI + +## Prerequisites + +Before you start, [install the Ory CLI](/docs/guides/cli/installation). + +## Client Credentials Grant + +The +[Client Credentials Grant](https://www.rfc-editor.org/rfc/rfc6749#section-4.4) +is commonly used in machine-to-machine communications. This allows web services, +applications, or devices to call each other without the context of human users. +Activity that uses this grant often runs in the background and doesn't require +any user interaction. + +Follow these steps to try this grant in Ory Network. Create an Ory Network +project using the Ory CLI and export the project ID: + +```shell +ory create project --name "Ory OAuth2 Example" +project_id="{set to the project ID from output}" +``` + +1. Create an OAuth2 client: + + ```shell + ory create oauth2-client --project "$PROJECT_ID" \ + --name "Client Credentials Demo" \ + --grant-type client_credentials + ``` + +2. Export the ID and secret of the created client: + + ```shell + client_id="{set to CLIENT ID from output}" + client_secret="{set to CLIENT SECRET from output}" + ``` + +3. Start the Client Credentials Grant: + + ```shell + ory perform client-credentials \ + --client-id="$client_id" \ + --client-secret="$client_secret" \ + --project "$PROJECT_ID" + ``` + +4. Perform token introspection to get the `access_token` details: + + ```shell + # Export 'access_token' + access_token="{set to ACCESS TOKEN from output}" + + # Perform token introspection + ory introspect token $access_token --project "$PROJECT_ID" + ``` + +## Authorization Code Grant + +The +[Authorization Code Grant](https://www.rfc-editor.org/rfc/rfc6749#section-1.3) +is most commonly used in scenarios where applications need to perform actions on +behalf of users. For example, when an online marketplace allows users to add +photos from their Google Photos album to listings. + +To achieve that, the online marketplace must access the user's Google Photos +library on their behalf. If the user accepts the access scope requested by the +app (online marketplace), the app's client gets an `id_token` and `access_token` +pair which is then used to interact with Google Photos. + +This is what using the grant with UI views supplied by the Ory Account +Experience looks like: + +```mdx-code-block +import mp4 from './_static/ory-network-oauth2/oauth2-ory.mp4' +import webm from './_static/ory-network-oauth2/oauth2-ory.webm' +import VideoEmbed from '@site/src/components/VideoEmbed' + ++ +
+``` + +To get started, clone the Ory Hydra locally: + +```mdx-code-block +import CodeBlock from '@theme/CodeBlock' + ++ We run integration tests for both the{" "} + Node.js{" "} + and{" "} + + React Native + {" "} + reference implementation using{" "} + Cypress. You can find the set up + and source code for these tests in{" "} + + ./test/e2e/run.sh + + . In principle, we start Ory Kratos with some configuration and an + in-memory database in the background +
+ ++ as well as our application in the background as well. Then, we start the + Cypress test runner which executes the different e2e tests. This works + really well to test compliance and integration of Ory Kratos. +
+ ++ If you run Ory Kratos and your app on separate domains or ports you + might want to add +
+ +
+ to your cypress.json config file.
+
Testing React Native on web with Cypress
+ +
+ If you want to test React Native (rendered as a web application) in
+ Cypress, you need to disable security features preventing browser from
+ executing self-service API flows. To do this, set the environment
+ variable DEV_DISABLE_API_FLOW_ENFORCEMENT=1:
+