diff --git a/apps/dev/qwik/src/routes/index.tsx b/apps/dev/qwik/src/routes/index.tsx index 6ad9dcbce1..df1bcaf46c 100644 --- a/apps/dev/qwik/src/routes/index.tsx +++ b/apps/dev/qwik/src/routes/index.tsx @@ -19,14 +19,14 @@ export default component$(() => { Session: {JSON.stringify(session.value)}
- diff --git a/docs/components/Code/index.tsx b/docs/components/Code/index.tsx index 16ff8c99fa..22f5fd498b 100644 --- a/docs/components/Code/index.tsx +++ b/docs/components/Code/index.tsx @@ -1,5 +1,5 @@ -import { useThemeConfig } from "nextra-theme-docs" import { useRouter } from "next/router" +import { useThemeConfig } from "nextra-theme-docs" import { Tabs } from "nextra/components" import React, { Children, useEffect, useState } from "react" @@ -14,9 +14,11 @@ Code.NextClient = NextClientCode Code.Svelte = SvelteCode // Code.Solid = SolidCode; Code.Express = ExpressCode +Code.Qwik = QwikCode const baseFrameworks = { [NextCode.name]: "Next.js", + [QwikCode.name]: "Qwik", [SvelteCode.name]: "SvelteKit", [ExpressCode.name]: "Express", // [SolidCode.name]: "SolidStart", @@ -25,6 +27,7 @@ const baseFrameworks = { const allFrameworks = { [NextCode.name]: "Next.js", [NextClientCode.name]: "Next.js (Client)", + [QwikCode.name]: "Qwik", [SvelteCode.name]: "SvelteKit", // [SolidCode.name]: "SolidStart", [ExpressCode.name]: "Express", @@ -124,3 +127,7 @@ function SvelteCode({ children }: ChildrenProps) { function ExpressCode({ children }: ChildrenProps) { return {children} } + +function QwikCode({ children }: ChildrenProps) { + return {children} +} diff --git a/docs/components/OAuthProviderInstructions/content/components/SetupCode.tsx b/docs/components/OAuthProviderInstructions/content/components/SetupCode.tsx index c5aad8ae28..a28c8bfe3d 100644 --- a/docs/components/OAuthProviderInstructions/content/components/SetupCode.tsx +++ b/docs/components/OAuthProviderInstructions/content/components/SetupCode.tsx @@ -49,6 +49,26 @@ export const { GET, POST } = handlers }} /> + + We recommend setting up your configuration in{" "} + /src/routes/plugin@auth.ts file. +
+      
       
         In SvelteKit you should also setup your Auth.js configuration in a file
         at /src/auth.ts.
diff --git a/docs/components/OAuthProviderInstructions/content/components/SignInCode.tsx b/docs/components/OAuthProviderInstructions/content/components/SignInCode.tsx
index 4b1514d43b..1c5f585e89 100644
--- a/docs/components/OAuthProviderInstructions/content/components/SignInCode.tsx
+++ b/docs/components/OAuthProviderInstructions/content/components/SignInCode.tsx
@@ -37,6 +37,49 @@ export function SignIn() {
           }}
         />
       
+      
+        With Qwik we can do a server-side login with Form action, or a more
+        simple client-side login via submit method.
+        
 {
+  const signInSig = useSignIn()
+
+  return (
+    <>
+      {/* server-side login with Form action */}
+      
+ + + +
+ + {/* submit method */} + signInSig.submit({ redirectTo: "/" })} + > + SignIn + + + ) +}) `), + }} + /> + With SvelteKit we can do a server-side login with Form Actions, or a more simple client-side login via links and redirects. diff --git a/docs/components/OAuthProviderInstructions/content/index.tsx b/docs/components/OAuthProviderInstructions/content/index.tsx index ec4644ed18..23d70bc830 100644 --- a/docs/components/OAuthProviderInstructions/content/index.tsx +++ b/docs/components/OAuthProviderInstructions/content/index.tsx @@ -75,6 +75,13 @@ export function OAuthInstructions({ providerId, disabled = false }: Props) {
+ +
+            
+              {`[origin]/auth/callback/${providerId}`}
+            
+          
+
             
@@ -119,6 +126,20 @@ AUTH_${providerId.toUpperCase().replace(/-/gi, "_")}_SECRET={CLIENT_SECRET}
             }}
           />
         
+        
+          
+        
         
           
+
+
+```ts filename="/src/routes/plugin@auth.ts"
+import { QwikAuth$ } from "@auth/qwik"
+import { TableStorageAdapter } from "@auth/azure-tables-adapter"
+import { AzureNamedKeyCredential, TableClient } from "@azure/data-tables"
+
+const credential = new AzureNamedKeyCredential(
+  import.meta.env.AUTH_AZURE_ACCOUNT,
+  import.meta.env.AUTH_AZURE_ACCESS_KEY
+)
+const authClient = new TableClient(
+  import.meta.env.AUTH_AZURE_TABLES_ENDPOINT,
+  "auth",
+  credential
+)
+
+export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$(
+  () => ({
+    providers: [],
+    adapter: TableStorageAdapter(authClient),
+  })
+)
+```
+
+
 
 
 ```ts filename="./src/auth.ts"
