Skip to content

Commit ce617ce

Browse files
committed
Add Ory provider
Ory supports two ways to run IAM - self-hosted or as a managed service. This PR adds a provider for the managed service and separates the managed provider and the self-hosted provider.
1 parent 0e0c7b6 commit ce617ce

File tree

2 files changed

+107
-3
lines changed

2 files changed

+107
-3
lines changed

packages/core/src/providers/ory-hydra.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export interface OryHydraProfile extends Record<string, any> {
2323
}
2424

2525
/**
26-
* Add Ory Hydra login to your page.
26+
* Add login with self-hosted Ory Hydra to your app.
2727
*
2828
* ### Setup
2929
*
@@ -55,8 +55,12 @@ export interface OryHydraProfile extends Record<string, any> {
5555
*
5656
* ### Notes
5757
*
58-
* Ory Hydra can be setup using the default Ory Network setup or self hosted on your own
58+
* Ory Hydra can be setup using the default Ory Network setup or self-hosted on your own
5959
* infrastructure.
60+
*
61+
* This provider is best for self-hosted Ory Hydra instances. For the Ory Network, use the
62+
* `Ory` provider.
63+
*
6064
* By default, Auth.js assumes that the Ory Hydra provider is
6165
* based on the [Open ID Connect](https://openid.net/specs/openid-connect-core-1_0.html) specification.
6266
*
@@ -82,7 +86,7 @@ export default function OryHydra<P extends OryHydraProfile>(
8286
): OIDCConfig<P> {
8387
return {
8488
id: "hydra",
85-
name: "Hydra",
89+
name: "Ory Hydra",
8690
type: "oidc",
8791
style: {
8892
bg: "#fff",

packages/core/src/providers/ory.ts

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/**
2+
* <div style={{backgroundColor: "#000", display: "flex", justifyContent: "space-between", color: "#fff", padding: 16}}>
3+
* <span>Built-in <b>Ory</b> integration.</span>
4+
* <a href="https://www.ory.sh/">
5+
* <img style={{display: "block"}} src="https://authjs.dev/img/providers/ory.svg" height="48" />
6+
* </a>
7+
* </div>
8+
*
9+
* @module providers/ory
10+
*/
11+
import type { OIDCConfig, OIDCUserConfig } from "./index.js"
12+
13+
export interface DefaultOryProfile extends Record<string, any> {
14+
iss: string
15+
ver: string
16+
sub: string
17+
aud: string
18+
iat: string
19+
exp: string
20+
jti: string
21+
amr: string
22+
email?: string
23+
email_verified?: boolean
24+
preferred_username?: string
25+
website?: string
26+
given_name?: string
27+
family_name?: string
28+
name?: string
29+
updated_at?: Date
30+
}
31+
32+
/**
33+
* Add login with Ory to your app.
34+
*
35+
* ### Setup
36+
*
37+
* #### Callback URL
38+
*
39+
* ```
40+
* https://example.com/api/auth/callback/ory
41+
* ```
42+
*
43+
* #### Configuration
44+
*```js
45+
* import Auth from "@auth/core"
46+
* import Ory from "@auth/core/providers/ory"
47+
*
48+
* const request = new Request(origin)
49+
* const response = await Auth(request, {
50+
* providers: [Ory({
51+
* clientId: ORY_CLIENT_ID,
52+
* clientSecret: ORY_CLIENT_SECRET,
53+
* issuer: ORY_SDK_URL // https://ory.yourdomain.com
54+
* })],
55+
* })
56+
* ```
57+
*
58+
* ### Resources
59+
*
60+
* - [Ory + Auth.js integration](https://www.ory.sh/docs/getting-started/integrate-auth/auth-js)
61+
* - [Ory Documentation](https://www.ory.sh/docs)
62+
*
63+
* ### Notes
64+
*
65+
* This set up is optimized for Ory Network, a managed service by Ory. To use Auth.js with self-hosted Ory Hydra, use the `OryHydra` provider.
66+
*
67+
* The Ory integration is based on the [Open ID Connect](https://openid.net/specs/openid-connect-core-1_0.html) specification.
68+
*
69+
* :::tip
70+
*
71+
* The Ory provider comes with a [default configuration](https://github.com/nextauthjs/next-auth/blob/main/packages/core/src/providers/ory.ts).
72+
* To override the defaults for your use case, check out [customizing a built-in OAuth provider](https://authjs.dev/guides/configuring-oauth-providers).
73+
*
74+
* :::
75+
*
76+
* :::info **Disclaimer**
77+
*
78+
* If you think you found a bug in the default configuration, you can [open an issue](https://authjs.dev/new/provider-issue).
79+
*
80+
* Auth.js strictly adheres to the specification and it cannot take responsibility for any deviation from
81+
* the spec by the provider. You can open an issue, but if the problem is non-compliance with the spec,
82+
* we might not pursue a resolution. You can ask for more help in [Discussions](https://authjs.dev/new/github-discussions).
83+
*
84+
* :::
85+
*/
86+
export default function Ory<P extends DefaultOryProfile>(
87+
options: OIDCUserConfig<P>
88+
): OIDCConfig<P> {
89+
return {
90+
id: "ory",
91+
name: "Ory",
92+
type: 'oidc',
93+
checks: ["pkce", "state", "nonce"],
94+
style: {
95+
bg: "#fff",
96+
text: "#0F172A",
97+
},
98+
options,
99+
}
100+
}

0 commit comments

Comments
 (0)