|
| 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