keystone-nextjs-auth icon indicating copy to clipboard operation
keystone-nextjs-auth copied to clipboard

Feature Request - Adapter Implementation

Open RedZepplin opened this issue 2 years ago • 1 comments

Hi Guys,

Amazing work you've done here this project of yours has really helped me,

I'm currently implementing Auth via the google identity platform, and I'm sure I could probably implement something directly with firebase but would love to keep using this module, the only thing really stopping me is adapters aren't implemented,

https://next-auth.js.org/adapters/overview https://next-auth.js.org/adapters/firebase

Probably just need to add the property definition "adaptor" to the AuthConfig type def, although not sure how the other dependencies might work

Keystone.ts would then look something like this

const auth = createAuth({
  listKey: 'User',
  identityField: 'subjectId',
  sessionData: `id name email`,
  autoCreate: true,
  resolver: async ({user, profile, account}) => {
    const username = user.name as string;
    const email = user.email as string;
    return { email, username };
  },

  keystonePath: '/admin',
  sessionSecret,
  providers: [
    GoogleProvider({
      clientId: process.env.GOOGLE_ID || "Google Cloud Client ID",
      clientSecret: process.env.GOOGLE_SECRET || "Google Cloud Client Secret",
    }),
  ],
  
  adapter: FirestoreAdapter({
  apiKey: process.env.FIREBASE_API_KEY,
  appId: process.env.FIREBASE_APP_ID,
  authDomain: process.env.FIREBASE_AUTH_DOMAIN,
  databaseURL: process.env.FIREBASE_DATABASE_URL,
  projectId: process.env.FIREBASE_PROJECT_ID,
  storageBucket: process.env.FIREBASE_STORAGE_BUCKET,
  messagingSenderId: process.env.FIREBASE_MESSAGING_SENDER_ID,
  // Optional emulator config (see below for options)
  emulator: {},

}),
});

Much love Juan H

RedZepplin avatar Nov 15 '22 07:11 RedZepplin