@farmsdotmarket/openauth 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @farmsdotmarket/openauth might be problematic. Click here for more details.
- package/.changeset/README.md +8 -0
- package/.changeset/commit.cjs +4 -0
- package/.changeset/config.json +11 -0
- package/.changeset/farms-openauth-release-0-4-3-farms-2.md +10 -0
- package/.changeset/popular-geese-reply.md +5 -0
- package/.changeset/stupid-boats-play.md +5 -0
- package/.changeset/ten-pans-invent.md +5 -0
- package/.github/CODE_OF_CONDUCT +15 -0
- package/.github/workflows/docs.yml +39 -0
- package/.github/workflows/format.yml +26 -0
- package/.github/workflows/release.yml +28 -0
- package/.github/workflows/test.yml +20 -0
- package/.prettierrc +3 -0
- package/CNAME +1 -0
- package/FARMS_RELEASE.md +82 -0
- package/LICENSE +22 -0
- package/PATCHES.md +32 -0
- package/README.md +311 -0
- package/bun.lockb +0 -0
- package/bunfig.toml +2 -0
- package/examples/README.md +28 -0
- package/examples/client/astro/.vscode/extensions.json +4 -0
- package/examples/client/astro/.vscode/launch.json +11 -0
- package/examples/client/astro/README.md +7 -0
- package/examples/client/astro/astro.config.mjs +10 -0
- package/examples/client/astro/package.json +15 -0
- package/examples/client/astro/public/favicon.svg +9 -0
- package/examples/client/astro/src/assets/astro.svg +1 -0
- package/examples/client/astro/src/assets/background.svg +1 -0
- package/examples/client/astro/src/auth.ts +23 -0
- package/examples/client/astro/src/components/Welcome.astro +209 -0
- package/examples/client/astro/src/env.d.ts +10 -0
- package/examples/client/astro/src/layouts/Layout.astro +22 -0
- package/examples/client/astro/src/middleware.ts +31 -0
- package/examples/client/astro/src/pages/callback.ts +19 -0
- package/examples/client/astro/src/pages/index.astro +11 -0
- package/examples/client/astro/tsconfig.json +5 -0
- package/examples/client/cloudflare-api/api.ts +80 -0
- package/examples/client/cloudflare-api/package.json +5 -0
- package/examples/client/jwt-api/CHANGELOG.md +8 -0
- package/examples/client/jwt-api/README.md +13 -0
- package/examples/client/jwt-api/index.ts +45 -0
- package/examples/client/jwt-api/package.json +15 -0
- package/examples/client/lambda-api/api.ts +69 -0
- package/examples/client/lambda-api/package.json +5 -0
- package/examples/client/nextjs/CHANGELOG.md +46 -0
- package/examples/client/nextjs/README.md +26 -0
- package/examples/client/nextjs/app/actions.ts +61 -0
- package/examples/client/nextjs/app/api/callback/route.ts +11 -0
- package/examples/client/nextjs/app/auth.ts +29 -0
- package/examples/client/nextjs/app/favicon.ico +0 -0
- package/examples/client/nextjs/app/globals.css +42 -0
- package/examples/client/nextjs/app/layout.tsx +32 -0
- package/examples/client/nextjs/app/page.module.css +169 -0
- package/examples/client/nextjs/app/page.tsx +97 -0
- package/examples/client/nextjs/next.config.ts +7 -0
- package/examples/client/nextjs/package.json +23 -0
- package/examples/client/nextjs/public/file.svg +1 -0
- package/examples/client/nextjs/public/globe.svg +1 -0
- package/examples/client/nextjs/public/next.svg +1 -0
- package/examples/client/nextjs/public/vercel.svg +1 -0
- package/examples/client/nextjs/public/window.svg +1 -0
- package/examples/client/nextjs/tsconfig.json +27 -0
- package/examples/client/react/README.md +29 -0
- package/examples/client/react/index.html +13 -0
- package/examples/client/react/package.json +30 -0
- package/examples/client/react/public/vite.svg +1 -0
- package/examples/client/react/src/App.tsx +39 -0
- package/examples/client/react/src/AuthContext.tsx +153 -0
- package/examples/client/react/src/assets/react.svg +1 -0
- package/examples/client/react/src/main.tsx +12 -0
- package/examples/client/react/src/vite-env.d.ts +1 -0
- package/examples/client/react/tsconfig.app.json +26 -0
- package/examples/client/react/tsconfig.json +11 -0
- package/examples/client/react/tsconfig.node.json +24 -0
- package/examples/client/react/vite.config.ts +7 -0
- package/examples/client/sveltekit/package.json +24 -0
- package/examples/client/sveltekit/src/app.d.ts +15 -0
- package/examples/client/sveltekit/src/app.html +12 -0
- package/examples/client/sveltekit/src/hooks.server.ts +29 -0
- package/examples/client/sveltekit/src/lib/auth.server.ts +29 -0
- package/examples/client/sveltekit/src/routes/+page.server.ts +5 -0
- package/examples/client/sveltekit/src/routes/+page.svelte +5 -0
- package/examples/client/sveltekit/src/routes/callback/+server.ts +17 -0
- package/examples/client/sveltekit/static/favicon.png +0 -0
- package/examples/client/sveltekit/svelte.config.js +18 -0
- package/examples/client/sveltekit/tsconfig.json +19 -0
- package/examples/client/sveltekit/vite.config.ts +6 -0
- package/examples/issuer/bun/issuer.ts +43 -0
- package/examples/issuer/bun/package.json +7 -0
- package/examples/issuer/cloudflare/issuer.ts +47 -0
- package/examples/issuer/cloudflare/package.json +8 -0
- package/examples/issuer/cloudflare/sst-env.d.ts +17 -0
- package/examples/issuer/cloudflare/sst.config.ts +23 -0
- package/examples/issuer/custom-frontend/auth/issuer.ts +43 -0
- package/examples/issuer/custom-frontend/auth/package.json +7 -0
- package/examples/issuer/custom-frontend/frontend/frontend.tsx +57 -0
- package/examples/issuer/custom-frontend/frontend/package.json +6 -0
- package/examples/issuer/custom-frontend/package.json +5 -0
- package/examples/issuer/lambda/issuer.ts +35 -0
- package/examples/issuer/lambda/package.json +8 -0
- package/examples/issuer/lambda/sst-env.d.ts +9 -0
- package/examples/issuer/lambda/sst.config.ts +15 -0
- package/examples/issuer/node/authorizer.ts +38 -0
- package/examples/issuer/node/package.json +5 -0
- package/examples/quickstart/sst/README.md +36 -0
- package/examples/quickstart/sst/app/actions.ts +62 -0
- package/examples/quickstart/sst/app/api/callback/route.ts +15 -0
- package/examples/quickstart/sst/app/auth.ts +29 -0
- package/examples/quickstart/sst/app/favicon.ico +0 -0
- package/examples/quickstart/sst/app/globals.css +42 -0
- package/examples/quickstart/sst/app/layout.tsx +32 -0
- package/examples/quickstart/sst/app/page.module.css +200 -0
- package/examples/quickstart/sst/app/page.tsx +53 -0
- package/examples/quickstart/sst/auth/index.ts +37 -0
- package/examples/quickstart/sst/auth/subjects.ts +8 -0
- package/examples/quickstart/sst/next.config.ts +7 -0
- package/examples/quickstart/sst/package-lock.json +1165 -0
- package/examples/quickstart/sst/package.json +26 -0
- package/examples/quickstart/sst/public/file.svg +1 -0
- package/examples/quickstart/sst/public/globe.svg +1 -0
- package/examples/quickstart/sst/public/next.svg +1 -0
- package/examples/quickstart/sst/public/vercel.svg +1 -0
- package/examples/quickstart/sst/public/window.svg +1 -0
- package/examples/quickstart/sst/sst-env.d.ts +18 -0
- package/examples/quickstart/sst/sst.config.ts +21 -0
- package/examples/quickstart/sst/tsconfig.json +27 -0
- package/examples/quickstart/standalone/README.md +36 -0
- package/examples/quickstart/standalone/app/actions.ts +62 -0
- package/examples/quickstart/standalone/app/api/callback/route.ts +15 -0
- package/examples/quickstart/standalone/app/auth.ts +28 -0
- package/examples/quickstart/standalone/app/favicon.ico +0 -0
- package/examples/quickstart/standalone/app/globals.css +42 -0
- package/examples/quickstart/standalone/app/layout.tsx +32 -0
- package/examples/quickstart/standalone/app/page.module.css +200 -0
- package/examples/quickstart/standalone/app/page.tsx +53 -0
- package/examples/quickstart/standalone/auth/index.ts +32 -0
- package/examples/quickstart/standalone/auth/subjects.ts +8 -0
- package/examples/quickstart/standalone/bun.lockb +0 -0
- package/examples/quickstart/standalone/next.config.ts +7 -0
- package/examples/quickstart/standalone/package.json +25 -0
- package/examples/quickstart/standalone/public/file.svg +1 -0
- package/examples/quickstart/standalone/public/globe.svg +1 -0
- package/examples/quickstart/standalone/public/next.svg +1 -0
- package/examples/quickstart/standalone/public/vercel.svg +1 -0
- package/examples/quickstart/standalone/public/window.svg +1 -0
- package/examples/quickstart/standalone/tsconfig.json +27 -0
- package/examples/subjects.ts +8 -0
- package/examples/tsconfig.json +10 -0
- package/package.json +23 -0
- package/packages/openauth/CHANGELOG.md +310 -0
- package/packages/openauth/bunfig.toml +2 -0
- package/packages/openauth/package.json +51 -0
- package/packages/openauth/script/build.ts +25 -0
- package/packages/openauth/src/client-native.ts +204 -0
- package/packages/openauth/src/client.ts +776 -0
- package/packages/openauth/src/css.d.ts +4 -0
- package/packages/openauth/src/error.ts +120 -0
- package/packages/openauth/src/index.ts +26 -0
- package/packages/openauth/src/issuer.ts +1156 -0
- package/packages/openauth/src/jwt.ts +17 -0
- package/packages/openauth/src/keys.ts +139 -0
- package/packages/openauth/src/pkce.ts +40 -0
- package/packages/openauth/src/provider/apple.ts +127 -0
- package/packages/openauth/src/provider/arctic.ts +66 -0
- package/packages/openauth/src/provider/code.ts +227 -0
- package/packages/openauth/src/provider/cognito.ts +74 -0
- package/packages/openauth/src/provider/discord.ts +45 -0
- package/packages/openauth/src/provider/facebook.ts +84 -0
- package/packages/openauth/src/provider/github.ts +45 -0
- package/packages/openauth/src/provider/google.ts +85 -0
- package/packages/openauth/src/provider/index.ts +3 -0
- package/packages/openauth/src/provider/jumpcloud.ts +45 -0
- package/packages/openauth/src/provider/keycloak.ts +75 -0
- package/packages/openauth/src/provider/linkedin.ts +12 -0
- package/packages/openauth/src/provider/microsoft.ts +100 -0
- package/packages/openauth/src/provider/oauth2.ts +297 -0
- package/packages/openauth/src/provider/oidc.ts +179 -0
- package/packages/openauth/src/provider/password.ts +672 -0
- package/packages/openauth/src/provider/provider.ts +33 -0
- package/packages/openauth/src/provider/slack.ts +67 -0
- package/packages/openauth/src/provider/spotify.ts +45 -0
- package/packages/openauth/src/provider/twitch.ts +45 -0
- package/packages/openauth/src/provider/x.ts +46 -0
- package/packages/openauth/src/provider/yahoo.ts +45 -0
- package/packages/openauth/src/random.ts +28 -0
- package/packages/openauth/src/storage/aws.ts +59 -0
- package/packages/openauth/src/storage/cloudflare.ts +77 -0
- package/packages/openauth/src/storage/dynamo.ts +193 -0
- package/packages/openauth/src/storage/memory.ts +135 -0
- package/packages/openauth/src/storage/storage.ts +46 -0
- package/packages/openauth/src/subject.ts +130 -0
- package/packages/openauth/src/ui/base.tsx +118 -0
- package/packages/openauth/src/ui/code.tsx +212 -0
- package/packages/openauth/src/ui/form.tsx +40 -0
- package/packages/openauth/src/ui/icon.tsx +95 -0
- package/packages/openauth/src/ui/password.tsx +403 -0
- package/packages/openauth/src/ui/select.tsx +221 -0
- package/packages/openauth/src/ui/theme.ts +319 -0
- package/packages/openauth/src/ui/ui.css +252 -0
- package/packages/openauth/src/util.ts +58 -0
- package/packages/openauth/test/client-native.test.ts +30 -0
- package/packages/openauth/test/client.test.ts +177 -0
- package/packages/openauth/test/issuer.test.ts +393 -0
- package/packages/openauth/test/scrap.test.ts +85 -0
- package/packages/openauth/test/storage.test.ts +94 -0
- package/packages/openauth/test/util.test.ts +103 -0
- package/packages/openauth/tsconfig.json +13 -0
- package/scripts/format +15 -0
- package/www/.vscode/extensions.json +4 -0
- package/www/.vscode/launch.json +11 -0
- package/www/README.md +55 -0
- package/www/astro.config.mjs +136 -0
- package/www/bun.lockb +0 -0
- package/www/config.ts +4 -0
- package/www/generate.ts +911 -0
- package/www/package.json +24 -0
- package/www/public/favicon-dark.svg +3 -0
- package/www/public/favicon.ico +0 -0
- package/www/public/favicon.svg +3 -0
- package/www/public/social-share.png +0 -0
- package/www/src/assets/logo-dark.svg +11 -0
- package/www/src/assets/logo-light.svg +11 -0
- package/www/src/components/Hero.astro +11 -0
- package/www/src/components/Lander.astro +176 -0
- package/www/src/content/config.ts +6 -0
- package/www/src/content/docs/docs/client.mdx +650 -0
- package/www/src/content/docs/docs/index.mdx +325 -0
- package/www/src/content/docs/docs/issuer.mdx +512 -0
- package/www/src/content/docs/docs/provider/apple.mdx +233 -0
- package/www/src/content/docs/docs/provider/code.mdx +163 -0
- package/www/src/content/docs/docs/provider/cognito.mdx +173 -0
- package/www/src/content/docs/docs/provider/discord.mdx +139 -0
- package/www/src/content/docs/docs/provider/facebook.mdx +233 -0
- package/www/src/content/docs/docs/provider/github.mdx +139 -0
- package/www/src/content/docs/docs/provider/google.mdx +233 -0
- package/www/src/content/docs/docs/provider/jumpcloud.mdx +139 -0
- package/www/src/content/docs/docs/provider/keycloak.mdx +176 -0
- package/www/src/content/docs/docs/provider/microsoft.mdx +252 -0
- package/www/src/content/docs/docs/provider/oauth2.mdx +173 -0
- package/www/src/content/docs/docs/provider/oidc.mdx +113 -0
- package/www/src/content/docs/docs/provider/password.mdx +237 -0
- package/www/src/content/docs/docs/provider/slack.mdx +157 -0
- package/www/src/content/docs/docs/provider/spotify.mdx +139 -0
- package/www/src/content/docs/docs/provider/twitch.mdx +139 -0
- package/www/src/content/docs/docs/provider/x.mdx +139 -0
- package/www/src/content/docs/docs/provider/yahoo.mdx +139 -0
- package/www/src/content/docs/docs/start/nextjs-dark.png +0 -0
- package/www/src/content/docs/docs/start/nextjs-light.png +0 -0
- package/www/src/content/docs/docs/start/sst.mdx +423 -0
- package/www/src/content/docs/docs/start/standalone.mdx +376 -0
- package/www/src/content/docs/docs/storage/cloudflare.mdx +63 -0
- package/www/src/content/docs/docs/storage/dynamo.mdx +127 -0
- package/www/src/content/docs/docs/storage/memory.mdx +77 -0
- package/www/src/content/docs/docs/subject.mdx +139 -0
- package/www/src/content/docs/docs/themes-dark.png +0 -0
- package/www/src/content/docs/docs/themes-light.png +0 -0
- package/www/src/content/docs/docs/ui/code.mdx +248 -0
- package/www/src/content/docs/docs/ui/password.mdx +410 -0
- package/www/src/content/docs/docs/ui/select.mdx +99 -0
- package/www/src/content/docs/docs/ui/theme.mdx +284 -0
- package/www/src/content/docs/index.mdx +12 -0
- package/www/src/custom.css +0 -0
- package/www/src/env.d.ts +2 -0
- package/www/src/styles/lander.css +15 -0
- package/www/tsconfig.json +3 -0
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: MicrosoftProvider
|
|
3
|
+
editUrl: https://github.com/toolbeam/openauth/blob/master/packages/openauth/src/provider/microsoft.ts
|
|
4
|
+
description: Reference doc for the `MicrosoftProvider`.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
import { Segment, Section, NestedTitle, InlineSection } from 'toolbeam-docs-theme/components'
|
|
8
|
+
import { Tabs, TabItem } from '@astrojs/starlight/components'
|
|
9
|
+
|
|
10
|
+
<div class="tsdoc">
|
|
11
|
+
<Section type="about">
|
|
12
|
+
Use this provider to authenticate with Microsoft. Supports both OAuth2 and OIDC.
|
|
13
|
+
|
|
14
|
+
#### Using OAuth
|
|
15
|
+
|
|
16
|
+
```ts {5-9}
|
|
17
|
+
import { MicrosoftProvider } from "@openauthjs/openauth/provider/microsoft"
|
|
18
|
+
|
|
19
|
+
export default issuer({
|
|
20
|
+
providers: {
|
|
21
|
+
microsoft: MicrosoftProvider({
|
|
22
|
+
tenant: "1234567890",
|
|
23
|
+
clientID: "1234567890",
|
|
24
|
+
clientSecret: "0987654321"
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
#### Using OIDC
|
|
31
|
+
|
|
32
|
+
```ts {5-7}
|
|
33
|
+
import { MicrosoftOidcProvider } from "@openauthjs/openauth/provider/microsoft"
|
|
34
|
+
|
|
35
|
+
export default issuer({
|
|
36
|
+
providers: {
|
|
37
|
+
microsoft: MicrosoftOidcProvider({
|
|
38
|
+
clientID: "1234567890"
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
```
|
|
43
|
+
</Section>
|
|
44
|
+
---
|
|
45
|
+
## Methods
|
|
46
|
+
### MicrosoftOidcProvider
|
|
47
|
+
<Segment>
|
|
48
|
+
<Section type="signature">
|
|
49
|
+
```ts
|
|
50
|
+
MicrosoftOidcProvider(config)
|
|
51
|
+
```
|
|
52
|
+
</Section>
|
|
53
|
+
<Section type="parameters">
|
|
54
|
+
#### Parameters
|
|
55
|
+
- <p><code class="key">config</code> [<code class="type">MicrosoftOidcConfig</code>](/docs/provider/microsoft#microsoftoidcconfig)</p>
|
|
56
|
+
The config for the provider.
|
|
57
|
+
</Section>
|
|
58
|
+
<InlineSection>
|
|
59
|
+
**Returns** <code class="type">Provider</code>
|
|
60
|
+
</InlineSection>
|
|
61
|
+
Create a Microsoft OIDC provider.
|
|
62
|
+
|
|
63
|
+
This is useful if you just want to verify the user's email address.
|
|
64
|
+
```ts
|
|
65
|
+
MicrosoftOidcProvider({
|
|
66
|
+
clientID: "1234567890"
|
|
67
|
+
})
|
|
68
|
+
```
|
|
69
|
+
</Segment>
|
|
70
|
+
### MicrosoftProvider
|
|
71
|
+
<Segment>
|
|
72
|
+
<Section type="signature">
|
|
73
|
+
```ts
|
|
74
|
+
MicrosoftProvider(config)
|
|
75
|
+
```
|
|
76
|
+
</Section>
|
|
77
|
+
<Section type="parameters">
|
|
78
|
+
#### Parameters
|
|
79
|
+
- <p><code class="key">config</code> [<code class="type">MicrosoftConfig</code>](/docs/provider/microsoft#microsoftconfig)</p>
|
|
80
|
+
The config for the provider.
|
|
81
|
+
</Section>
|
|
82
|
+
<InlineSection>
|
|
83
|
+
**Returns** <code class="type">Provider</code>
|
|
84
|
+
</InlineSection>
|
|
85
|
+
Create a Microsoft OAuth2 provider.
|
|
86
|
+
```ts
|
|
87
|
+
MicrosoftProvider({
|
|
88
|
+
tenant: "1234567890",
|
|
89
|
+
clientID: "1234567890",
|
|
90
|
+
clientSecret: "0987654321"
|
|
91
|
+
})
|
|
92
|
+
```
|
|
93
|
+
</Segment>
|
|
94
|
+
## MicrosoftConfig
|
|
95
|
+
<Segment>
|
|
96
|
+
<Section type="parameters">
|
|
97
|
+
- <p>[<code class="key">clientID</code>](#microsoftconfig.clientid) <code class="primitive">string</code></p>
|
|
98
|
+
- <p>[<code class="key">clientSecret</code>](#microsoftconfig.clientsecret) <code class="primitive">string</code></p>
|
|
99
|
+
- <p>[<code class="key">pkce?</code>](#microsoftconfig.pkce) <code class="primitive">boolean</code></p>
|
|
100
|
+
- <p>[<code class="key">query?</code>](#microsoftconfig.query) <code class="primitive">Record</code><code class="symbol"><</code><code class="primitive">string</code>, <code class="primitive">string</code><code class="symbol">></code></p>
|
|
101
|
+
- <p>[<code class="key">scopes</code>](#microsoftconfig.scopes) <code class="primitive">string</code><code class="symbol">[]</code></p>
|
|
102
|
+
- <p>[<code class="key">tenant</code>](#microsoftconfig.tenant) <code class="primitive">string</code></p>
|
|
103
|
+
</Section>
|
|
104
|
+
</Segment>
|
|
105
|
+
<NestedTitle id="microsoftconfig.clientid" Tag="h4" parent="MicrosoftConfig.">clientID</NestedTitle>
|
|
106
|
+
<Segment>
|
|
107
|
+
<Section type="parameters">
|
|
108
|
+
<InlineSection>
|
|
109
|
+
**Type** <code class="primitive">string</code>
|
|
110
|
+
</InlineSection>
|
|
111
|
+
</Section>
|
|
112
|
+
The client ID.
|
|
113
|
+
|
|
114
|
+
This is just a string to identify your app.
|
|
115
|
+
```ts
|
|
116
|
+
{
|
|
117
|
+
clientID: "my-client"
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
</Segment>
|
|
121
|
+
<NestedTitle id="microsoftconfig.clientsecret" Tag="h4" parent="MicrosoftConfig.">clientSecret</NestedTitle>
|
|
122
|
+
<Segment>
|
|
123
|
+
<Section type="parameters">
|
|
124
|
+
<InlineSection>
|
|
125
|
+
**Type** <code class="primitive">string</code>
|
|
126
|
+
</InlineSection>
|
|
127
|
+
</Section>
|
|
128
|
+
The client secret.
|
|
129
|
+
|
|
130
|
+
This is a private key that's used to authenticate your app. It should be kept secret.
|
|
131
|
+
```ts
|
|
132
|
+
{
|
|
133
|
+
clientSecret: "0987654321"
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
</Segment>
|
|
137
|
+
<NestedTitle id="microsoftconfig.pkce" Tag="h4" parent="MicrosoftConfig.">pkce?</NestedTitle>
|
|
138
|
+
<Segment>
|
|
139
|
+
<Section type="parameters">
|
|
140
|
+
<InlineSection>
|
|
141
|
+
**Type** <code class="primitive">boolean</code>
|
|
142
|
+
</InlineSection>
|
|
143
|
+
</Section>
|
|
144
|
+
|
|
145
|
+
<InlineSection>
|
|
146
|
+
**Default** false
|
|
147
|
+
</InlineSection>
|
|
148
|
+
Whether to use PKCE (Proof Key for Code Exchange) for the authorization code flow.
|
|
149
|
+
Some providers like x.com require this.
|
|
150
|
+
</Segment>
|
|
151
|
+
<NestedTitle id="microsoftconfig.query" Tag="h4" parent="MicrosoftConfig.">query?</NestedTitle>
|
|
152
|
+
<Segment>
|
|
153
|
+
<Section type="parameters">
|
|
154
|
+
<InlineSection>
|
|
155
|
+
**Type** <code class="primitive">Record</code><code class="symbol"><</code><code class="primitive">string</code>, <code class="primitive">string</code><code class="symbol">></code>
|
|
156
|
+
</InlineSection>
|
|
157
|
+
</Section>
|
|
158
|
+
Any additional parameters that you want to pass to the authorization endpoint.
|
|
159
|
+
```ts
|
|
160
|
+
{
|
|
161
|
+
query: {
|
|
162
|
+
access_type: "offline",
|
|
163
|
+
prompt: "consent"
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
</Segment>
|
|
168
|
+
<NestedTitle id="microsoftconfig.scopes" Tag="h4" parent="MicrosoftConfig.">scopes</NestedTitle>
|
|
169
|
+
<Segment>
|
|
170
|
+
<Section type="parameters">
|
|
171
|
+
<InlineSection>
|
|
172
|
+
**Type** <code class="primitive">string</code><code class="symbol">[]</code>
|
|
173
|
+
</InlineSection>
|
|
174
|
+
</Section>
|
|
175
|
+
A list of OAuth scopes that you want to request.
|
|
176
|
+
```ts
|
|
177
|
+
{
|
|
178
|
+
scopes: ["email", "profile"]
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
</Segment>
|
|
182
|
+
<NestedTitle id="microsoftconfig.tenant" Tag="h4" parent="MicrosoftConfig.">tenant</NestedTitle>
|
|
183
|
+
<Segment>
|
|
184
|
+
<Section type="parameters">
|
|
185
|
+
<InlineSection>
|
|
186
|
+
**Type** <code class="primitive">string</code>
|
|
187
|
+
</InlineSection>
|
|
188
|
+
</Section>
|
|
189
|
+
The tenant ID of the Microsoft account.
|
|
190
|
+
|
|
191
|
+
This is usually the same as the client ID.
|
|
192
|
+
```ts
|
|
193
|
+
{
|
|
194
|
+
tenant: "1234567890"
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
</Segment>
|
|
198
|
+
## MicrosoftOidcConfig
|
|
199
|
+
<Segment>
|
|
200
|
+
<Section type="parameters">
|
|
201
|
+
- <p>[<code class="key">clientID</code>](#microsoftoidcconfig.clientid) <code class="primitive">string</code></p>
|
|
202
|
+
- <p>[<code class="key">query?</code>](#microsoftoidcconfig.query) <code class="primitive">Record</code><code class="symbol"><</code><code class="primitive">string</code>, <code class="primitive">string</code><code class="symbol">></code></p>
|
|
203
|
+
- <p>[<code class="key">scopes?</code>](#microsoftoidcconfig.scopes) <code class="primitive">string</code><code class="symbol">[]</code></p>
|
|
204
|
+
</Section>
|
|
205
|
+
</Segment>
|
|
206
|
+
<NestedTitle id="microsoftoidcconfig.clientid" Tag="h4" parent="MicrosoftOidcConfig.">clientID</NestedTitle>
|
|
207
|
+
<Segment>
|
|
208
|
+
<Section type="parameters">
|
|
209
|
+
<InlineSection>
|
|
210
|
+
**Type** <code class="primitive">string</code>
|
|
211
|
+
</InlineSection>
|
|
212
|
+
</Section>
|
|
213
|
+
The client ID.
|
|
214
|
+
|
|
215
|
+
This is just a string to identify your app.
|
|
216
|
+
```ts
|
|
217
|
+
{
|
|
218
|
+
clientID: "my-client"
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
</Segment>
|
|
222
|
+
<NestedTitle id="microsoftoidcconfig.query" Tag="h4" parent="MicrosoftOidcConfig.">query?</NestedTitle>
|
|
223
|
+
<Segment>
|
|
224
|
+
<Section type="parameters">
|
|
225
|
+
<InlineSection>
|
|
226
|
+
**Type** <code class="primitive">Record</code><code class="symbol"><</code><code class="primitive">string</code>, <code class="primitive">string</code><code class="symbol">></code>
|
|
227
|
+
</InlineSection>
|
|
228
|
+
</Section>
|
|
229
|
+
Any additional parameters that you want to pass to the authorization endpoint.
|
|
230
|
+
```ts
|
|
231
|
+
{
|
|
232
|
+
query: {
|
|
233
|
+
prompt: "consent"
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
</Segment>
|
|
238
|
+
<NestedTitle id="microsoftoidcconfig.scopes" Tag="h4" parent="MicrosoftOidcConfig.">scopes?</NestedTitle>
|
|
239
|
+
<Segment>
|
|
240
|
+
<Section type="parameters">
|
|
241
|
+
<InlineSection>
|
|
242
|
+
**Type** <code class="primitive">string</code><code class="symbol">[]</code>
|
|
243
|
+
</InlineSection>
|
|
244
|
+
</Section>
|
|
245
|
+
A list of OIDC scopes that you want to request.
|
|
246
|
+
```ts
|
|
247
|
+
{
|
|
248
|
+
scopes: ["openid", "profile", "email"]
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
</Segment>
|
|
252
|
+
</div>
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Oauth2Provider
|
|
3
|
+
editUrl: https://github.com/toolbeam/openauth/blob/master/packages/openauth/src/provider/oauth2.ts
|
|
4
|
+
description: Reference doc for the `Oauth2Provider`.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
import { Segment, Section, NestedTitle, InlineSection } from 'toolbeam-docs-theme/components'
|
|
8
|
+
import { Tabs, TabItem } from '@astrojs/starlight/components'
|
|
9
|
+
|
|
10
|
+
<div class="tsdoc">
|
|
11
|
+
<Section type="about">
|
|
12
|
+
Use this to connect authentication providers that support OAuth 2.0.
|
|
13
|
+
|
|
14
|
+
```ts {5-12}
|
|
15
|
+
import { Oauth2Provider } from "@openauthjs/openauth/provider/oauth2"
|
|
16
|
+
|
|
17
|
+
export default issuer({
|
|
18
|
+
providers: {
|
|
19
|
+
oauth2: Oauth2Provider({
|
|
20
|
+
clientID: "1234567890",
|
|
21
|
+
clientSecret: "0987654321",
|
|
22
|
+
endpoint: {
|
|
23
|
+
authorization: "https://auth.myserver.com/authorize",
|
|
24
|
+
token: "https://auth.myserver.com/token"
|
|
25
|
+
}
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
```
|
|
30
|
+
</Section>
|
|
31
|
+
---
|
|
32
|
+
## Methods
|
|
33
|
+
### Oauth2Provider
|
|
34
|
+
<Segment>
|
|
35
|
+
<Section type="signature">
|
|
36
|
+
```ts
|
|
37
|
+
Oauth2Provider(config)
|
|
38
|
+
```
|
|
39
|
+
</Section>
|
|
40
|
+
<Section type="parameters">
|
|
41
|
+
#### Parameters
|
|
42
|
+
- <p><code class="key">config</code> [<code class="type">Oauth2Config</code>](/docs/provider/oauth2#oauth2config)</p>
|
|
43
|
+
</Section>
|
|
44
|
+
<InlineSection>
|
|
45
|
+
**Returns** <code class="type">Provider</code>
|
|
46
|
+
</InlineSection>
|
|
47
|
+
</Segment>
|
|
48
|
+
## Oauth2Config
|
|
49
|
+
<Segment>
|
|
50
|
+
<Section type="parameters">
|
|
51
|
+
- <p>[<code class="key">clientID</code>](#oauth2config.clientid) <code class="primitive">string</code></p>
|
|
52
|
+
- <p>[<code class="key">clientSecret</code>](#oauth2config.clientsecret) <code class="primitive">string</code></p>
|
|
53
|
+
- <p>[<code class="key">endpoint</code>](#oauth2config.endpoint) <code class="primitive">Object</code></p>
|
|
54
|
+
- <p>[<code class="key">authorization</code>](#endpoint.authorization) <code class="primitive">string</code></p>
|
|
55
|
+
- <p>[<code class="key">token</code>](#endpoint.token) <code class="primitive">string</code></p>
|
|
56
|
+
- <p>[<code class="key">pkce?</code>](#oauth2config.pkce) <code class="primitive">boolean</code></p>
|
|
57
|
+
- <p>[<code class="key">query?</code>](#oauth2config.query) <code class="primitive">Record</code><code class="symbol"><</code><code class="primitive">string</code>, <code class="primitive">string</code><code class="symbol">></code></p>
|
|
58
|
+
- <p>[<code class="key">scopes</code>](#oauth2config.scopes) <code class="primitive">string</code><code class="symbol">[]</code></p>
|
|
59
|
+
</Section>
|
|
60
|
+
</Segment>
|
|
61
|
+
<NestedTitle id="oauth2config.clientid" Tag="h4" parent="Oauth2Config.">clientID</NestedTitle>
|
|
62
|
+
<Segment>
|
|
63
|
+
<Section type="parameters">
|
|
64
|
+
<InlineSection>
|
|
65
|
+
**Type** <code class="primitive">string</code>
|
|
66
|
+
</InlineSection>
|
|
67
|
+
</Section>
|
|
68
|
+
The client ID.
|
|
69
|
+
|
|
70
|
+
This is just a string to identify your app.
|
|
71
|
+
```ts
|
|
72
|
+
{
|
|
73
|
+
clientID: "my-client"
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
</Segment>
|
|
77
|
+
<NestedTitle id="oauth2config.clientsecret" Tag="h4" parent="Oauth2Config.">clientSecret</NestedTitle>
|
|
78
|
+
<Segment>
|
|
79
|
+
<Section type="parameters">
|
|
80
|
+
<InlineSection>
|
|
81
|
+
**Type** <code class="primitive">string</code>
|
|
82
|
+
</InlineSection>
|
|
83
|
+
</Section>
|
|
84
|
+
The client secret.
|
|
85
|
+
|
|
86
|
+
This is a private key that's used to authenticate your app. It should be kept secret.
|
|
87
|
+
```ts
|
|
88
|
+
{
|
|
89
|
+
clientSecret: "0987654321"
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
</Segment>
|
|
93
|
+
<NestedTitle id="oauth2config.endpoint" Tag="h4" parent="Oauth2Config.">endpoint</NestedTitle>
|
|
94
|
+
<Segment>
|
|
95
|
+
<Section type="parameters">
|
|
96
|
+
<InlineSection>
|
|
97
|
+
**Type** <code class="primitive">Object</code>
|
|
98
|
+
</InlineSection>
|
|
99
|
+
</Section>
|
|
100
|
+
The URLs of the authorization and token endpoints.
|
|
101
|
+
```ts
|
|
102
|
+
{
|
|
103
|
+
endpoint: {
|
|
104
|
+
authorization: "https://auth.myserver.com/authorize",
|
|
105
|
+
token: "https://auth.myserver.com/token"
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
</Segment>
|
|
110
|
+
<NestedTitle id="endpoint.authorization" Tag="h5" parent="Oauth2Config.endpoint.">authorization</NestedTitle>
|
|
111
|
+
<Segment>
|
|
112
|
+
<Section type="parameters">
|
|
113
|
+
<InlineSection>
|
|
114
|
+
**Type** <code class="primitive">string</code>
|
|
115
|
+
</InlineSection>
|
|
116
|
+
</Section>
|
|
117
|
+
The URL of the authorization endpoint.
|
|
118
|
+
</Segment>
|
|
119
|
+
<NestedTitle id="endpoint.token" Tag="h5" parent="Oauth2Config.endpoint.">token</NestedTitle>
|
|
120
|
+
<Segment>
|
|
121
|
+
<Section type="parameters">
|
|
122
|
+
<InlineSection>
|
|
123
|
+
**Type** <code class="primitive">string</code>
|
|
124
|
+
</InlineSection>
|
|
125
|
+
</Section>
|
|
126
|
+
The URL of the token endpoint.
|
|
127
|
+
</Segment>
|
|
128
|
+
<NestedTitle id="oauth2config.pkce" Tag="h4" parent="Oauth2Config.">pkce?</NestedTitle>
|
|
129
|
+
<Segment>
|
|
130
|
+
<Section type="parameters">
|
|
131
|
+
<InlineSection>
|
|
132
|
+
**Type** <code class="primitive">boolean</code>
|
|
133
|
+
</InlineSection>
|
|
134
|
+
</Section>
|
|
135
|
+
|
|
136
|
+
<InlineSection>
|
|
137
|
+
**Default** false
|
|
138
|
+
</InlineSection>
|
|
139
|
+
Whether to use PKCE (Proof Key for Code Exchange) for the authorization code flow.
|
|
140
|
+
Some providers like x.com require this.
|
|
141
|
+
</Segment>
|
|
142
|
+
<NestedTitle id="oauth2config.query" Tag="h4" parent="Oauth2Config.">query?</NestedTitle>
|
|
143
|
+
<Segment>
|
|
144
|
+
<Section type="parameters">
|
|
145
|
+
<InlineSection>
|
|
146
|
+
**Type** <code class="primitive">Record</code><code class="symbol"><</code><code class="primitive">string</code>, <code class="primitive">string</code><code class="symbol">></code>
|
|
147
|
+
</InlineSection>
|
|
148
|
+
</Section>
|
|
149
|
+
Any additional parameters that you want to pass to the authorization endpoint.
|
|
150
|
+
```ts
|
|
151
|
+
{
|
|
152
|
+
query: {
|
|
153
|
+
access_type: "offline",
|
|
154
|
+
prompt: "consent"
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
</Segment>
|
|
159
|
+
<NestedTitle id="oauth2config.scopes" Tag="h4" parent="Oauth2Config.">scopes</NestedTitle>
|
|
160
|
+
<Segment>
|
|
161
|
+
<Section type="parameters">
|
|
162
|
+
<InlineSection>
|
|
163
|
+
**Type** <code class="primitive">string</code><code class="symbol">[]</code>
|
|
164
|
+
</InlineSection>
|
|
165
|
+
</Section>
|
|
166
|
+
A list of OAuth scopes that you want to request.
|
|
167
|
+
```ts
|
|
168
|
+
{
|
|
169
|
+
scopes: ["email", "profile"]
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
</Segment>
|
|
173
|
+
</div>
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: OidcProvider
|
|
3
|
+
editUrl: https://github.com/toolbeam/openauth/blob/master/packages/openauth/src/provider/oidc.ts
|
|
4
|
+
description: Reference doc for the `OidcProvider`.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
import { Segment, Section, NestedTitle, InlineSection } from 'toolbeam-docs-theme/components'
|
|
8
|
+
import { Tabs, TabItem } from '@astrojs/starlight/components'
|
|
9
|
+
|
|
10
|
+
<div class="tsdoc">
|
|
11
|
+
<Section type="about">
|
|
12
|
+
Use this to connect authentication providers that support OIDC.
|
|
13
|
+
|
|
14
|
+
```ts {5-8}
|
|
15
|
+
import { OidcProvider } from "@openauthjs/openauth/provider/oidc"
|
|
16
|
+
|
|
17
|
+
export default issuer({
|
|
18
|
+
providers: {
|
|
19
|
+
oauth2: OidcProvider({
|
|
20
|
+
clientId: "1234567890",
|
|
21
|
+
issuer: "https://auth.myserver.com"
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
```
|
|
26
|
+
</Section>
|
|
27
|
+
---
|
|
28
|
+
## Methods
|
|
29
|
+
### OidcProvider
|
|
30
|
+
<Segment>
|
|
31
|
+
<Section type="signature">
|
|
32
|
+
```ts
|
|
33
|
+
OidcProvider(config)
|
|
34
|
+
```
|
|
35
|
+
</Section>
|
|
36
|
+
<Section type="parameters">
|
|
37
|
+
#### Parameters
|
|
38
|
+
- <p><code class="key">config</code> [<code class="type">OidcConfig</code>](/docs/provider/oidc#oidcconfig)</p>
|
|
39
|
+
</Section>
|
|
40
|
+
<InlineSection>
|
|
41
|
+
**Returns** <code class="type">Provider</code>
|
|
42
|
+
</InlineSection>
|
|
43
|
+
</Segment>
|
|
44
|
+
## OidcConfig
|
|
45
|
+
<Segment>
|
|
46
|
+
<Section type="parameters">
|
|
47
|
+
- <p>[<code class="key">clientID</code>](#oidcconfig.clientid) <code class="primitive">string</code></p>
|
|
48
|
+
- <p>[<code class="key">issuer</code>](#oidcconfig.issuer) <code class="primitive">string</code></p>
|
|
49
|
+
- <p>[<code class="key">query?</code>](#oidcconfig.query) <code class="primitive">Record</code><code class="symbol"><</code><code class="primitive">string</code>, <code class="primitive">string</code><code class="symbol">></code></p>
|
|
50
|
+
- <p>[<code class="key">scopes?</code>](#oidcconfig.scopes) <code class="primitive">string</code><code class="symbol">[]</code></p>
|
|
51
|
+
</Section>
|
|
52
|
+
</Segment>
|
|
53
|
+
<NestedTitle id="oidcconfig.clientid" Tag="h4" parent="OidcConfig.">clientID</NestedTitle>
|
|
54
|
+
<Segment>
|
|
55
|
+
<Section type="parameters">
|
|
56
|
+
<InlineSection>
|
|
57
|
+
**Type** <code class="primitive">string</code>
|
|
58
|
+
</InlineSection>
|
|
59
|
+
</Section>
|
|
60
|
+
The client ID.
|
|
61
|
+
|
|
62
|
+
This is just a string to identify your app.
|
|
63
|
+
```ts
|
|
64
|
+
{
|
|
65
|
+
clientID: "my-client"
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
</Segment>
|
|
69
|
+
<NestedTitle id="oidcconfig.issuer" Tag="h4" parent="OidcConfig.">issuer</NestedTitle>
|
|
70
|
+
<Segment>
|
|
71
|
+
<Section type="parameters">
|
|
72
|
+
<InlineSection>
|
|
73
|
+
**Type** <code class="primitive">string</code>
|
|
74
|
+
</InlineSection>
|
|
75
|
+
</Section>
|
|
76
|
+
The URL of your authorization server.
|
|
77
|
+
```ts
|
|
78
|
+
{
|
|
79
|
+
issuer: "https://auth.myserver.com"
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
</Segment>
|
|
83
|
+
<NestedTitle id="oidcconfig.query" Tag="h4" parent="OidcConfig.">query?</NestedTitle>
|
|
84
|
+
<Segment>
|
|
85
|
+
<Section type="parameters">
|
|
86
|
+
<InlineSection>
|
|
87
|
+
**Type** <code class="primitive">Record</code><code class="symbol"><</code><code class="primitive">string</code>, <code class="primitive">string</code><code class="symbol">></code>
|
|
88
|
+
</InlineSection>
|
|
89
|
+
</Section>
|
|
90
|
+
Any additional parameters that you want to pass to the authorization endpoint.
|
|
91
|
+
```ts
|
|
92
|
+
{
|
|
93
|
+
query: {
|
|
94
|
+
prompt: "consent"
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
</Segment>
|
|
99
|
+
<NestedTitle id="oidcconfig.scopes" Tag="h4" parent="OidcConfig.">scopes?</NestedTitle>
|
|
100
|
+
<Segment>
|
|
101
|
+
<Section type="parameters">
|
|
102
|
+
<InlineSection>
|
|
103
|
+
**Type** <code class="primitive">string</code><code class="symbol">[]</code>
|
|
104
|
+
</InlineSection>
|
|
105
|
+
</Section>
|
|
106
|
+
A list of OIDC scopes that you want to request.
|
|
107
|
+
```ts
|
|
108
|
+
{
|
|
109
|
+
scopes: ["openid", "profile", "email"]
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
</Segment>
|
|
113
|
+
</div>
|