Skip to content

Commit

Permalink
add authkit to docs and examples
Browse files Browse the repository at this point in the history
  • Loading branch information
fierysolid committed Jan 15, 2025
1 parent 0f077ea commit 66fbe22
Show file tree
Hide file tree
Showing 10 changed files with 136 additions and 14 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/2_bug_provider.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ body:
- "Atlassian"
- "Auth0"
- "Authentik"
- "AuthKit"
- "Azure Active Directory"
- "Azure Active Directory B2C"
- "Azure DevOps"
Expand Down
2 changes: 2 additions & 0 deletions apps/dev/express/src/config/auth.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Apple from "@auth/express/providers/apple"
import Auth0 from "@auth/express/providers/auth0"
import AuthKit from "@auth/express/providers/authkit"
import AzureB2C from "@auth/express/providers/azure-ad-b2c"
import BoxyHQSAML from "@auth/express/providers/boxyhq-saml"
import Cognito from "@auth/express/providers/cognito"
Expand Down Expand Up @@ -31,6 +32,7 @@ export const authConfig = {
providers: [
Apple,
Auth0,
AuthKit,
AzureB2C({
clientId: process.env.AUTH_AZURE_AD_B2C_ID,
clientSecret: process.env.AUTH_AZURE_AD_B2C_SECRET,
Expand Down
2 changes: 2 additions & 0 deletions apps/examples/express/src/config/auth.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Apple from "@auth/express/providers/apple"
import Auth0 from "@auth/express/providers/auth0"
import AuthKit from "@auth/express/providers/authkit"
import AzureB2C from "@auth/express/providers/azure-ad-b2c"
import BoxyHQSAML from "@auth/express/providers/boxyhq-saml"
import Cognito from "@auth/express/providers/cognito"
Expand Down Expand Up @@ -30,6 +31,7 @@ export const authConfig = {
providers: [
Apple,
Auth0,
AuthKit,
AzureB2C({
clientId: process.env.AUTH_AZURE_AD_B2C_ID,
clientSecret: process.env.AUTH_AZURE_AD_B2C_SECRET,
Expand Down
2 changes: 2 additions & 0 deletions apps/examples/nextjs-pages/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import NextAuth from "next-auth"
// import Apple from "next-auth/providers/apple"
// import Auth0 from "next-auth/providers/auth0"
// import Authentik from "next-auth/providers/authentik"
// import AuthKit from "next-auth/providers/authkit"
// import AzureAD from "next-auth/providers/azure-ad"
// import AzureB2C from "next-auth/providers/azure-ad-b2c"
// import Battlenet from "next-auth/providers/battlenet"
Expand Down Expand Up @@ -72,6 +73,7 @@ export const config = {
// Apple,
// Auth0,
// Authentik,
// AuthKit,
// AzureAD,
// AzureB2C,
// Battlenet,
Expand Down
2 changes: 2 additions & 0 deletions apps/examples/nextjs/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import "next-auth/jwt"
import Apple from "next-auth/providers/apple"
// import Atlassian from "next-auth/providers/atlassian"
import Auth0 from "next-auth/providers/auth0"
import AuthKit from "next-auth/providers/authkit"
import AzureB2C from "next-auth/providers/azure-ad-b2c"
import BankIDNorway from "next-auth/providers/bankid-no"
import BoxyHQSAML from "next-auth/providers/boxyhq-saml"
Expand Down Expand Up @@ -56,6 +57,7 @@ export const { handlers, auth, signIn, signOut } = NextAuth({
Apple,
// Atlassian,
Auth0,
AuthKit,
AzureB2C,
BankIDNorway,
BoxyHQSAML({
Expand Down
2 changes: 2 additions & 0 deletions apps/examples/sveltekit/src/auth.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { SvelteKitAuth } from "@auth/sveltekit"
import Apple from "@auth/sveltekit/providers/apple"
import Auth0 from "@auth/sveltekit/providers/auth0"
import AuthKit from "@auth/sveltekit/providers/authkit"
import AzureB2C from "@auth/sveltekit/providers/azure-ad-b2c"
import BoxyHQSAML from "@auth/sveltekit/providers/boxyhq-saml"
import Cognito from "@auth/sveltekit/providers/cognito"
Expand Down Expand Up @@ -32,6 +33,7 @@ export const { handle, signIn, signOut } = SvelteKitAuth({
providers: [
Apple,
Auth0,
AuthKit,
AzureB2C({
clientId: env.AUTH_AZURE_AD_B2C_ID,
clientSecret: env.AUTH_AZURE_AD_B2C_SECRET,
Expand Down
2 changes: 2 additions & 0 deletions apps/proxy/api/[auth].ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Auth, setEnvDefaults, type AuthConfig } from "@auth/core"
import Apple from "@auth/core/providers/apple"
import Auth0 from "@auth/core/providers/auth0"
import AuthKit from "@auth/core/providers/authkit"
import AzureB2C from "@auth/core/providers/azure-ad-b2c"
import BankId from "@auth/core/providers/bankid-no"
import BoxyHQSAML from "@auth/core/providers/boxyhq-saml"
Expand Down Expand Up @@ -34,6 +35,7 @@ const authConfig: AuthConfig = {
providers: [
Apple,
Auth0,
AuthKit,
AzureB2C,
BankId,
BoxyHQSAML({
Expand Down
1 change: 1 addition & 0 deletions docs/pages/data/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"asgardeo": "Asgardeo",
"atlassian": "Atlassian",
"authentik": "Authentik",
"authkit": "AuthKit",
"azure-ad-b2c": "Azure Active Directory B2C",
"azure-ad": "Azure Active Directory",
"azure-devops": "Azure DevOps",
Expand Down
107 changes: 107 additions & 0 deletions docs/pages/getting-started/providers/authkit.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
---
title: WorkOS
---

import { Callout } from "nextra/components"
import { Code } from "@/components/Code"

<img align="right" src="/img/providers/workos.svg" height="64" width="64" />

# AuthKit Provider

## Resources

- [WorkOS AuthKit documentation](https://workos.com/docs/reference/user-management)

## Setup

### Callback URL

<Code>
<Code.Next>

```bash
https://example.com/api/auth/callback/authkit
```

</Code.Next>
<Code.Qwik>

```bash
https://example.com/auth/callback/authkit
```

</Code.Qwik>
<Code.Svelte>

```bash
https://example.com/auth/callback/authkit
```

</Code.Svelte>
</Code>

### Environment Variables

```
AUTH_AUTHKIT_ID
AUTH_AUTHKIT_SECRET
```

### Configuration

<Code>
<Code.Next>

```ts filename="/auth.ts"
import NextAuth from "next-auth"
import AuthKit from "next-auth/providers/authkit"

export const { handlers, auth, signIn, signOut } = NextAuth({
providers: [AuthKit({ authkitProvider: "authkit", screenHint: "sign-in" })],
})
```

</Code.Next>
<Code.Qwik>

```ts filename="/src/routes/[email protected]"
import { QwikAuth$ } from "@auth/qwik"
import AuthKit from "@auth/qwik/providers/authkit"

export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$(
() => ({
providers: [AuthKit({ authkitProvider: "authkit", screenHint: "sign-in" })],
})
)
```

</Code.Qwik>
<Code.Svelte>

```ts filename="/src/auth.ts"
import { SvelteKitAuth } from "@auth/sveltekit"
import AuthKit from "@auth/sveltekit/providers/authkit"

export const { handle, signIn, signOut } = SvelteKitAuth({
providers: [AuthKit({ authkitProvider: "authkit", screenHint: "sign-in" })],
})
```

</Code.Svelte>
<Code.Express>

```ts filename="/src/app.ts"
import { ExpressAuth } from "@auth/express"
import AuthKit from "@auth/express/providers/authkit"

app.use(
"/auth/*",
ExpressAuth({
providers: [AuthKit({ authkitProvider: "authkit", screenHint: "sign-in" })],
})
)
```

</Code.Express>
</Code>
29 changes: 15 additions & 14 deletions packages/core/src/providers/authkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,25 @@ import type { OAuthConfig, OAuthUserConfig } from "./index.js"
export interface AuthKitProfile extends Record<string, any> {
object: string
id: string
organization_id: string
connection_id: string
connection_type: string
idp_id: string
email: string
email_verified: boolean
first_name: string
last_name: string
raw_attributes: {
id: string
email: string
lastName: string
firstName: string
picture: string
}
profile_picture_url: string | null
created_at: string
updated_at: string
}

export default function AuthKit<P extends AuthKitProfile>(
options: OAuthUserConfig<P>
options: OAuthUserConfig<P> & {
authkitProvider?:
| "authkit"
| "GoogleOAuth"
| "AppleOAuth"
| "MicrosoftOAuth"
| "GitHubOAuth"
screenHint?: "sign-in" | "sign-up"
}
): OAuthConfig<P> {
return {
id: "authkit",
Expand All @@ -35,8 +36,8 @@ export default function AuthKit<P extends AuthKitProfile>(
authorization: {
url: "https://api.workos.com/user_management/authorize",
params: {
provider: "authkit",
screen_hint: "sign-in",
provider: options.authkitProvider ?? "authkit",
screen_hint: options.screenHint ?? "sign-up",
},
},
token: {
Expand Down

0 comments on commit 66fbe22

Please sign in to comment.