feat(adapters): add Airtable adapter
โ๏ธ 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
- Contributing guidelines
- Code of conduct
- Contributing to Open Source
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) |
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).
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
@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!
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?
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.jsonfile)
Let me know if you have any questions!
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!