diff --git a/docs/pages/getting-started/adapters/d1.mdx b/docs/pages/getting-started/adapters/d1.mdx
index ed9908eaee..c233301383 100644
--- a/docs/pages/getting-started/adapters/d1.mdx
+++ b/docs/pages/getting-started/adapters/d1.mdx
@@ -37,6 +37,21 @@ export const { handlers, auth, signIn, signOut } = NextAuth({
 ```
 
 
+
+
+```ts filename="/src/routes/plugin@auth.ts"
+import { QwikAuth$ } from "@auth/qwik"
+import { D1Adapter } from "@auth/d1-adapter"
+
+export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$(
+  () => ({
+    providers: [],
+    adapter: D1Adapter(env.db),
+  })
+)
+```
+
+
 
 
 ```ts filename="./src/auth.ts"
diff --git a/docs/pages/getting-started/adapters/dgraph.mdx b/docs/pages/getting-started/adapters/dgraph.mdx
index aee857758e..c2db4ba787 100644
--- a/docs/pages/getting-started/adapters/dgraph.mdx
+++ b/docs/pages/getting-started/adapters/dgraph.mdx
@@ -46,6 +46,27 @@ export const { handlers, auth, signIn, signOut } = NextAuth({
 ```
 
 
+
+
+```ts filename="/src/routes/plugin@auth.ts"
+import { QwikAuth$ } from "@auth/qwik"
+import { DgraphAdapter } from "@auth/dgraph-adapter"
+
+export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$(
+  () => ({
+    providers: [],
+    adapter: DgraphAdapter({
+      endpoint: import.meta.env.DGRAPH_GRAPHQL_ENDPOINT,
+      authToken: import.meta.env.DGRAPH_GRAPHQL_KEY,
+      // you can omit the following properties if you are running an unsecure schema
+      authHeader: import.meta.env.AUTH_HEADER, // default: "Authorization",
+      jwtSecret: import.meta.env.SECRET,
+    }),
+  })
+)
+```
+
+
 
 
 ```ts filename="./src/auth.ts"
diff --git a/docs/pages/getting-started/adapters/drizzle.mdx b/docs/pages/getting-started/adapters/drizzle.mdx
index c212f7fedd..9a2a709c35 100644
--- a/docs/pages/getting-started/adapters/drizzle.mdx
+++ b/docs/pages/getting-started/adapters/drizzle.mdx
@@ -369,6 +369,22 @@ export const { handlers, auth, signIn, signOut } = NextAuth({
 ```
 
 
+
+
+```ts filename="/src/routes/plugin@auth.ts"
+import { QwikAuth$ } from "@auth/qwik"
+import { DrizzleAdapter } from "@auth/drizzle-adapter"
+import { db } from "./schema.ts"
+
+export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$(
+  () => ({
+    providers: [],
+    adapter: DrizzleAdapter(db),
+  })
+)
+```
+
+
 
 
 ```ts filename="./src/auth.ts"
diff --git a/docs/pages/getting-started/adapters/dynamodb.mdx b/docs/pages/getting-started/adapters/dynamodb.mdx
index 53c7fdaef1..8362d63046 100644
--- a/docs/pages/getting-started/adapters/dynamodb.mdx
+++ b/docs/pages/getting-started/adapters/dynamodb.mdx
@@ -67,6 +67,39 @@ export const { handlers, auth, signIn, signOut } = NextAuth({
 ```
 
 
+
+
+```ts filename="/src/routes/plugin@auth.ts"
+import { QwikAuth$ } from "@auth/qwik"
+import { DynamoDB, DynamoDBClientConfig } from "@aws-sdk/client-dynamodb"
+import { DynamoDBDocument } from "@aws-sdk/lib-dynamodb"
+import { DynamoDBAdapter } from "@auth/dynamodb-adapter"
+
+const config: DynamoDBClientConfig = {
+  credentials: {
+    accessKeyId: import.meta.env.AUTH_DYNAMODB_ID,
+    secretAccessKey: import.meta.env.AUTH_DYNAMODB_SECRET,
+  },
+  region: import.meta.env.AUTH_DYNAMODB_REGION,
+}
+
+const client = DynamoDBDocument.from(new DynamoDB(config), {
+  marshallOptions: {
+    convertEmptyValues: true,
+    removeUndefinedValues: true,
+    convertClassInstanceToMap: true,
+  },
+})
+
+export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$(
+  () => ({
+    providers: [],
+    adapter: DynamoDBAdapter(client),
+  })
+)
+```
+
+
 
 
 ```ts filename="./src/auth.ts"
diff --git a/docs/pages/getting-started/adapters/edgedb.mdx b/docs/pages/getting-started/adapters/edgedb.mdx
index 178d562a36..e596b2c3e1 100644
--- a/docs/pages/getting-started/adapters/edgedb.mdx
+++ b/docs/pages/getting-started/adapters/edgedb.mdx
@@ -44,6 +44,24 @@ export const { handlers, auth, signIn, signOut } = NextAuth({
 ```
 
 
+
+
+```ts filename="/src/routes/plugin@auth.ts"
+import { QwikAuth$ } from "@auth/qwik"
+import { EdgeDBAdapter } from "@auth/edgedb-adapter"
+import { createClient } from "edgedb"
+
+const client = createClient({ dsn: import.meta.env.AUTH_EDGEDB_DSN })
+
+export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$(
+  () => ({
+    providers: [],
+    adapter: EdgeDBAdapter(client),
+  })
+)
+```
+
+
 
 
 ```js filename="./auth.ts"
diff --git a/docs/pages/getting-started/adapters/fauna.mdx b/docs/pages/getting-started/adapters/fauna.mdx
index d2dad159a6..e2ed0de477 100644
--- a/docs/pages/getting-started/adapters/fauna.mdx
+++ b/docs/pages/getting-started/adapters/fauna.mdx
@@ -46,6 +46,27 @@ export { handlers, auth, signIn, signOut } = NextAuth({
 ```
 
 
+
+
+```ts filename="/src/routes/plugin@auth.ts"
+import { QwikAuth$ } from "@auth/qwik"
+import { Client } from "fauna"
+import { FaunaAdapter } from "@auth/fauna-adapter"
+
+const client = new Client({
+  secret: import.meta.env.AUTH_FAUNA_SECRET,
+  endpoint: new URL(import.meta.env.AUTH_FAUNA_CLIENT),
+})
+
+export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$(
+  () => ({
+    providers: [],
+    adapter: FaunaAdapter(client),
+  })
+)
+```
+
+
 
 
 ```ts filename="./src/auth.ts"
diff --git a/docs/pages/getting-started/adapters/firebase.mdx b/docs/pages/getting-started/adapters/firebase.mdx
index cee56e08eb..f48dbbcfaf 100644
--- a/docs/pages/getting-started/adapters/firebase.mdx
+++ b/docs/pages/getting-started/adapters/firebase.mdx
@@ -46,6 +46,21 @@ export { handlers, auth, signIn, signOut } = NextAuth({
 ```
 
 
+
+
+```ts filename="/src/routes/plugin@auth.ts"
+import { QwikAuth$ } from "@auth/qwik"
+import { FirestoreAdapter } from "@auth/firebase-adapter"
+
+export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$(
+  () => ({
+    providers: [],
+    adapter: FirestoreAdapter(),
+  })
+)
+```
+
+
 
 
 ```ts filename="src/auth.ts"
diff --git a/docs/pages/getting-started/adapters/hasura.mdx b/docs/pages/getting-started/adapters/hasura.mdx
index 7ceb363afb..c8f3f915d3 100644
--- a/docs/pages/getting-started/adapters/hasura.mdx
+++ b/docs/pages/getting-started/adapters/hasura.mdx
@@ -42,6 +42,24 @@ export const { handlers, auth, signIn, signOut } = NextAuth({
 ```
 
 
+
+
+```ts filename="/src/routes/plugin@auth.ts"
+import { QwikAuth$ } from "@auth/qwik"
+import { HasuraAdapter } from "@auth/hasura-adapter"
+
+export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$(
+  () => ({
+    providers: [],
+    adapter: HasuraAdapter({
+      endpoint: import.meta.env.AUTH_HASURA_GRAPHQL,
+      adminSecret: import.meta.env.AUTH_HASURA_SECRET,
+    }),
+  })
+)
+```
+
+
 
 
 ```ts filename="./auth.ts"
diff --git a/docs/pages/getting-started/adapters/kysely.mdx b/docs/pages/getting-started/adapters/kysely.mdx
index bdb7a5a1d3..f318bf182c 100644
--- a/docs/pages/getting-started/adapters/kysely.mdx
+++ b/docs/pages/getting-started/adapters/kysely.mdx
@@ -50,6 +50,22 @@ export const { handlers, auth, signIn, signOut } = NextAuth({
 ```
 
 
+
+
+```ts filename="/src/routes/plugin@auth.ts"
+import { QwikAuth$ } from "@auth/qwik"
+import { KyselyAdapter } from "@auth/kysely-adapter"
+import { db } from "../../../db"
+
+export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$(
+  () => ({
+    providers: [],
+    adapter: KyselyAdapter(db),
+  })
+)
+```
+
+
 
 
 ```ts filename="./src/auth.ts"
diff --git a/docs/pages/getting-started/adapters/mikro-orm.mdx b/docs/pages/getting-started/adapters/mikro-orm.mdx
index b72b0c5fa4..4d31b830d9 100644
--- a/docs/pages/getting-started/adapters/mikro-orm.mdx
+++ b/docs/pages/getting-started/adapters/mikro-orm.mdx
@@ -43,6 +43,26 @@ export const { handlers, auth, signIn, signOut } = NextAuth({
 ```
 
 
+
+
+```ts filename="/src/routes/plugin@auth.ts"
+import { QwikAuth$ } from "@auth/qwik"
+import { MikroOrmAdapter } from "@auth/mikro-orm-adapter"
+
+export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$(
+  () => ({
+    providers: [],
+    adapter: MikroOrmAdapter({
+      // MikroORM options object - https://mikro-orm.io/docs/next/configuration#driver
+      dbName: import.meta.env.DATABASE_CONNECTION_STRING,
+      type: "sqlite",
+      debug: true,
+    }),
+  })
+)
+```
+
+
 
 
 ```ts filename="./src/auth.ts"
diff --git a/docs/pages/getting-started/adapters/mongodb.mdx b/docs/pages/getting-started/adapters/mongodb.mdx
index 0141708819..4bd9b4e975 100644
--- a/docs/pages/getting-started/adapters/mongodb.mdx
+++ b/docs/pages/getting-started/adapters/mongodb.mdx
@@ -38,6 +38,22 @@ export const { handlers, auth, signIn, signOut } = NextAuth({
 ```
 
 
+
+
+```ts filename="/src/routes/plugin@auth.ts"
+import { QwikAuth$ } from "@auth/qwik"
+import { MongoDBAdapter } from "@auth/mongodb-adapter"
+import clientPromise from "./lib/db"
+
+export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$(
+  () => ({
+    providers: [],
+    adapter: MongoDBAdapter(clientPromise),
+  })
+)
+```
+
+
 
 
 ```ts filename="./src/auth.ts"
diff --git a/docs/pages/getting-started/adapters/neo4j.mdx b/docs/pages/getting-started/adapters/neo4j.mdx
index 21d1b1aa81..2fd3ff7be2 100644
--- a/docs/pages/getting-started/adapters/neo4j.mdx
+++ b/docs/pages/getting-started/adapters/neo4j.mdx
@@ -48,6 +48,32 @@ export const { handlers, auth, signIn, signOut } = NextAuth({
 ```
 
 
+
+
+```ts filename="/src/routes/plugin@auth.ts"
+import { QwikAuth$ } from "@auth/qwik"
+import neo4j from "neo4j-driver"
+import { Neo4jAdapter } from "@auth/neo4j-adapter"
+
+const driver = neo4j.driver(
+  import.meta.env.NEO4J_URI,
+  neo4j.auth.basic(
+    import.meta.env.NEO4J_USERNAME,
+    import.meta.env.NEO4J_PASSWORD
+  )
+)
+
+const neo4jSession = driver.session()
+
+export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$(
+  () => ({
+    providers: [],
+    adapter: Neo4jAdapter(neo4jSession),
+  })
+)
+```
+
+
 
 
 ```ts filename="./src/auth.ts"
diff --git a/docs/pages/getting-started/adapters/pg.mdx b/docs/pages/getting-started/adapters/pg.mdx
index 021759e6de..6c69ec639b 100644
--- a/docs/pages/getting-started/adapters/pg.mdx
+++ b/docs/pages/getting-started/adapters/pg.mdx
@@ -72,6 +72,54 @@ export const { handlers, auth, signIn, signOut } = NextAuth(() => {
 ```
 
 
+
+
+```ts filename="/src/routes/plugin@auth.ts"
+import { QwikAuth$ } from "@auth/qwik"
+import PostgresAdapter from "@auth/pg-adapter"
+import { Pool } from "pg"
+
+const pool = new Pool({
+  host: import.meta.env.DATABASE_HOST,
+  user: import.meta.env.DATABASE_USER,
+  password: import.meta.env.DATABASE_PASSWORD,
+  database: import.meta.env.DATABASE_NAME,
+  max: 20,
+  idleTimeoutMillis: 30000,
+  connectionTimeoutMillis: 2000,
+})
+
+export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$(
+  () => ({
+    providers: [],
+    adapter: PostgresAdapter(pool),
+  })
+)
+```
+
+If you are using [Neon](https://neon.tech)'s PostgreSQL like [Vercel Postgres](https://vercel.com/docs/postgres), you can use `@neondatabase/serverless` to work with edge runtime.
+
+```ts filename="/src/routes/plugin@auth.ts"
+import { QwikAuth$ } from "@auth/qwik"
+import PostgresAdapter from "@auth/pg-adapter"
+import { Pool } from "@neondatabase/serverless"
+
+// *DO NOT* create a `Pool` here, outside the request handler.
+// Neon's Postgres cannot keep a pool alive between requests.
+
+export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$(
+  () => {
+    // Create a `Pool` inside the request handler.
+    const pool = new Pool({ connectionString: import.meta.env.DATABASE_URL })
+    return {
+      providers: [],
+      adapter: PostgresAdapter(pool),
+    }
+  }
+)
+```
+
+
 
 
 ```ts filename="./src/auth.ts"
diff --git a/docs/pages/getting-started/adapters/pouchdb.mdx b/docs/pages/getting-started/adapters/pouchdb.mdx
index 7652adc547..c42bda5abb 100644
--- a/docs/pages/getting-started/adapters/pouchdb.mdx
+++ b/docs/pages/getting-started/adapters/pouchdb.mdx
@@ -40,6 +40,28 @@ export const { handlers, auth, signIn, signOut } = NextAuth({
 ```
 
 
+
+
+```ts filename="/src/routes/plugin@auth.ts"
+import { QwikAuth$ } from "@auth/qwik"
+import { PouchDBAdapter } from "@auth/pouchdb-adapter"
+import PouchDB from "pouchdb"
+
+// Setup your PouchDB instance and database
+PouchDB.plugin(require("pouchdb-adapter-leveldb")) // Or any other adapter
+  .plugin(require("pouchdb-find")) // Don't forget the `pouchdb-find` plugin
+
+const pouchdb = new PouchDB("auth_db", { adapter: "leveldb" })
+
+export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$(
+  () => ({
+    providers: [],
+    adapter: PouchDBAdapter(pouchdb),
+  })
+)
+```
+
+
 
 
 ```ts filename="./auth.ts"
diff --git a/docs/pages/getting-started/adapters/prisma.mdx b/docs/pages/getting-started/adapters/prisma.mdx
index bb1de0d651..8722ca1ab4 100644
--- a/docs/pages/getting-started/adapters/prisma.mdx
+++ b/docs/pages/getting-started/adapters/prisma.mdx
@@ -50,6 +50,24 @@ export const { handlers, auth, signIn, signOut } = NextAuth({
 ```
 
 
+
+
+```ts filename="/src/routes/plugin@auth.ts"
+import { QwikAuth$ } from "@auth/qwik"
+import { PrismaAdapter } from "@auth/prisma-adapter"
+import { PrismaClient } from "@prisma/client"
+
+const prisma = new PrismaClient()
+
+export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$(
+  () => ({
+    providers: [],
+    adapter: PrismaAdapter(prisma),
+  })
+)
+```
+
+
 
 
 ```ts filename="./src/auth.ts"
diff --git a/docs/pages/getting-started/adapters/sequelize.mdx b/docs/pages/getting-started/adapters/sequelize.mdx
index de690a3731..650b799481 100644
--- a/docs/pages/getting-started/adapters/sequelize.mdx
+++ b/docs/pages/getting-started/adapters/sequelize.mdx
@@ -48,6 +48,24 @@ export const { handlers, auth, signIn, signOut } = NextAuth({
 ```
 
 
+
+
+```ts filename="/src/routes/plugin@auth.ts"
+import { QwikAuth$ } from "@auth/qwik"
+import SequelizeAdapter from "@auth/sequelize-adapter"
+import { Sequelize } from "sequelize"
+
+const sequelize = new Sequelize(import.meta.env.DATABASE_URL)
+
+export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$(
+  () => ({
+    providers: [],
+    adapter: SequelizeAdapter(sequelize),
+  })
+)
+```
+
+
 
 
 ```ts filename="./src/auth.ts"
diff --git a/docs/pages/getting-started/adapters/supabase.mdx b/docs/pages/getting-started/adapters/supabase.mdx
index 4f12447138..01a598c9c0 100644
--- a/docs/pages/getting-started/adapters/supabase.mdx
+++ b/docs/pages/getting-started/adapters/supabase.mdx
@@ -43,6 +43,24 @@ export const { handlers, auth, signIn, signOut } = NextAuth({
 ```
 
 
+
+
+```ts filename="/src/routes/plugin@auth.ts"
+import { QwikAuth$ } from "@auth/qwik"
+import { SupabaseAdapter } from "@auth/supabase-adapter"
+
+export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$(
+  () => ({
+    providers: [],
+    adapter: SupabaseAdapter({
+      url: import.meta.env.SUPABASE_URL,
+      secret: import.meta.env.SUPABASE_SERVICE_ROLE_KEY,
+    }),
+  })
+)
+```
+
+
 
 
 ```ts filename="./src/auth.ts"
diff --git a/docs/pages/getting-started/adapters/surrealdb.mdx b/docs/pages/getting-started/adapters/surrealdb.mdx
index 0a05b3f623..4411e84206 100644
--- a/docs/pages/getting-started/adapters/surrealdb.mdx
+++ b/docs/pages/getting-started/adapters/surrealdb.mdx
@@ -43,6 +43,22 @@ export const { handlers, auth, signIn, signOut } = NextAuth({
 ```
 
 
+
+
+```ts filename="/src/routes/plugin@auth.ts"
+import { QwikAuth$ } from "@auth/qwik"
+import { SurrealDBAdapter } from "@auth/surrealdb-adapter"
+import clientPromise from "./lib/surrealdb"
+
+export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$(
+  () => ({
+    providers: [],
+    adapter: SurrealDBAdapter(clientPromise),
+  })
+)
+```
+
+
 
 
 ```ts filename="./src/auth.ts"
diff --git a/docs/pages/getting-started/adapters/typeorm.mdx b/docs/pages/getting-started/adapters/typeorm.mdx
index 8d593d8fb8..4bb0f1b7b5 100644
--- a/docs/pages/getting-started/adapters/typeorm.mdx
+++ b/docs/pages/getting-started/adapters/typeorm.mdx
@@ -38,6 +38,21 @@ export const { handlers, auth, signIn, signOut } = NextAuth({
 ```
 
 
+
+
+```ts filename="/src/routes/plugin@auth.ts"
+import { QwikAuth$ } from "@auth/qwik"
+import { TypeORMAdapter } from "@auth/typeorm-adapter"
+
+export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$(
+  () => ({
+    providers: [],
+    adapter: TypeORMAdapter(import.meta.env.AUTH_TYPEORM_CONNECTION),
+  })
+)
+```
+
+
 
 
 ```ts filename="./src/auth.ts"
diff --git a/docs/pages/getting-started/adapters/unstorage.mdx b/docs/pages/getting-started/adapters/unstorage.mdx
index b9fea22563..552c450b91 100644
--- a/docs/pages/getting-started/adapters/unstorage.mdx
+++ b/docs/pages/getting-started/adapters/unstorage.mdx
@@ -35,6 +35,24 @@ export const { handlers, auth, signIn, signOut } = NextAuth({
 ```
 
 
+
+
+```ts filename="/src/routes/plugin@auth.ts"
+import { QwikAuth$ } from "@auth/qwik"
+import { UnstorageAdapter } from "@auth/unstorage-adapter"
+import { createStorage } from "unstorage"
+
+const storage = createStorage()
+
+export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$(
+  () => ({
+    providers: [],
+    adapter: UnstorageAdapter(storage),
+  })
+)
+```
+
+
 
 
 ```ts filename="./src/auth.ts"
diff --git a/docs/pages/getting-started/adapters/upstash-redis.mdx b/docs/pages/getting-started/adapters/upstash-redis.mdx
index 709ba4bc91..f745d85a95 100644
--- a/docs/pages/getting-started/adapters/upstash-redis.mdx
+++ b/docs/pages/getting-started/adapters/upstash-redis.mdx
@@ -50,6 +50,27 @@ export const { handlers, auth, signIn, signOut } = NextAuth({
 ```
 
 
+
+
+```ts filename="/src/routes/plugin@auth.ts"
+import { QwikAuth$ } from "@auth/qwik"
+import { UpstashRedisAdapter } from "@auth/upstash-redis-adapter"
+import { Redis } from "@upstash/redis"
+
+const redis = new Redis({
+  url: import.meta.env.UPSTASH_REDIS_URL!,
+  token: import.meta.env.UPSTASH_REDIS_TOKEN!,
+})
+
+export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$(
+  () => ({
+    providers: [],
+    adapter: UpstashRedisAdapter(redis),
+  })
+)
+```
+
+
 
 
 ```ts filename="./src/auth.ts"
diff --git a/docs/pages/getting-started/adapters/xata.mdx b/docs/pages/getting-started/adapters/xata.mdx
index f7f16080ff..9de4a5afd4 100644
--- a/docs/pages/getting-started/adapters/xata.mdx
+++ b/docs/pages/getting-started/adapters/xata.mdx
@@ -43,6 +43,24 @@ export const { handlers, auth, signIn, signOut } = NextAuth({
 ```
 
 
+
+
+```ts filename="/src/routes/plugin@auth.ts"
+import { QwikAuth$ } from "@auth/qwik"
+import { XataAdapter } from "@auth/xata-adapter"
+import { XataClient } from "../../../xata" // Or wherever you've chosen for the generated client
+
+const client = new XataClient()
+
+export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$(
+  () => ({
+    providers: [],
+    adapter: XataAdapter(client),
+  })
+)
+```
+
+
 
 
 ```ts filename="./src/auth.ts"
diff --git a/docs/pages/getting-started/authentication/credentials.mdx b/docs/pages/getting-started/authentication/credentials.mdx
index 7959fab7c8..574debf1fe 100644
--- a/docs/pages/getting-started/authentication/credentials.mdx
+++ b/docs/pages/getting-started/authentication/credentials.mdx
@@ -57,6 +57,32 @@ export const { handlers, signIn, signOut, auth } = NextAuth({
 ```
 
 
+
+  
+```ts filename="/src/routes/plugin@auth.ts"
+import { QwikAuth$ } from "@auth/qwik"
+import Credentials from "@auth/qwik/providers/credentials"
+
+export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$(
+  () => ({
+    providers: [
+      Credentials({
+        credentials: {
+          email: { label: "Email" },
+          password: { label: "Password", type: "password" },
+        },
+        async authorize(credentials) {
+          const response = await getUserFromDb(credentials)
+          if (!response.ok) return null
+          return (await response.json()) ?? null
+        },
+      }),
+    ],
+  })
+)
+```
+
+
 
 
 ```ts filename="./src/auth.ts" {2, 8}
@@ -191,6 +217,33 @@ export function SignIn() {
 ```
 
 
+
+
+```ts filename="/src/routes/index.tsx"
+import { component$ } from "@builder.io/qwik"
+import { Form } from "@builder.io/qwik-city"
+import { useSignIn } from "./plugin@auth"
+
+export default component$(() => {
+  const signInSig = useSignIn()
+
+  return (
+    
+ + + +
+ ) +}) +``` + +
```svelte filename="src/route/+page.svelte" /bind:value/ /signIn/ @@ -300,6 +353,47 @@ export const { handlers, auth } = NextAuth({ ``` + + +```ts filename="./lib/zod.ts" +import { object, string } from "zod" + +export const signInSchema = object({ + email: string({ required_error: "Email is required" }) + .min(1, "Email is required") + .email("Invalid email"), + password: string({ required_error: "Password is required" }) + .min(1, "Password is required") + .min(8, "Password must be more than 8 characters") + .max(32, "Password must be less than 32 characters"), +}) +``` + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Credentials from "@auth/qwik/providers/credentials" +import { signInSchema } from "./lib/zod" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [ + Credentials({ + credentials: { + email: { label: "Email" }, + password: { label: "Password", type: "password" }, + }, + async authorize(credentials) { + const { email, password } = await signInSchema.parseAsync(credentials) + + // your logic here + }, + }), + ], + }) +) +``` + + ```ts filename="./lib/zod.ts" diff --git a/docs/pages/getting-started/authentication/email.mdx b/docs/pages/getting-started/authentication/email.mdx index 24d4252390..75d253b014 100644 --- a/docs/pages/getting-started/authentication/email.mdx +++ b/docs/pages/getting-started/authentication/email.mdx @@ -108,6 +108,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Resend from "@auth/qwik/providers/resend" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Resend], + }) +) +``` + + ```ts filename="./src/auth.ts" @@ -152,6 +166,26 @@ export function SignIn() { ``` + + +```ts filename="./components/sign-in.tsx" +import { component$ } from "@builder.io/qwik" +import { useSignIn } from "./plugin@auth" + +export default component$(() => { + const signInSig = useSignIn() + + return ( + + ) +}) +``` + + ```html filename="src/routes/+page.svelte" @@ -228,6 +262,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Sendgrid from "@auth/qwik/providers/sendgrid" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Sendgrid], + }) +) +``` + + ```ts filename="./src/auth.ts" @@ -272,6 +320,26 @@ export function SignIn() { ``` + + +```ts filename="./components/sign-in.tsx" +import { component$ } from "@builder.io/qwik" +import { useSignIn } from "./plugin@auth" + +export default component$(() => { + const signInSig = useSignIn() + + return ( + + ) +}) +``` + + ```html filename="src/routes/+page.svelte" @@ -362,6 +430,25 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Nodemailer from "@auth/qwik/providers/nodemailer" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [ + Nodemailer({ + server: import.meta.env.EMAIL_SERVER, + from: import.meta.env.EMAIL_FROM, + }), + ], + }) +) +``` + + ```ts filename="./src/auth.ts" @@ -421,6 +508,32 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Nodemailer from "@auth/qwik/providers/nodemailer" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [ + Nodemailer({ + server: { + host: import.meta.env.EMAIL_SERVER_HOST, + port: import.meta.env.EMAIL_SERVER_PORT, + auth: { + user: import.meta.env.EMAIL_SERVER_USER, + pass: import.meta.env.EMAIL_SERVER_PASSWORD, + }, + }, + from: import.meta.env.EMAIL_FROM, + }), + ], + }) +) +``` + + ```ts filename="./src/auth.ts" @@ -479,6 +592,26 @@ export function SignIn() { ``` + + +```ts filename="./components/sign-in.tsx" +import { component$ } from "@builder.io/qwik" +import { useSignIn } from "./plugin@auth" + +export default component$(() => { + const signInSig = useSignIn() + + return ( + + ) +}) +``` + + ```ts filename="src/routes/+page.svelte" @@ -552,6 +685,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Postmark from "@auth/qwik/providers/postmark" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Postmark], + }) +) +``` + + ```ts filename="./src/auth.ts" @@ -596,6 +743,26 @@ export function SignIn() { ``` + + +```ts filename="./components/sign-in.tsx" +import { component$ } from "@builder.io/qwik" +import { useSignIn } from "./plugin@auth" + +export default component$(() => { + const signInSig = useSignIn() + + return ( + + ) +}) +``` + + ```html filename="src/routes/+page.svelte" diff --git a/docs/pages/getting-started/index.mdx b/docs/pages/getting-started/index.mdx index 866850cb9d..d84a11679e 100644 --- a/docs/pages/getting-started/index.mdx +++ b/docs/pages/getting-started/index.mdx @@ -48,6 +48,35 @@ Select your framework of choice to get started, or view the example application +
+ + Qwik Logo +
Qwik
+ + +
+ + + You can use the Qwik starter script: + + ```bash npm2yarn + npm run qwik add auth + ``` + + ```bash npm2yarn @@ -96,6 +105,31 @@ export { auth as middleware } from "@/auth" ``` + + +You can add Auth.js easily by using the following Qwik starter script: + +```bash npm2yarn +npm run qwik add auth +``` + +This command will add a new package: + +`@auth/qwik` + +and create a new file named `plugin@auth.ts` with an example configuration. + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [...], + }) +) +``` + + 1. Start by creating a new `auth.ts` file in your `src/` directory with the following content. diff --git a/docs/pages/getting-started/providers/42-school.mdx b/docs/pages/getting-started/providers/42-school.mdx index 27cd525d30..f0b587541a 100644 --- a/docs/pages/getting-started/providers/42-school.mdx +++ b/docs/pages/getting-started/providers/42-school.mdx @@ -21,6 +21,13 @@ https://example.com/api/auth/callback/42-school ``` + + +```bash +https://example.com/auth/callback/42-school +``` + + ```bash @@ -52,6 +59,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import 42School from "@auth/qwik/providers/42-school" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [42School], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/apple.mdx b/docs/pages/getting-started/providers/apple.mdx index 1c97aa5646..7d2a2d5377 100644 --- a/docs/pages/getting-started/providers/apple.mdx +++ b/docs/pages/getting-started/providers/apple.mdx @@ -22,6 +22,13 @@ https://example.com/api/auth/callback/apple ``` + + +```bash +https://example.com/auth/callback/apple +``` + + ```bash @@ -53,6 +60,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Apple from "@auth/qwik/providers/apple" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Apple], + }) +) +``` + + ```ts filename="./src/auth.ts" diff --git a/docs/pages/getting-started/providers/asgardeo.mdx b/docs/pages/getting-started/providers/asgardeo.mdx index 434c67e209..2fb17b0c3c 100644 --- a/docs/pages/getting-started/providers/asgardeo.mdx +++ b/docs/pages/getting-started/providers/asgardeo.mdx @@ -21,6 +21,13 @@ https://example.com/api/auth/callback/asgardeo ``` + + +```bash +https://example.com/auth/callback/asgardeo +``` + + ```bash @@ -65,6 +72,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Asgardeo from "@auth/qwik/providers/asgardeo" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Asgardeo], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/auth0.mdx b/docs/pages/getting-started/providers/auth0.mdx index 99fe68c3db..c6cea8cf48 100644 --- a/docs/pages/getting-started/providers/auth0.mdx +++ b/docs/pages/getting-started/providers/auth0.mdx @@ -20,6 +20,13 @@ https://example.com/api/auth/callback/auth0 ``` + + +```bash +https://example.com/auth/callback/auth0 +``` + + ```bash @@ -51,6 +58,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Auth0 from "@auth/qwik/providers/auth0" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Auth0], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/authentik.mdx b/docs/pages/getting-started/providers/authentik.mdx index fae6b572aa..4dfe90d9da 100644 --- a/docs/pages/getting-started/providers/authentik.mdx +++ b/docs/pages/getting-started/providers/authentik.mdx @@ -21,6 +21,13 @@ https://example.com/api/auth/callback/authentik ``` + + +```bash +https://example.com/auth/callback/authentik +``` + + ```bash @@ -57,6 +64,26 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Authentik from "@auth/qwik/providers/authentik"; + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [ + Authentik({ + clientId: import.meta.env.AUTH_AUTHENTIK_CLIENT_ID + clientSecret: import.meta.env.AUTH_AUTHENTIK_CLIENT_SECRET + issuer: import.meta.env.AUTH_AUTHENTIK_ISSUER + }) + ], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/azure-ad-b2c.mdx b/docs/pages/getting-started/providers/azure-ad-b2c.mdx index cf99477a7b..76758f50ff 100644 --- a/docs/pages/getting-started/providers/azure-ad-b2c.mdx +++ b/docs/pages/getting-started/providers/azure-ad-b2c.mdx @@ -42,6 +42,26 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import AzureADB2C from "@auth/qwik/providers/azure-ad-b2c"; + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [ + AzureADB2C({ + clientId: import.meta.env.AUTH_AZURE_AD_CLIENT_ID + clientSecret: import.meta.env.AUTH_AZURE_AD_CLIENT_SECRET + issuer: import.meta.env.AUTH_AZURE_AD_ISSUER + }) + ], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/azure-ad.mdx b/docs/pages/getting-started/providers/azure-ad.mdx index c583512f91..d17998efe7 100644 --- a/docs/pages/getting-started/providers/azure-ad.mdx +++ b/docs/pages/getting-started/providers/azure-ad.mdx @@ -29,6 +29,13 @@ https://example.com/api/auth/callback/azure-ad ``` + + +```bash +https://example.com/auth/callback/azure-ad +``` + + ```bash @@ -61,6 +68,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import AzureAd from "@auth/qwik/providers/azure-ad" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [AzureAd], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/azure-devops.mdx b/docs/pages/getting-started/providers/azure-devops.mdx index cb62eba6c8..5e876bfd11 100644 --- a/docs/pages/getting-started/providers/azure-devops.mdx +++ b/docs/pages/getting-started/providers/azure-devops.mdx @@ -34,6 +34,13 @@ https://example.com/api/auth/callback/azure-devops ``` + + +```bash +https://example.com/auth/callback/azure-devops +``` + + ```bash @@ -102,6 +109,25 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import AzureDevOps from "@auth/qwik/providers/azure-devops" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [ + AzureDevOps({ + clientId: import.meta.env.AUTH_AZURE_DEVOPS_APP_ID, + clientSecret: import.meta.env.AUTH_AZURE_DEVOPS_CLIENT_SECRET, + }), + ], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/bankid-no.mdx b/docs/pages/getting-started/providers/bankid-no.mdx index ec684e3c10..7f0138b36a 100644 --- a/docs/pages/getting-started/providers/bankid-no.mdx +++ b/docs/pages/getting-started/providers/bankid-no.mdx @@ -28,6 +28,13 @@ https://example.com/api/auth/callback/bankid-no ``` + + +```bash +https://example.com/auth/callback/bankid-no +``` + + ```bash @@ -59,6 +66,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import BankIDNorway from "@auth/qwik/providers/bankid-no" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [BankIDNorway], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/battlenet.mdx b/docs/pages/getting-started/providers/battlenet.mdx index 0d739b2f0b..c7e7f18125 100644 --- a/docs/pages/getting-started/providers/battlenet.mdx +++ b/docs/pages/getting-started/providers/battlenet.mdx @@ -21,6 +21,13 @@ https://example.com/api/auth/callback/battlenet ``` + + +```bash +https://example.com/auth/callback/battlenet +``` + + ```bash @@ -68,6 +75,24 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import BattleNet from "@auth/qwik/providers/battlenet"; + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [BattleNet({ + clientId: import.meta.env.AUTH_BATTLENET_CLIENT_ID + clientSecret: import.meta.env.AUTH_BATTLENET_CLIENT_SECRET + issuer: import.meta.env.AUTH_BATTLENET_ISSUER + })] + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/beyondidentity.mdx b/docs/pages/getting-started/providers/beyondidentity.mdx index fa2b6af608..46fc1711eb 100644 --- a/docs/pages/getting-started/providers/beyondidentity.mdx +++ b/docs/pages/getting-started/providers/beyondidentity.mdx @@ -26,6 +26,13 @@ https://example.com/api/auth/callback/beyondidentity ``` + + +```bash +https://example.com/auth/callback/beyondidentity +``` + + ```bash @@ -58,6 +65,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import BeyondIdentity from "@auth/qwik/providers/beyondidentity" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [BeyondIdentity], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/box.mdx b/docs/pages/getting-started/providers/box.mdx index 8df2ac8587..000a17a7db 100644 --- a/docs/pages/getting-started/providers/box.mdx +++ b/docs/pages/getting-started/providers/box.mdx @@ -22,6 +22,13 @@ https://example.com/api/auth/callback/box ``` + + +```bash +https://example.com/auth/callback/box +``` + + ```bash @@ -53,6 +60,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Box from "@auth/qwik/providers/box" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Box], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/boxyhq-saml.mdx b/docs/pages/getting-started/providers/boxyhq-saml.mdx index 200bc953cc..5c3f41161a 100644 --- a/docs/pages/getting-started/providers/boxyhq-saml.mdx +++ b/docs/pages/getting-started/providers/boxyhq-saml.mdx @@ -32,6 +32,13 @@ https://example.com/api/auth/callback/boxyhq-saml ``` + + +```bash +https://example.com/auth/callback/boxhq-saml +``` + + ```bash @@ -71,6 +78,27 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import BoxyHQ from "@auth/qwik/providers/boxyhq-saml" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [ + BoxyHQ({ + authorization: { params: { scope: "" } }, // This is needed for OAuth 2.0 flow, otherwise default to openid + clientId: import.meta.env.AUTH_BOXYHQ_SAML_ID, + clientSecret: import.meta.env.AUTH_BOXYHQ_SAML_SECRET, + issuer: import.meta.env.AUTH_BOXYHQ_SAML_ISSUER, + }), + ], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/bungie.mdx b/docs/pages/getting-started/providers/bungie.mdx index 4dbef11b86..ee9e085960 100644 --- a/docs/pages/getting-started/providers/bungie.mdx +++ b/docs/pages/getting-started/providers/bungie.mdx @@ -21,6 +21,13 @@ https://example.com/api/auth/callback/bungie ``` + + +```bash +https://example.com/auth/callback/bungie +``` + + ```bash @@ -72,6 +79,26 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Bungie from "@auth/qwik/providers/boxyhq-saml"; + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [ + Bungie({ + clientId: import.meta.env.AUTH_BUNGIE_ID + clientSecret: import.meta.env.AUTH_BUNGIE_SECRET + headers: { "X-API-Key": import.meta.env.AUTH_BUNGIE_API_KEY } + }), + ], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/click-up.mdx b/docs/pages/getting-started/providers/click-up.mdx index 438f577b78..a3504cb2e0 100644 --- a/docs/pages/getting-started/providers/click-up.mdx +++ b/docs/pages/getting-started/providers/click-up.mdx @@ -21,6 +21,13 @@ https://example.com/api/auth/callback/clickup ``` + + +```bash +https://example.com/auth/callback/clickup +``` + + ```bash @@ -52,6 +59,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import ClickUp from "@auth/qwik/providers/click-up" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [ClickUp], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/cognito.mdx b/docs/pages/getting-started/providers/cognito.mdx index 282c87b60e..6d182fde3b 100644 --- a/docs/pages/getting-started/providers/cognito.mdx +++ b/docs/pages/getting-started/providers/cognito.mdx @@ -23,6 +23,13 @@ https://example.com/api/auth/callback/cognito ``` + + +```bash +https://example.com/auth/callback/cognito +``` + + ```bash @@ -55,6 +62,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Cognito from "@auth/qwik/providers/cognito" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Cognito], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/coinbase.mdx b/docs/pages/getting-started/providers/coinbase.mdx index 563c2362dc..3b08e469d2 100644 --- a/docs/pages/getting-started/providers/coinbase.mdx +++ b/docs/pages/getting-started/providers/coinbase.mdx @@ -21,6 +21,13 @@ https://example.com/api/auth/callback/coinbase ``` + + +```bash +https://example.com/auth/callback/coinbase +``` + + ```bash @@ -52,6 +59,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Coinbase from "@auth/qwik/providers/coinbase" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Coinbase], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/credentials.mdx b/docs/pages/getting-started/providers/credentials.mdx index bf9240e237..f666534a3e 100644 --- a/docs/pages/getting-started/providers/credentials.mdx +++ b/docs/pages/getting-started/providers/credentials.mdx @@ -38,6 +38,32 @@ export const { signIn, signOut, auth } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Credentials from "@auth/qwik/providers/credentials" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [ + Credentials({ + credentials: { + username: { label: "Username" }, + password: { label: "Password", type: "password" }, + }, + async authorize({ request }) { + const response = await fetch(request) + if (!response.ok) return null + return (await response.json()) ?? null + }, + }), + ], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/descope.mdx b/docs/pages/getting-started/providers/descope.mdx index 5c45dc3343..3d9ea92fff 100644 --- a/docs/pages/getting-started/providers/descope.mdx +++ b/docs/pages/getting-started/providers/descope.mdx @@ -22,6 +22,13 @@ https://example.com/api/auth/callback/descope ``` + + +```bash +https://example.com/auth/callback/descope +``` + + ```bash @@ -61,6 +68,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Descope from "@auth/qwik/providers/descope" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Descope], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/discord.mdx b/docs/pages/getting-started/providers/discord.mdx index a1ca6606b8..01a81b872e 100644 --- a/docs/pages/getting-started/providers/discord.mdx +++ b/docs/pages/getting-started/providers/discord.mdx @@ -22,6 +22,13 @@ https://example.com/api/auth/callback/discord ``` + + +```bash +https://example.com/auth/callback/discord +``` + + ```bash @@ -53,6 +60,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Discord from "@auth/qwik/providers/discord" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Discord], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/dribbble.mdx b/docs/pages/getting-started/providers/dribbble.mdx index a20a613b16..c7db9febc1 100644 --- a/docs/pages/getting-started/providers/dribbble.mdx +++ b/docs/pages/getting-started/providers/dribbble.mdx @@ -23,6 +23,13 @@ https://example.com/api/auth/callback/dribbble ``` + + +```bash +https://example.com/auth/callback/dribbble +``` + + ```bash @@ -54,6 +61,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Dribbble from "@auth/qwik/providers/dribbble" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Dribbble], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/dropbox.mdx b/docs/pages/getting-started/providers/dropbox.mdx index ca837b6992..23987c46ec 100644 --- a/docs/pages/getting-started/providers/dropbox.mdx +++ b/docs/pages/getting-started/providers/dropbox.mdx @@ -21,6 +21,13 @@ https://example.com/api/auth/callback/dropbox ``` + + +```bash +https://example.com/auth/callback/dropbox +``` + + ```bash @@ -52,6 +59,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Dropbox from "@auth/qwik/providers/dropbox" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Dropbox], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/duende-identity-server6.mdx b/docs/pages/getting-started/providers/duende-identity-server6.mdx index 4066544d0c..2255554f9c 100644 --- a/docs/pages/getting-started/providers/duende-identity-server6.mdx +++ b/docs/pages/getting-started/providers/duende-identity-server6.mdx @@ -26,6 +26,13 @@ https://example.com/api/auth/callback/duende-identity-service ``` + + +```bash +https://example.com/auth/callback/duende-identity-service +``` + + ```bash @@ -58,6 +65,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import DuendeIdentityServer6 from "@auth/qwik/providers/duende-identity-server6" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [DuendeIdentityServer6], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/eveonline.mdx b/docs/pages/getting-started/providers/eveonline.mdx index 73c2e30abe..50f854555e 100644 --- a/docs/pages/getting-started/providers/eveonline.mdx +++ b/docs/pages/getting-started/providers/eveonline.mdx @@ -21,6 +21,13 @@ https://example.com/api/auth/callback/eveonline ``` + + +```bash +https://example.com/auth/callback/eveonline +``` + + ```bash @@ -52,6 +59,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import EveOnline from "@auth/qwik/providers/eve-online" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [EveOnline], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/facebook.mdx b/docs/pages/getting-started/providers/facebook.mdx index 01b40ec8a8..17f4737e94 100644 --- a/docs/pages/getting-started/providers/facebook.mdx +++ b/docs/pages/getting-started/providers/facebook.mdx @@ -22,6 +22,13 @@ https://example.com/api/auth/callback/facebook ``` + + +```bash +https://example.com/auth/callback/facebook +``` + + ```bash @@ -53,6 +60,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Facebook from "@auth/qwik/providers/facebook" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Facebook], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/faceit.mdx b/docs/pages/getting-started/providers/faceit.mdx index 19ba63d965..d1970fc399 100644 --- a/docs/pages/getting-started/providers/faceit.mdx +++ b/docs/pages/getting-started/providers/faceit.mdx @@ -21,6 +21,13 @@ https://example.com/api/auth/callback/faceit ``` + + +```bash +https://example.com/auth/callback/faceit +``` + + ```bash @@ -52,6 +59,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import FaceIt from "@auth/qwik/providers/faceit" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [FaceIt], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/foursquare.mdx b/docs/pages/getting-started/providers/foursquare.mdx index f6062a27ae..0cdc0a7088 100644 --- a/docs/pages/getting-started/providers/foursquare.mdx +++ b/docs/pages/getting-started/providers/foursquare.mdx @@ -21,6 +21,13 @@ https://example.com/api/auth/callback/foursquare ``` + + +```bash +https://example.com/auth/callback/foursquare +``` + + ```bash @@ -52,6 +59,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import FourSquare from "@auth/qwik/providers/foursquare" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [FourSquare], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/freshbooks.mdx b/docs/pages/getting-started/providers/freshbooks.mdx index 7002592806..fb74e305ec 100644 --- a/docs/pages/getting-started/providers/freshbooks.mdx +++ b/docs/pages/getting-started/providers/freshbooks.mdx @@ -21,6 +21,13 @@ https://example.com/api/auth/callback/freshbooks ``` + + +```bash +https://example.com/auth/callback/freshbooks +``` + + ```bash @@ -52,6 +59,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import FreshBooks from "@auth/qwik/providers/freshbooks" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [FreshBooks], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/fusionauth.mdx b/docs/pages/getting-started/providers/fusionauth.mdx index d95c172335..94f2ebd769 100644 --- a/docs/pages/getting-started/providers/fusionauth.mdx +++ b/docs/pages/getting-started/providers/fusionauth.mdx @@ -22,6 +22,13 @@ https://example.com/api/auth/callback/fusionauth ``` + + +```bash +https://example.com/auth/callback/fusionauth +``` + + ```bash @@ -62,6 +69,27 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import FusionAuth from "@auth/qwik/providers/fusionauth" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [ + FusionAuth({ + clientId: import.meta.env.AUTH_FUSIONAUTH_ID, + clientSecret: import.meta.env.AUTH_FUSIONAUTH_SECRET, + tenantId: import.meta.env.AUTH_FUSIONAUTH_TENANT_ID, + issuer: import.meta.env.AUTH_FUSIONAUTH_ISSUER, + }), + ], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/github.mdx b/docs/pages/getting-started/providers/github.mdx index c10dd25ebc..c971c13211 100644 --- a/docs/pages/getting-started/providers/github.mdx +++ b/docs/pages/getting-started/providers/github.mdx @@ -25,6 +25,13 @@ https://example.com/api/auth/callback/github ``` + + +```bash +https://example.com/auth/callback/github +``` + + ```bash @@ -56,6 +63,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import GitHub from "@auth/qwik/providers/github" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [GitHub], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/gitlab.mdx b/docs/pages/getting-started/providers/gitlab.mdx index 97683cbc80..85a6f7207a 100644 --- a/docs/pages/getting-started/providers/gitlab.mdx +++ b/docs/pages/getting-started/providers/gitlab.mdx @@ -21,6 +21,13 @@ https://example.com/api/auth/callback/gitlab ``` + + +```bash +https://example.com/auth/callback/gitlab +``` + + ```bash @@ -52,6 +59,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import GitLab from "@auth/qwik/providers/gitlab" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [GitLab], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/google.mdx b/docs/pages/getting-started/providers/google.mdx index 9e8e86938e..c74dbe6d73 100644 --- a/docs/pages/getting-started/providers/google.mdx +++ b/docs/pages/getting-started/providers/google.mdx @@ -22,6 +22,13 @@ https://example.com/api/auth/callback/google ``` + + +```bash +https://example.com/auth/callback/google +``` + + ```bash @@ -53,6 +60,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Google from "@auth/qwik/providers/google" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Google], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/hubspot.mdx b/docs/pages/getting-started/providers/hubspot.mdx index e9cf9b971d..52edf4460d 100644 --- a/docs/pages/getting-started/providers/hubspot.mdx +++ b/docs/pages/getting-started/providers/hubspot.mdx @@ -21,6 +21,13 @@ https://example.com/api/auth/callback/hubspot ``` + + +```bash +https://example.com/auth/callback/hubspot +``` + + ```bash @@ -52,6 +59,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Hubspot from "@auth/qwik/providers/hubspot" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Hubspot], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/identity-server4.mdx b/docs/pages/getting-started/providers/identity-server4.mdx index 39c6c6769f..fc5afb3545 100644 --- a/docs/pages/getting-started/providers/identity-server4.mdx +++ b/docs/pages/getting-started/providers/identity-server4.mdx @@ -31,6 +31,13 @@ https://example.com/api/auth/callback/identity-server4 ``` + + +```bash +https://example.com/auth/callback/identity-server4 +``` + + ```bash @@ -63,6 +70,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import IdentityServer4 from "@auth/qwik/providers/identity-server4" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [IdentityServer4], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/instagram.mdx b/docs/pages/getting-started/providers/instagram.mdx index c917a4f35c..493756f130 100644 --- a/docs/pages/getting-started/providers/instagram.mdx +++ b/docs/pages/getting-started/providers/instagram.mdx @@ -22,6 +22,13 @@ https://example.com/api/auth/callback/instagram ``` + + +```bash +https://example.com/auth/callback/instagram +``` + + ```bash @@ -53,6 +60,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Instagram from "@auth/qwik/providers/instagram" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Instagram], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/kakao.mdx b/docs/pages/getting-started/providers/kakao.mdx index aaa178f456..563560bcc4 100644 --- a/docs/pages/getting-started/providers/kakao.mdx +++ b/docs/pages/getting-started/providers/kakao.mdx @@ -22,6 +22,13 @@ https://example.com/api/auth/callback/kakao ``` + + +```bash +https://example.com/auth/callback/kakao +``` + + ```bash @@ -55,6 +62,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Kakao from "@auth/qwik/providers/kakao" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Kakao], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/keycloak.mdx b/docs/pages/getting-started/providers/keycloak.mdx index 2d1d4e28b5..deaf62fba4 100644 --- a/docs/pages/getting-started/providers/keycloak.mdx +++ b/docs/pages/getting-started/providers/keycloak.mdx @@ -21,6 +21,13 @@ https://example.com/api/auth/callback/keycloak ``` + + +```bash +https://example.com/auth/callback/keycloak +``` + + ```bash @@ -53,6 +60,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Keycloak from "@auth/qwik/providers/keycloak" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Keycloak], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/line.mdx b/docs/pages/getting-started/providers/line.mdx index 57d31304b5..32c22d7150 100644 --- a/docs/pages/getting-started/providers/line.mdx +++ b/docs/pages/getting-started/providers/line.mdx @@ -22,6 +22,13 @@ https://example.com/api/auth/callback/line ``` + + +```bash +https://example.com/auth/callback/line +``` + + ```bash @@ -53,6 +60,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Line from "@auth/qwik/providers/line" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Line], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/linkedin.mdx b/docs/pages/getting-started/providers/linkedin.mdx index fbe5329a09..c8cba0ea11 100644 --- a/docs/pages/getting-started/providers/linkedin.mdx +++ b/docs/pages/getting-started/providers/linkedin.mdx @@ -22,6 +22,13 @@ https://example.com/api/auth/callback/linkedin ``` + + +```bash +https://example.com/auth/callback/linkedin +``` + + ```bash @@ -53,6 +60,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import LinkedIn from "@auth/qwik/providers/linkedin" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [LinkedIn], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/mailchimp.mdx b/docs/pages/getting-started/providers/mailchimp.mdx index 9a214e4599..dd6f74e877 100644 --- a/docs/pages/getting-started/providers/mailchimp.mdx +++ b/docs/pages/getting-started/providers/mailchimp.mdx @@ -22,6 +22,13 @@ https://example.com/api/auth/callback/mailchimp ``` + + +```bash +https://example.com/auth/callback/mailchimp +``` + + ```bash @@ -53,6 +60,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import MailChimp from "@auth/qwik/providers/mailchimp" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [MailChimp], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/mailru.mdx b/docs/pages/getting-started/providers/mailru.mdx index b4f33ea3fd..b1d0b0e7b4 100644 --- a/docs/pages/getting-started/providers/mailru.mdx +++ b/docs/pages/getting-started/providers/mailru.mdx @@ -22,6 +22,13 @@ https://example.com/api/auth/callback/mailru ``` + + +```bash +https://example.com/auth/callback/mailru +``` + + ```bash @@ -53,6 +60,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import MailRu from "@auth/qwik/providers/mailru" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [MailRu], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/mastodon.mdx b/docs/pages/getting-started/providers/mastodon.mdx index bc44ac2453..5a10bd928a 100644 --- a/docs/pages/getting-started/providers/mastodon.mdx +++ b/docs/pages/getting-started/providers/mastodon.mdx @@ -22,6 +22,13 @@ https://example.com/api/auth/callback/mastodon ``` + + +```bash +https://example.com/auth/callback/mastodon +``` + + ```bash @@ -54,6 +61,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Mastodon from "@auth/qwik/providers/mastodon" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Mastodon], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/mattermost.mdx b/docs/pages/getting-started/providers/mattermost.mdx index 6b6dd1c01c..9037f9b97c 100644 --- a/docs/pages/getting-started/providers/mattermost.mdx +++ b/docs/pages/getting-started/providers/mattermost.mdx @@ -21,6 +21,13 @@ https://example.com/api/auth/callback/mattermost ``` + + +```bash +https://example.com/auth/callback/mattermost +``` + + ```bash @@ -53,6 +60,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Mattermost from "@auth/qwik/providers/mattermost" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Mattermost], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/medium.mdx b/docs/pages/getting-started/providers/medium.mdx index 27b0c8b995..bfea57322b 100644 --- a/docs/pages/getting-started/providers/medium.mdx +++ b/docs/pages/getting-started/providers/medium.mdx @@ -21,6 +21,13 @@ https://example.com/api/auth/callback/medium ``` + + +```bash +https://example.com/auth/callback/medium +``` + + ```bash @@ -52,6 +59,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Medium from "@auth/qwik/providers/medium" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Medium], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/microsoft-entra-id.mdx b/docs/pages/getting-started/providers/microsoft-entra-id.mdx index 2fa1df3285..36e27d9f37 100644 --- a/docs/pages/getting-started/providers/microsoft-entra-id.mdx +++ b/docs/pages/getting-started/providers/microsoft-entra-id.mdx @@ -33,6 +33,13 @@ https://example.com/api/auth/callback/microsoft-entra-id ``` + + +```bash +https://example.com/auth/callback/microsoft-entra-id +``` + + ```bash @@ -71,6 +78,26 @@ const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Entra from "@auth/qwik/providers/microsoft-entra-id" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [ + Entra({ + clientId: import.meta.env.AUTH_MICROSOFT_ENTRA_ID_ID, + clientSecret: import.meta.env.AUTH_MICROSOFT_ENTRA_ID_SECRET, + tenantId: import.meta.env.AUTH_MICROSOFT_ENTRA_ID_TENANT_ID, + }), + ], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/naver.mdx b/docs/pages/getting-started/providers/naver.mdx index 6cd375a38b..8a497d548b 100644 --- a/docs/pages/getting-started/providers/naver.mdx +++ b/docs/pages/getting-started/providers/naver.mdx @@ -22,6 +22,13 @@ https://example.com/api/auth/callback/naver ``` + + +```bash +https://example.com/auth/callback/naver +``` + + ```bash @@ -53,6 +60,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Naver from "@auth/qwik/providers/naver" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Naver], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/netlify.mdx b/docs/pages/getting-started/providers/netlify.mdx index 01e0b44ddc..56547a6717 100644 --- a/docs/pages/getting-started/providers/netlify.mdx +++ b/docs/pages/getting-started/providers/netlify.mdx @@ -22,6 +22,13 @@ https://example.com/api/auth/callback/netlify ``` + + +```bash +https://example.com/auth/callback/netlify +``` + + ```bash @@ -53,6 +60,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Netlify from "@auth/qwik/providers/netlify" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Netlify], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/netsuite.mdx b/docs/pages/getting-started/providers/netsuite.mdx index a15d0d368e..6fb1c86dd6 100644 --- a/docs/pages/getting-started/providers/netsuite.mdx +++ b/docs/pages/getting-started/providers/netsuite.mdx @@ -26,6 +26,13 @@ https://example.com/api/auth/callback/netsuite ``` + + +```bash +https://example.com/auth/callback/netsuite +``` + + ```bash @@ -160,6 +167,33 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import NetSuite from "@auth/qwik/providers/netsuite" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [ + NetSuite({ + clientId: import.meta.env.AUTH_NETSUITE_ID, + clientSecret: import.meta.env.AUTH_NETSUITE_SECRET, + issuer: import.meta.env.AUTH_NETSUITE_ACCOUNT_ID, // EX: TSTDRV1234567 or 81555 for prod, and 1234567-SB1 for Sandbox accounts not "_" use "-". + // Returns the current user using the N/runtime module. This url can be a suitelet or RESTlet (Recommended) + // Using getCurrentUser(); So we match this schema returned from this RESTlet in the profile callback. (Required) + userinfo: + "https://1234567.restlets.api.netsuite.com/app/site/hosting/restlet.nl?script=123&deploy=1", + // Optional + prompt: "login", // Required if you want to force the user to login every time. + scope: "restlets", // Optional defaults to "restlets rest_webservices". Enter the scope(s) you want to use followed by spaces. + }), + ], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/nodemailer.mdx b/docs/pages/getting-started/providers/nodemailer.mdx index 755f850996..7357453126 100644 --- a/docs/pages/getting-started/providers/nodemailer.mdx +++ b/docs/pages/getting-started/providers/nodemailer.mdx @@ -66,6 +66,25 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Nodemailer from "@auth/qwik/providers/nodemailer" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [ + Nodemailer({ + server: import.meta.env.EMAIL_SERVER, + from: import.meta.env.EMAIL_FROM, + }), + ], + }) +) +``` + + ```ts filename="./src/auth.ts" diff --git a/docs/pages/getting-started/providers/notion.mdx b/docs/pages/getting-started/providers/notion.mdx index 10f56db400..32aca0008a 100644 --- a/docs/pages/getting-started/providers/notion.mdx +++ b/docs/pages/getting-started/providers/notion.mdx @@ -23,6 +23,13 @@ https://example.com/api/auth/callback/notion ``` + + +```bash +https://example.com/auth/callback/notion +``` + + ```bash @@ -61,6 +68,26 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Notion from "@auth/qwik/providers/notion" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [ + Notion({ + clientId: import.meta.env.AUTH_NOTION_ID, + clientSecret: import.meta.env.AUTH_NOTION_SECRET, + redirectUri: import.meta.env.AUTH_NOTION_REDIRECT_URI, + }), + ], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/okta.mdx b/docs/pages/getting-started/providers/okta.mdx index 310b791d99..524cea3fe5 100644 --- a/docs/pages/getting-started/providers/okta.mdx +++ b/docs/pages/getting-started/providers/okta.mdx @@ -21,6 +21,13 @@ https://example.com/api/auth/callback/okta ``` + + +```bash +https://example.com/auth/callback/okta +``` + + ```bash @@ -53,6 +60,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Okta from "@auth/qwik/providers/okta" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Okta], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/onelogin.mdx b/docs/pages/getting-started/providers/onelogin.mdx index dea67e381a..e3b9f7e380 100644 --- a/docs/pages/getting-started/providers/onelogin.mdx +++ b/docs/pages/getting-started/providers/onelogin.mdx @@ -21,6 +21,13 @@ https://example.com/api/auth/callback/onelogin ``` + + +```bash +https://example.com/auth/callback/onelogin +``` + + ```bash @@ -52,6 +59,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import OneLogin from "@auth/qwik/providers/onelogin" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [OneLogin], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/osso.mdx b/docs/pages/getting-started/providers/osso.mdx index dd0f61c24c..c4405c6b63 100644 --- a/docs/pages/getting-started/providers/osso.mdx +++ b/docs/pages/getting-started/providers/osso.mdx @@ -21,6 +21,13 @@ https://example.com/api/auth/callback/osso ``` + + +```bash +https://example.com/auth/callback/osso +``` + + ```bash @@ -53,6 +60,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Osso from "@auth/qwik/providers/osso" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Osso], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/osu.mdx b/docs/pages/getting-started/providers/osu.mdx index a5f04a46bf..f098cb766c 100644 --- a/docs/pages/getting-started/providers/osu.mdx +++ b/docs/pages/getting-started/providers/osu.mdx @@ -22,6 +22,13 @@ https://example.com/api/auth/callback/osu ``` + + +```bash +https://example.com/auth/callback/osu +``` + + ```bash @@ -53,6 +60,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Osu from "@auth/qwik/providers/osu" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Osu], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/passage.mdx b/docs/pages/getting-started/providers/passage.mdx index 8146707346..d103fe1496 100644 --- a/docs/pages/getting-started/providers/passage.mdx +++ b/docs/pages/getting-started/providers/passage.mdx @@ -21,6 +21,13 @@ https://example.com/api/auth/callback/passage ``` + + +```bash +https://example.com/auth/callback/passage +``` + + ```bash @@ -53,6 +60,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Passage from "@auth/qwik/providers/passage" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Passage], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/patreon.mdx b/docs/pages/getting-started/providers/patreon.mdx index 78ad64ef54..2cc59e828d 100644 --- a/docs/pages/getting-started/providers/patreon.mdx +++ b/docs/pages/getting-started/providers/patreon.mdx @@ -23,6 +23,13 @@ https://example.com/api/auth/callback/patreon ``` + + +```bash +https://example.com/auth/callback/patreon +``` + + ```bash @@ -54,6 +61,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Patreon from "@auth/qwik/providers/patreon" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Patreon], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/pinterest.mdx b/docs/pages/getting-started/providers/pinterest.mdx index 7940ee3b0d..c97f28450b 100644 --- a/docs/pages/getting-started/providers/pinterest.mdx +++ b/docs/pages/getting-started/providers/pinterest.mdx @@ -22,6 +22,13 @@ https://example.com/api/auth/callback/pinterest ``` + + +```bash +https://example.com/auth/callback/pinterest +``` + + ```bash @@ -53,6 +60,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Pinterest from "@auth/qwik/providers/pinterest" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Pinterest], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/pipedrive.mdx b/docs/pages/getting-started/providers/pipedrive.mdx index 786a5fc9fd..961def805f 100644 --- a/docs/pages/getting-started/providers/pipedrive.mdx +++ b/docs/pages/getting-started/providers/pipedrive.mdx @@ -21,6 +21,13 @@ https://example.com/api/auth/callback/pipedrive ``` + + +```bash +https://example.com/auth/callback/pipedrive +``` + + ```bash @@ -52,6 +59,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import PipeDrive from "@auth/qwik/providers/pipedrive" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [PipeDrive], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/postmark.mdx b/docs/pages/getting-started/providers/postmark.mdx index 56ea53c437..ecb8f365f4 100644 --- a/docs/pages/getting-started/providers/postmark.mdx +++ b/docs/pages/getting-started/providers/postmark.mdx @@ -57,6 +57,26 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Postmark from "@auth/qwik/providers/postmark" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [ + Postmark({ + // If your environment variable is named differently than default + apiKey: import.meta.env.AUTH_POSTMARK_KEY, + from: "no-reply@company.com", + }), + ], + }) +) +``` + + ```ts filename="./src/auth.ts" diff --git a/docs/pages/getting-started/providers/reddit.mdx b/docs/pages/getting-started/providers/reddit.mdx index 43f4477c9b..0c357faa51 100644 --- a/docs/pages/getting-started/providers/reddit.mdx +++ b/docs/pages/getting-started/providers/reddit.mdx @@ -22,6 +22,13 @@ https://example.com/api/auth/callback/reddit ``` + + +```bash +https://example.com/auth/callback/reddit +``` + + ```bash @@ -53,6 +60,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Reddit from "@auth/qwik/providers/reddit" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Reddit], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/resend.mdx b/docs/pages/getting-started/providers/resend.mdx index cbdf855b6c..b21afd6b29 100644 --- a/docs/pages/getting-started/providers/resend.mdx +++ b/docs/pages/getting-started/providers/resend.mdx @@ -63,6 +63,26 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Resend from "@auth/qwik/providers/resend" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [ + Resend({ + // If your environment variable is named differently than default + apiKey: import.meta.env.AUTH_RESEND_KEY, + from: "no-reply@company.com", + }), + ], + }) +) +``` + + ```ts filename="./src/auth.ts" diff --git a/docs/pages/getting-started/providers/sailpoint.mdx b/docs/pages/getting-started/providers/sailpoint.mdx index 2c41317b9c..a509fdeaae 100644 --- a/docs/pages/getting-started/providers/sailpoint.mdx +++ b/docs/pages/getting-started/providers/sailpoint.mdx @@ -35,6 +35,13 @@ https://example.com/api/auth/callback/sailpoint ``` + + +```bash +https://example.com/auth/callback/sailpoint +``` + + ```bash @@ -108,6 +115,42 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [ + { + id: "sailpoint", + name: "SailPoint", + type: "oauth", + clientId: import.meta.env.AUTH_SAILPOINT_ID!, + clientSecret: import.meta.env.AUTH_SAILPOINT_SECRET!, + authorization: { + url: `${import.meta.env.AUTH_SAILPOINT_BASE_URL!}/oauth/authorize`, + params: { scope: "sp:scopes:all" }, + }, + token: `${import.meta.env.AUTH_SAILPOINT_BASE_API_URL!}/oauth/token`, + userinfo: `${import.meta.env.AUTH_SAILPOINT_BASE_API_URL!}/oauth/userinfo`, + profile(profile) { + return { + id: profile.id, + email: profile.email, + name: profile.uid, + image: null, + } + }, + style: { brandColor: "#011E69", logo: "sailpoint.svg" }, + }, + ], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/salesforce.mdx b/docs/pages/getting-started/providers/salesforce.mdx index 79acafeab7..d3408cc484 100644 --- a/docs/pages/getting-started/providers/salesforce.mdx +++ b/docs/pages/getting-started/providers/salesforce.mdx @@ -21,6 +21,13 @@ https://example.com/api/auth/callback/salesforce ``` + + +```bash +https://example.com/auth/callback/salesforce +``` + + ```bash @@ -52,6 +59,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Salesforce from "@auth/qwik/providers/salesforce" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Salesforce], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/sendgrid.mdx b/docs/pages/getting-started/providers/sendgrid.mdx index ac32d920ad..e1d4723b02 100644 --- a/docs/pages/getting-started/providers/sendgrid.mdx +++ b/docs/pages/getting-started/providers/sendgrid.mdx @@ -57,6 +57,26 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Sendgrid from "@auth/qwik/providers/sendgrid" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [ + Sendgrid({ + // If your environment variable is named differently than default + apiKey: import.meta.env.COMPANY_AUTH_SENDGRID_API_KEY, + from: "no-reply@company.com", + }), + ], + }) +) +``` + + ```ts filename="./src/auth.ts" diff --git a/docs/pages/getting-started/providers/simplelogin.mdx b/docs/pages/getting-started/providers/simplelogin.mdx index d48aead2ec..1ccf126995 100644 --- a/docs/pages/getting-started/providers/simplelogin.mdx +++ b/docs/pages/getting-started/providers/simplelogin.mdx @@ -28,6 +28,13 @@ https://example.com/api/auth/callback/simplelogin ``` + + +```bash +https://example.com/auth/callback/simplelogin +``` + + ```bash @@ -59,6 +66,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import SimpleLogin from "@auth/qwik/providers/simplelogin" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [SimpleLogin], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/slack.mdx b/docs/pages/getting-started/providers/slack.mdx index 73245fcee0..922781f880 100644 --- a/docs/pages/getting-started/providers/slack.mdx +++ b/docs/pages/getting-started/providers/slack.mdx @@ -23,6 +23,13 @@ https://example.com/api/auth/callback/slack ``` + + +```bash +https://example.com/auth/callback/slack +``` + + ```bash @@ -54,6 +61,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Slack from "@auth/qwik/providers/slack" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Slack], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/spotify.mdx b/docs/pages/getting-started/providers/spotify.mdx index 286ac953af..b191f7d5ab 100644 --- a/docs/pages/getting-started/providers/spotify.mdx +++ b/docs/pages/getting-started/providers/spotify.mdx @@ -22,6 +22,13 @@ https://example.com/api/auth/callback/spotify ``` + + +```bash +https://example.com/auth/callback/spotify +``` + + ```bash @@ -53,6 +60,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Spotify from "@auth/qwik/providers/spotify" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Spotify], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/strava.mdx b/docs/pages/getting-started/providers/strava.mdx index 850566897d..994b13859b 100644 --- a/docs/pages/getting-started/providers/strava.mdx +++ b/docs/pages/getting-started/providers/strava.mdx @@ -21,6 +21,13 @@ https://example.com/api/auth/callback/strava ``` + + +```bash +https://example.com/auth/callback/strava +``` + + ```bash @@ -52,6 +59,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Strava from "@auth/qwik/providers/strava" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Strava], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/threads.mdx b/docs/pages/getting-started/providers/threads.mdx index 1872ffc90e..2677ba823f 100644 --- a/docs/pages/getting-started/providers/threads.mdx +++ b/docs/pages/getting-started/providers/threads.mdx @@ -22,6 +22,13 @@ https://example.com/api/auth/callback/threads ``` + + +```bash +https://example.com/auth/callback/threads +``` + + ```bash @@ -53,6 +60,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Threads from "@auth/qwik/providers/threads" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Threads], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/tiktok.mdx b/docs/pages/getting-started/providers/tiktok.mdx index 37acd5b0f6..9ca2d085c3 100644 --- a/docs/pages/getting-started/providers/tiktok.mdx +++ b/docs/pages/getting-started/providers/tiktok.mdx @@ -23,6 +23,13 @@ https://example.com/api/auth/callback/tiktok ``` + + +```bash +https://example.com/auth/callback/tiktok +``` + + ```bash @@ -54,6 +61,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import TikTok from "@auth/qwik/providers/tiktok" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [TikTok], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/todoist.mdx b/docs/pages/getting-started/providers/todoist.mdx index de41636d92..acb3717388 100644 --- a/docs/pages/getting-started/providers/todoist.mdx +++ b/docs/pages/getting-started/providers/todoist.mdx @@ -22,6 +22,13 @@ https://example.com/api/auth/callback/todoist ``` + + +```bash +https://example.com/auth/callback/todoist +``` + + ```bash @@ -53,6 +60,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Todoist from "@auth/qwik/providers/todoist" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Todoist], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/trakt.mdx b/docs/pages/getting-started/providers/trakt.mdx index fdf1dac3f7..0d5bd80751 100644 --- a/docs/pages/getting-started/providers/trakt.mdx +++ b/docs/pages/getting-started/providers/trakt.mdx @@ -21,6 +21,13 @@ https://example.com/api/auth/callback/trakt ``` + + +```bash +https://example.com/auth/callback/trakt +``` + + ```bash @@ -52,6 +59,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Trakt from "@auth/qwik/providers/trakt" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Trakt], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/twitch.mdx b/docs/pages/getting-started/providers/twitch.mdx index 4fa808a874..9b41069a4d 100644 --- a/docs/pages/getting-started/providers/twitch.mdx +++ b/docs/pages/getting-started/providers/twitch.mdx @@ -21,6 +21,13 @@ https://example.com/api/auth/callback/twitch ``` + + +```bash +https://example.com/auth/callback/twitch +``` + + ```bash @@ -52,6 +59,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Twitch from "@auth/qwik/providers/twitch" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Twitch], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/twitter.mdx b/docs/pages/getting-started/providers/twitter.mdx index f603c57f5f..79c1769bc5 100644 --- a/docs/pages/getting-started/providers/twitter.mdx +++ b/docs/pages/getting-started/providers/twitter.mdx @@ -21,6 +21,13 @@ https://example.com/api/auth/callback/twitter ``` + + +```bash +https://example.com/auth/callback/twitter +``` + + ```bash @@ -52,6 +59,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Twitter from "@auth/qwik/providers/twitter" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Twitter], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/united-effects.mdx b/docs/pages/getting-started/providers/united-effects.mdx index bf4a5cd51e..d579837063 100644 --- a/docs/pages/getting-started/providers/united-effects.mdx +++ b/docs/pages/getting-started/providers/united-effects.mdx @@ -26,6 +26,13 @@ https://example.com/api/auth/callback/united-effects ``` + + +```bash +https://example.com/auth/callback/united-effects +``` + + ```bash @@ -57,6 +64,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import UnitedEffects from "@auth/qwik/providers/united-effects" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [UnitedEffects], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/vk.mdx b/docs/pages/getting-started/providers/vk.mdx index d40b814775..59e8223b14 100644 --- a/docs/pages/getting-started/providers/vk.mdx +++ b/docs/pages/getting-started/providers/vk.mdx @@ -22,6 +22,13 @@ https://example.com/api/auth/callback/vk ``` + + +```bash +https://example.com/auth/callback/vk +``` + + ```bash @@ -53,6 +60,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Vk from "@auth/qwik/providers/vk" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Vk], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/webex.mdx b/docs/pages/getting-started/providers/webex.mdx index f67ad2bc7a..bec9a630fb 100644 --- a/docs/pages/getting-started/providers/webex.mdx +++ b/docs/pages/getting-started/providers/webex.mdx @@ -22,6 +22,13 @@ https://example.com/api/auth/callback/webex ``` + + +```bash +https://example.com/auth/callback/webex +``` + + ```bash @@ -53,6 +60,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Webex from "@auth/qwik/providers/webex" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Webex], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/wikimedia.mdx b/docs/pages/getting-started/providers/wikimedia.mdx index 18f1d88429..b179a86085 100644 --- a/docs/pages/getting-started/providers/wikimedia.mdx +++ b/docs/pages/getting-started/providers/wikimedia.mdx @@ -21,6 +21,13 @@ https://example.com/api/auth/callback/wikimedia ``` + + +```bash +https://example.com/auth/callback/wikimedia +``` + + ```bash @@ -52,6 +59,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Wikimedia from "@auth/qwik/providers/wikimedia" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Wikimedia], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/wordpress.mdx b/docs/pages/getting-started/providers/wordpress.mdx index 3ecf9646e5..31f51ab9ba 100644 --- a/docs/pages/getting-started/providers/wordpress.mdx +++ b/docs/pages/getting-started/providers/wordpress.mdx @@ -21,6 +21,13 @@ https://example.com/api/auth/callback/wordpress ``` + + +```bash +https://example.com/auth/callback/wordpress +``` + + ```bash @@ -52,6 +59,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import WordPress from "@auth/qwik/providers/wordpress" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [WordPress], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/workos.mdx b/docs/pages/getting-started/providers/workos.mdx index 231573eddf..8168ea7968 100644 --- a/docs/pages/getting-started/providers/workos.mdx +++ b/docs/pages/getting-started/providers/workos.mdx @@ -25,6 +25,13 @@ https://example.com/api/auth/callback/workos ``` + + +```bash +https://example.com/auth/callback/workos +``` + + ```bash @@ -58,6 +65,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import WorkOS from "@auth/qwik/providers/workos" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [WorkOS({ connection: "conn_abc123" })], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/yandex.mdx b/docs/pages/getting-started/providers/yandex.mdx index 17f74af587..9da0267910 100644 --- a/docs/pages/getting-started/providers/yandex.mdx +++ b/docs/pages/getting-started/providers/yandex.mdx @@ -25,6 +25,13 @@ https://example.com/api/auth/callback/yandex ``` + + +```bash +https://example.com/auth/callback/yandex +``` + + ```bash @@ -56,6 +63,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Yandex from "@auth/qwik/providers/yandex" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Yandex], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/zitadel.mdx b/docs/pages/getting-started/providers/zitadel.mdx index c8171e892e..1af91cb871 100644 --- a/docs/pages/getting-started/providers/zitadel.mdx +++ b/docs/pages/getting-started/providers/zitadel.mdx @@ -22,6 +22,13 @@ https://example.com/api/auth/callback/zitadel ``` + + +```bash +https://example.com/auth/callback/zitadel +``` + + ```bash @@ -53,6 +60,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Zitadel from "@auth/qwik/providers/zitadel" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Zitadel], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/zoho.mdx b/docs/pages/getting-started/providers/zoho.mdx index 1e10960f13..4d1b674250 100644 --- a/docs/pages/getting-started/providers/zoho.mdx +++ b/docs/pages/getting-started/providers/zoho.mdx @@ -22,6 +22,13 @@ https://example.com/api/auth/callback/zoho ``` + + +```bash +https://example.com/auth/callback/zoho +``` + + ```bash @@ -53,6 +60,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Zoho from "@auth/qwik/providers/zoho" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Zoho], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/providers/zoom.mdx b/docs/pages/getting-started/providers/zoom.mdx index 004b2f310c..7eb194aaba 100644 --- a/docs/pages/getting-started/providers/zoom.mdx +++ b/docs/pages/getting-started/providers/zoom.mdx @@ -21,6 +21,13 @@ https://example.com/api/auth/callback/zoom ``` + + +```bash +https://example.com/auth/callback/zoom +``` + + ```bash @@ -52,6 +59,20 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Zoom from "@auth/qwik/providers/zoom" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Zoom], + }) +) +``` + + ```ts filename="/src/auth.ts" diff --git a/docs/pages/getting-started/session-management/custom-pages.mdx b/docs/pages/getting-started/session-management/custom-pages.mdx index e3ff196d1f..0bc990c3a0 100644 --- a/docs/pages/getting-started/session-management/custom-pages.mdx +++ b/docs/pages/getting-started/session-management/custom-pages.mdx @@ -25,6 +25,23 @@ export const { signIn, signOut, handle } = NextAuth(config) ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import GitHub from "@auth/qwik/providers/github" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [GitHub], + pages: { + signIn: "/login", + }, + }) +) +``` + + ```ts filename="src/auth.ts" {14-16} diff --git a/docs/pages/getting-started/session-management/get-session.mdx b/docs/pages/getting-started/session-management/get-session.mdx index 16c684b642..4991a09b96 100644 --- a/docs/pages/getting-started/session-management/get-session.mdx +++ b/docs/pages/getting-started/session-management/get-session.mdx @@ -108,6 +108,12 @@ export function UserAvatar({ session }) { ``` + + +Under the hood Qwik is preparing automatically the session for you so you don't have to implement custom logic for that. +You can read the sesion on the server with `event.sharedMap.get("session")` and on the client with the `useSession()` action. + + With SvelteKit, you have to return the `session` object from the load function in your `+page.server.ts` or `+layout.server.ts` files. diff --git a/docs/pages/getting-started/session-management/login.mdx b/docs/pages/getting-started/session-management/login.mdx index f4898e019d..936dedf0c8 100644 --- a/docs/pages/getting-started/session-management/login.mdx +++ b/docs/pages/getting-started/session-management/login.mdx @@ -48,6 +48,43 @@ export function SignIn() { ``` + + +With Qwik we can do a server-side sign in with Form action, or a more simple client-side login via submit method. + +```ts filename="./components/sign-in.tsx" +import { component$ } from "@builder.io/qwik" +import { Form } from "@builder.io/qwik-city" +import { useSignIn } from "./plugin@auth" + +export default component$(() => { + const signInSig = useSignIn() + + return ( + <> + {/* server-side login with Form action */} +
+ + + +
+ + {/* submit method */} + signInSig.submit({ redirectTo: "/" })} + > + SignIn + + + ) +}) +``` + +
The SvelteKit client supports two signin and signout methods, one server-side using Form Actions, and one client-side using requests and redirects. @@ -152,6 +189,28 @@ export function SignIn() { ``` + + +```ts filename="./components/sign-in.tsx" +import { component$ } from "@builder.io/qwik" +import { useSignIn } from "./plugin@auth" + +export default component$(() => { + const signInSig = useSignIn() + + return ( + <> + signInSig.submit({ redirectTo: "/dashboard" })} + > + SignIn + + + ) +}) +``` + + ```svelte filename="src/routes/+page.svelte" {9-13} @@ -227,6 +286,36 @@ export function SignOut() { ``` + + +With Qwik we can do a server-side sign out with Form action, or a more simple client-side sign out via submit method. + +```ts filename="./components/sign-out.tsx" +import { component$ } from "@builder.io/qwik" +import { Form, Link } from "@builder.io/qwik-city" +import { useSignOut } from "./plugin@auth" + +export default component$(() => { + const signOutSig = useSignOut() + + return ( + <> + {/* server-side with Form action */} +
+ + +
+ + {/* submit method */} + signOutSig.submit({ redirectTo: "/" })}> + SignIn + + + ) +}) +``` + +
SvelteKit supports both server and client-side methods for signing out as well. diff --git a/docs/pages/getting-started/session-management/protecting.mdx b/docs/pages/getting-started/session-management/protecting.mdx index 0b0bfc0cff..1857f10211 100644 --- a/docs/pages/getting-started/session-management/protecting.mdx +++ b/docs/pages/getting-started/session-management/protecting.mdx @@ -72,6 +72,21 @@ export default function MyApp({ ``` + + +Inside component$ you can use `useSession` loader to retrieve the current sessionStorage. + +```ts +import { component$ } from '@builder.io/qwik'; +import { useSession } from '~/routes/plugin@auth'; + +export default component$(() => { + const session = useSession(); + return

{session.value?.user?.email}

; +}); +``` + +
In SvelteKit, you can leverage the `event.locals.auth()` function that is put there by the Auth.js `handle` function we're importing and using in `hooks.server.ts`. @@ -186,6 +201,21 @@ export default async function handler( ``` + + +Session data can be accessed via the route event.sharedMap. +So a route can be protected and redirect using something like this located in a layout.tsx or page index.tsx: + +```ts +export const onRequest: RequestHandler = (event) => { + const session = event.sharedMap.get("session") + if (!session || new Date(session.expires) < new Date()) { + throw event.redirect(302, `/`) + } +} +``` + + API Routes in SvelteKit work like any other server-side file in Auth.js in SvelteKit, you can access the session by calling `event.locals.auth()` in the `+server.ts` files as well. diff --git a/docs/pages/guides/configuring-github.mdx b/docs/pages/guides/configuring-github.mdx index 13420ad321..73314b76b3 100644 --- a/docs/pages/guides/configuring-github.mdx +++ b/docs/pages/guides/configuring-github.mdx @@ -91,6 +91,19 @@ https://app.company.com/api/auth/callback/github ``` + + +```bash +// Local +http://localhost:3000/auth/callback/github + +// Prod +https://app.company.com/auth/callback/github +``` + +Notice no `/api` path parameter. + + ```bash diff --git a/docs/pages/guides/configuring-http-email.mdx b/docs/pages/guides/configuring-http-email.mdx index 6bf73d03bf..cf343199b8 100644 --- a/docs/pages/guides/configuring-http-email.mdx +++ b/docs/pages/guides/configuring-http-email.mdx @@ -32,6 +32,28 @@ export const { handlers, auth } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import { sendVerificationRequest } from "../lib/authSendRequest" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [ + { + id: "http-email", + name: "Email", + type: "email", + maxAge: 60 * 60 * 24, // Email link will expire in 24 hours + sendVerificationRequest, + }, + ], + }) +) +``` + + ```ts filename="./src/auth.ts" diff --git a/docs/pages/guides/configuring-oauth-providers.mdx b/docs/pages/guides/configuring-oauth-providers.mdx index b6989f0ae5..df5421c38f 100644 --- a/docs/pages/guides/configuring-oauth-providers.mdx +++ b/docs/pages/guides/configuring-oauth-providers.mdx @@ -26,6 +26,22 @@ export const { handlers, auth } = NextAuth({ }); ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Auth0 from "@auth/qwik/providers/auth0"; + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [ + Auth0({ authorization: { params: { scope: "openid custom_scope" } } }), + ], + }) +) +``` + + ```ts filename="src/auth.ts" import { SvelteKitAuth } from "@auth/sveltekit"; @@ -65,6 +81,27 @@ export const { handlers, auth } = NextAuth({ }); ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Auth0 from "@auth/qwik/providers/auth0"; + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [ + Auth0({ + // You can also make calls to external resources if necessary. + async profile(profile) { + return {}; + }, + }), + ], + }) +) +``` + + ```ts filename="src/auth.ts" import { SvelteKitAuth } from "@auth/sveltekit"; @@ -116,6 +153,26 @@ export const { handlers, auth } = NextAuth({ }); ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [{ + id: "my-provider", // signIn("my-provider") and will be part of the callback URL + name: "My Provider", // optional, used on the default login page as the button text. + type: "oidc", // or "oauth" for OAuth 2 providers + issuer: "https://my.oidc-provider.com", // to infer the .well-known/openid-configuration URL + clientId: import.meta.env.AUTH_CLIENT_ID, // from the provider's dashboard + clientSecret: import.meta.env.AUTH_CLIENT_SECRET, // from the provider's dashboard + }], + }) +) +``` + + ```ts filename="src/auth.ts" import { SvelteKitAuth } from "@auth/sveltekit"; diff --git a/docs/pages/guides/environment-variables.mdx b/docs/pages/guides/environment-variables.mdx index c3bf9824d2..5e0ed17492 100644 --- a/docs/pages/guides/environment-variables.mdx +++ b/docs/pages/guides/environment-variables.mdx @@ -13,6 +13,13 @@ AUTH_SECRET="This is an example" ``` + + +```bash filename=".env" +AUTH_SECRET="This is an example" +``` + + ```bash filename=".env" @@ -85,6 +92,22 @@ export const { handlers, auth } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Google from "@auth/qwik/providers/google" +import Twitter from "@auth/qwik/providers/twitter" +import GitHub from "@auth/qwik/providers/github" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [Google, Twitter, GitHub], + }) +) +``` + + ```ts filename="./auth.ts" {7} @@ -129,6 +152,25 @@ export const { handlers, auth } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Google from "@auth/qwik/providers/google" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [ + Google({ + clientId: import.meta.env.AUTH_WEBAPP_GOOGLE_CLIENT_ID, + clientSecret: import.meta.env.AUTH_WEBAPP_GOOGLE_CLIENT_SECRET, + }), + ], + }) +) +``` + + ```ts filename="./src/auth.ts" {8-9} diff --git a/docs/pages/guides/pages/signin.mdx b/docs/pages/guides/pages/signin.mdx index d7869e84ca..adb93947b3 100644 --- a/docs/pages/guides/pages/signin.mdx +++ b/docs/pages/guides/pages/signin.mdx @@ -49,6 +49,35 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Credentials from "@auth/qwik/providers/credentials" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [ + Credentials({ + credentials: { + username: { label: "Username" }, + password: { label: "Password", type: "password" }, + }, + async authorize({ request }) { + if (c.password !== "password") return null + return { + id: "test", + name: "Test User", + email: "test@example.com", + } + }, + }), + ], + }) +) +``` + + ```tsx filename="./src/auth.ts" {6, 21-28, 32-34} @@ -138,6 +167,44 @@ export default async function SignInPage() { ``` + + +With Qwik we can do a server-side sign in with Form action, or a more +simple client-side sign in via submit method. + +```ts filename="./components/sign-in.tsx" +import { component$ } from "@builder.io/qwik" +import { Form } from "@builder.io/qwik-city" +import { useSignIn } from "./plugin@auth" + +export default component$(() => { + const signInSig = useSignIn() + + return ( + <> + {/* server-side login with Form action */} +
+ + + +
+ + {/* submit method */} + signInSig.submit({ redirectTo: "/" })} + > + SignIn + + + ) +}) +``` + +
```svelte filename="src/routes/signin/+page.svelte" /submitButton/ /providerMap/ diff --git a/docs/pages/guides/pages/signout.mdx b/docs/pages/guides/pages/signout.mdx index f961c8087e..210b3efb1d 100644 --- a/docs/pages/guides/pages/signout.mdx +++ b/docs/pages/guides/pages/signout.mdx @@ -31,6 +31,37 @@ export default function SignOutPage() { ``` + + +With Qwik we can do a server-side sign out with Form action, or a more +simple client-side sign out via submit method. + +```ts filename="./components/sign-out.tsx" +import { component$ } from "@builder.io/qwik" +import { Form, Link } from "@builder.io/qwik-city" +import { useSignOut } from "./plugin@auth" + +export default component$(() => { + const signOutSig = useSignOut() + + return ( + <> + {/* server-side with Form action */} +
+ + +
+ + {/* submit method */} + signOutSig.submit({ redirectTo: "/" })}> + SignIn + + + ) +}) +``` + +
```svelte filename="src/routes/signout/+page.svelte" {13} /submitButton/ diff --git a/docs/pages/guides/role-based-access-control.mdx b/docs/pages/guides/role-based-access-control.mdx index d4b252dbea..b4ba0222e5 100644 --- a/docs/pages/guides/role-based-access-control.mdx +++ b/docs/pages/guides/role-based-access-control.mdx @@ -28,6 +28,26 @@ export const { handlers, auth } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import Google from "@auth/qwik/providers/google" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [ + Google({ + profile(profile) { + return { role: profile.role ?? "user", ... } + }, + }) + ], + }) +) +``` + + ```ts filename="./src/auth.ts" @@ -92,6 +112,36 @@ export const { handlers, auth } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" {9} +import { QwikAuth$ } from "@auth/qwik" +import Google from "@auth/qwik/providers/google" + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [ + Google({ + profile(profile) { + return { role: profile.role ?? "user", ... } + }, + }) + ], + callbacks: { + jwt({ token, user }) { + if(user) token.role = user.role + return token + }, + session({ session, token }) { + session.user.role = token.role + return session + } + } + }) +) +``` + + ```ts filename="./src/auth.ts" {8} @@ -177,6 +227,30 @@ export const { handlers, auth } = NextAuth({ ``` + + +```ts filename="/src/routes/plugin@auth.ts" +import { QwikAuth$ } from "@auth/qwik" +import { PrismaAdapter } from "@auth/prisma-adapter" +import { PrismaClient } from "@prisma/client" + +const prisma = new PrismaClient() + +export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$( + () => ({ + providers: [], + adapter: PrismaAdapter(prisma), + callbacks: { + session({ session, user }) { + session.user.role = user.role + return session + }, + }, + }) +) +``` + + ```ts filename="./src/auth.ts" @@ -237,6 +311,20 @@ export default function Page() { ``` + + +```ts filename="/src/routes/plugin@auth.ts" +export const onRequest: RequestHandler = (event) => { + const session = event.sharedMap.get("session") + if (!session || new Date(session.expires) < new Date()) { + throw event.redirect(302, `/auth/signin?redirectTo=${event.url.pathname}`) + } + + return session +} +``` + + ```ts filename="./routes/+page.server.ts" diff --git a/docs/pages/index.mdx b/docs/pages/index.mdx index 8df2cf4b88..1635af6191 100644 --- a/docs/pages/index.mdx +++ b/docs/pages/index.mdx @@ -88,10 +88,10 @@ import { CaretRight } from "@/icons"
{[ - { value: "express", src: Express, name: "Express" }, - { value: "nextjs", src: Next, name: "Next.js" }, - { value: "qwik", src: Qwik, name: "Qwik" }, - { value: "sveltekit", src: SvelteKit, name: "SvelteKit" }, + { value: "express", src: Express, name: "Express", darkInvert: true }, + { value: "nextjs", src: Next, name: "Next.js", darkInvert: true }, + { value: "qwik", src: Qwik, name: "Qwik", darkInvert: false }, + { value: "sveltekit", src: SvelteKit, name: "SvelteKit", darkInvert: false }, ].map((trigger) => ( ))}