{"id":15099157,"url":"https://github.com/opensaasau/keystone-nextjs-auth","last_synced_at":"2025-10-08T05:30:20.506Z","repository":{"id":37618892,"uuid":"377986506","full_name":"OpenSaasAU/keystone-nextjs-auth","owner":"OpenSaasAU","description":"A package that add social auth to Keystone-6 (https://keystonejs.com/) by using next-authjs (https://next-auth.js.org/)","archived":true,"fork":false,"pushed_at":"2023-10-08T00:44:58.000Z","size":3375,"stargazers_count":75,"open_issues_count":48,"forks_count":11,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-26T08:31:55.795Z","etag":null,"topics":["auth0","authentication","hacktoberfest","keystone","nextauth","nextjs"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OpenSaasAU.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"github":null,"ko_fi":"opensaas"}},"created_at":"2021-06-17T23:47:40.000Z","updated_at":"2024-01-15T10:27:46.000Z","dependencies_parsed_at":"2023-10-02T20:07:59.488Z","dependency_job_id":null,"html_url":"https://github.com/OpenSaasAU/keystone-nextjs-auth","commit_stats":{"total_commits":404,"total_committers":12,"mean_commits":"33.666666666666664","dds":"0.42821782178217827","last_synced_commit":"9ae86bfef29bd5fbd611351d3de039ea315f09be"},"previous_names":[],"tags_count":61,"template":false,"template_full_name":null,"purl":"pkg:github/OpenSaasAU/keystone-nextjs-auth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenSaasAU%2Fkeystone-nextjs-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenSaasAU%2Fkeystone-nextjs-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenSaasAU%2Fkeystone-nextjs-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenSaasAU%2Fkeystone-nextjs-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OpenSaasAU","download_url":"https://codeload.github.com/OpenSaasAU/keystone-nextjs-auth/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenSaasAU%2Fkeystone-nextjs-auth/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278892036,"owners_count":26063918,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["auth0","authentication","hacktoberfest","keystone","nextauth","nextjs"],"created_at":"2024-09-25T17:06:31.658Z","updated_at":"2025-10-08T05:30:20.156Z","avatar_url":"https://github.com/OpenSaasAU.png","language":"TypeScript","funding_links":["https://ko-fi.com/opensaas"],"categories":[],"sub_categories":[],"readme":"# Package now DEPRECIATED\nThis package now no longer works with the latest versions of Keystone and Next-Auth. For more background see https://github.com/keystonejs/keystone/pull/8582.\nYou can now implement Next-Auth directly in Keystone - see example https://github.com/keystonejs/keystone/tree/main/examples/custom-session-next-auth\n\n[![Open in Visual Studio Code](https://open.vscode.dev/badges/open-in-vscode.svg)](https://open.vscode.dev/OpenSaasAU/keystone-nextjs-auth)\n[![Release](https://github.com/OpenSaasAU/keystone-nextjs-auth/actions/workflows/release.yml/badge.svg)](https://github.com/OpenSaasAU/keystone-nextjs-auth/actions/workflows/release.yml)\n\n# Keystone next auth\n\nThis package enables the addition of social auth to keystone-6.\n\n## Contents\n\n- [About](#about)\n- [Adding to your project](#adding-to-your-project)\n- [Configuration](#configuration)\n- [Contributing](#contributing)\n\n## About\n\nThis uses NextAuth.js (https://next-auth.js.org/) project to add social auth to Keystone-6 (https://keystonejs.com/). Primary testing has been done with Auth0, happy for others to test other providers/give feedback or send through a PR.\n\n## Adding to your project\n\nAdd package by `yarn add @opensaas/keystone-nextjs-auth` then add the following to your `keystone.ts`:\n\nAdd import...\n\n```javascript\nimport { createAuth } from '@opensaas/keystone-nextjs-auth';\nimport Auth0 from '@opensaas/keystone-nextjs-auth/providers/auth0';\n```\n\nAdd you Auth configuration including providers\nfor Provider configuration see https://next-auth.js.org/providers/. For Provider configuration replace `next-auth/providers/` with `@opensaas/keystone-nextjs-auth/providers/`\n\n```javascript\nlet sessionSecret = process.env.SESSION_SECRET;\n\nif (!sessionSecret) {\n  if (process.env.NODE_ENV === 'production') {\n    throw new Error(\n      'The SESSION_SECRET environment variable must be set in production'\n    );\n  } else {\n    sessionSecret = '-- DEV COOKIE SECRET; CHANGE ME --';\n  }\n}\n\nconst auth = createAuth({\n  listKey: 'User',\n  identityField: 'subjectId',\n  sessionData: `id name email`,\n  autoCreate: true,\n  resolver: async ({user, profile, account}) =\u003e {\n    const username = user.name as string;\n    const email = user.email as string;\n    return { email, username };\n  },\n  keystonePath: '/admin',\n  sessionSecret,\n  providers: [\n    Auth0({\n      clientId: process.env.AUTH0_CLIENT_ID || 'Auth0ClientID',\n      clientSecret: process.env.AUTH0_CLIENT_SECRET || 'Auth0ClientSecret',\n      domain: process.env.AUTH0_DOMAIN || 'opensaas.au.auth0.com',\n    }),\n]\n});\n```\n\nWrap your keystone config in `auth.withAuth`.\n\n```javascript\nexport default auth.withAuth(\n  config({\n    server: {},\n    db: {},\n    ui: {},\n    lists,\n    ...\n  });\n```\n\n## Configuration\n\nProvider configuration see https://next-auth.js.org/configuration/providers.\nFor Keystone-6 Configuration see https://keystonejs.com/\nfor example see the example [backend](./backend)\n\n- listKey - the list for authentication (generally `'User'`). Make sure any required fields are set using the `*Map` fields, see note below.\n- identityField - The field that stores the identity/subjectId in keystone (generally `'subjectId'`). You will need to add this field to your list schema specified by `listKey`. An example can be found [here](./backend/schemas/User.ts).\n- sessionData - Data to be stored in the session ( something like `'id name email'`),\n- autoCreate - boolean to autocreate a user when they log in\n- userMap: `key:value` pairs that define what is copied from the User object returned from NextAuth in the SignIn callback (https://next-auth.js.org/configuration/callbacks#sign-in-callback) Left side is Keystone side, right is what comes from NextAuth eg: `{ subjectId: 'id', name: 'name' }`\n- accountMap - As Above but for the Account object\n- profileMap - As Above but for the Profile object\n- keystonePath - the path you want to access keystone from your frontend app (if required).\n\nNote: The Keystone `create-keystone-app` CLI app (generally run with `yarn create keystone-app`/`npm init keystone-app`) will set a required `password` field on the `User` list. If you've used this to set up your project you will need to modify your list schema to set the field as not required, or remove it entirely if you don't plan to use the default Keystone auth system at all.\n\n## Contributing\n\nIf you want to run this package locally\nAfter cloning run `yarn install` and either:\n\n- `yarn dev` to run both the frontend and backend or\n- `yarn dev:backend` for just the backend\n\nThe [Demo App](./apps/ks-frontend-demo) is configured in `next.config.js` to proxy `/api/auth` to the the host setup using the environment variable `BACKEND_BASE_URL` in development set `export BACKEND_BASE_URL=http://localhost:3000` you will also need to set your `NEXTAUTH_URL` environment variable see https://next-auth.js.org/configuration/options for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopensaasau%2Fkeystone-nextjs-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopensaasau%2Fkeystone-nextjs-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopensaasau%2Fkeystone-nextjs-auth/lists"}