next-auth icon indicating copy to clipboard operation
next-auth copied to clipboard

feat(adapters): add Airtable adapter

Open kyen99 opened this issue 3 years ago โ€ข 5 comments

โ˜•๏ธ Reasoning

This PR adds an adapter to use Airtable as a store for next-auth. Airtable is NOT a good long term solution for an authentication backend, but is useful for standing up a site with authentication FAST to test whether anyone wants to use [insert your probably terrible idea here].

๐Ÿงข Checklist

  • [ X] Documentation
  • [ X] Tests
  • [ X] Ready to be merged

๐ŸŽซ Affected issues

There are no existing tickets that mention Airtable as an adapter, but I intend to use this for many projects at my company for quickly testing ideas.

This doesn't fix any existing problem. (Unless someone secretly wanted an Airtable adapter.)

๐Ÿ“Œ Resources

kyen99 avatar May 21 '22 19:05 kyen99

The latest updates on your projects. Learn more about Vercel for Git โ†—๏ธŽ

Name Status Preview Updated
next-auth โœ… Ready (Inspect) Visit Preview Nov 6, 2022 at 3:32PM (UTC)

vercel[bot] avatar May 21 '22 19:05 vercel[bot]

Some additional notes I forgot to add to the PR...

  • The tests require an airtable account and clone of this base to run: https://airtable.com/shr16Xd8glUk90c4P
  • Airtable does not provide a way to programmatically create a database, so providing a public one with the correct schema that can be cloned seemed to be the best option (short of mocking the airtable sdk).

kyen99 avatar May 21 '22 19:05 kyen99

If anyone comes across this PR while looking for an Airtable adapter, you can use this separate npm package until this is merged (or in case it is never merged).... https://www.npmjs.com/package/next-auth-adapter-airtable

kyen99 avatar May 28 '22 12:05 kyen99

@balazsorban44 thank you for reviewing the PR!

I could move everything into a single file at the expense of a cognitive complexity of 30+ and about 200 lines of code (that's how I originally wrote it.) If this better matches the style of the existing codebase I will change to a single file.

There is no self-hosted airtable option. The only alternative is to mock the Airtable API. If that's preferable, I will do that.

I will start working on the documentation. Please let me know about the above two items.

Thank you!

kyen99 avatar May 31 '22 23:05 kyen99

I combined this into fewer files as suggested by @balazsorban44. I believe everything has been addressed except for the tests requiring an airtable account and .env to store api key and base id.

Airtable doesn't provide any simulated environments for testing except a testDriver for their blocks SDK. I tried to use that testDriver, but it's not designed for testing the REST API. Mocking the library doesn't seem to make sense because of the way runBasicTests works (i.e. I would have to mock those calls as well).

I'll continue to think about other testing options. Maybe @ndom91 will have an idea?

kyen99 avatar Jun 04 '22 22:06 kyen99

hi @kyen99 sorry for the delay, do you think you can pick up the pieces and get this in soon? ๐Ÿšข About formatting, you can take a look at https://github.com/nextauthjs/next-auth/pull/6745 as a reference for:

  • JSDoc for documentation (
  • ESM output (check the package.json file)

Let me know if you have any questions!

ThangHuuVu avatar Jul 10 '23 15:07 ThangHuuVu

To keep things tidy, we are closing this issue for now. If you think your issue is still relevant, leave a comment and we might reopen it. Thanks!

stale[bot] avatar Sep 16 '23 19:09 stale[bot]