Skip to content

Commit

Permalink
fix(providers): update providers config from verification walk-throug…
Browse files Browse the repository at this point in the history
…hs (#10582)

* fix(netlify): add "?scope" query param to authorizationUrl

* fix(slack): update checks

* fix(workos): add connection name to authorizationUrl

* fix: cleanup providers in example app and workos docs

* chore: update example connection
  • Loading branch information
ndom91 committed Apr 14, 2024
1 parent 10b4de9 commit 85ab5fa
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
6 changes: 3 additions & 3 deletions apps/examples/nextjs/auth.ts
Expand Up @@ -55,17 +55,17 @@ export const config = {
Hubspot,
Keycloak,
LinkedIn,
Netlify({ authorization: "https://app.netlify.com/authorize?scope" }),
Netlify,
Okta,
Passage,
Pinterest,
Reddit,
Slack({ checks: ["nonce"] }), // TODO: Make this default in core
Slack,
Spotify,
Twitch,
Twitter,
WorkOS({
authorization: `https://api.workos.com/sso/authorize?${new URLSearchParams({ connection: process.env.AUTH_WORKOS_CONNECTION ?? "" })}`,
connection: process.env.AUTH_WORKOS_CONNECTION,
}),
Zoom,
],
Expand Down
12 changes: 8 additions & 4 deletions docs/pages/getting-started/providers/workos.mdx
Expand Up @@ -35,9 +35,10 @@ https://example.com/auth/callback/workos
```
AUTH_WORKOS_ID
AUTH_WORKOS_SECRET
AUTH_WORKOS_ISSUER
```

WorkOS also requires you to pass in your `connection` ID to the provider.

### Configuration

<Code>
Expand All @@ -48,7 +49,7 @@ import NextAuth from "next-auth"
import WorkOS from "next-auth/providers/workos"

export const { handlers, auth, signIn, signOut } = NextAuth({
providers: [WorkOS],
providers: [WorkOS({ connection: "conn_abc123" })],
})
```

Expand All @@ -60,7 +61,7 @@ import { SvelteKitAuth } from "@auth/sveltekit"
import WorkOS from "@auth/sveltekit/providers/workos"

export const { handle, signIn, signOut } = SvelteKitAuth({
providers: [WorkOS],
providers: [WorkOS({ connection: "conn_abc123" })],
})
```

Expand All @@ -71,7 +72,10 @@ export const { handle, signIn, signOut } = SvelteKitAuth({
import { ExpressAuth } from "@auth/express"
import WorkOS from "@auth/express/providers/workos"

app.use("/auth/*", ExpressAuth({ providers: [WorkOS] }))
app.use(
"/auth/*",
ExpressAuth({ providers: [WorkOS({ connection: "conn_abc123" })] })
)
```

</Code.Express>
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/providers/netlify.ts
Expand Up @@ -66,7 +66,7 @@ export default function Netlify(
id: "netlify",
name: "Netlify",
type: "oauth",
authorization: "https://app.netlify.com/authorize",
authorization: "https://app.netlify.com/authorize?scope",
token: "https://api.netlify.com/oauth/token",
userinfo: "https://api.netlify.com/api/v1/user",
profile(profile) {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/providers/slack.ts
Expand Up @@ -106,6 +106,7 @@ export default function Slack<P extends SlackProfile>(
name: "Slack",
type: "oidc",
issuer: "https://slack.com",
checks: ["nonce"],
style: { brandColor: "#611f69" },
options,
}
Expand Down
8 changes: 5 additions & 3 deletions packages/core/src/providers/workos.ts
Expand Up @@ -144,15 +144,17 @@ export interface WorkOSProfile extends Record<string, any> {
* :::
*/
export default function WorkOS<P extends WorkOSProfile>(
options: OAuthUserConfig<P>
options: OAuthUserConfig<P> & { connection: string }
): OAuthConfig<P> {
const { issuer = "https://api.workos.com/" } = options
const { issuer = "https://api.workos.com/", connection = "" } = options

const connectionParams = new URLSearchParams({ connection })

return {
id: "workos",
name: "WorkOS",
type: "oauth",
authorization: `${issuer}sso/authorize`,
authorization: `${issuer}sso/authorize?${connectionParams}`,
token: `${issuer}sso/token`,
client: {
token_endpoint_auth_method: "client_secret_post",
Expand Down

0 comments on commit 85ab5fa

Please sign in to comment.