Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redis adapter #544

Closed
nikitapilgrim opened this issue Aug 5, 2020 · 6 comments
Closed

redis adapter #544

nikitapilgrim opened this issue Aug 5, 2020 · 6 comments
Labels
incomplete Insufficient reproduction. Without more info, we won't take further actions/provide help. question Ask how to do something or how something works

Comments

@nikitapilgrim
Copy link

Hi, don't you have an example of connecting a redis as a database?

@nikitapilgrim nikitapilgrim added the question Ask how to do something or how something works label Aug 5, 2020
@nyedidikeke
Copy link
Contributor

Following the documentation, you should be able to connect to redis as below;

// pages/api/auth/[...nextauth].js
import NextAuth from 'next-auth'
import Providers from 'next-auth/providers'

const options = {
  // OAuth Service Providers and other details
  // Provide URL to redis to connect (here, from .env file)
  database: process.env.DATABASE_URL
}

export default (req, res) => NextAuth(req, res, options)
# .env
DATABASE_URL=redis://user:pass@host:port

You may want to check node-redis and rediSQL while experimenting and share details as redis may/is not currently be supported by default.

D10221 pushed a commit to D10221/next-auth that referenced this issue Aug 5, 2020
Build custom adapter with the same mechanics as as the 'default' adapter
Provide 'backwards' compatibility with current implementation
@iaincollins iaincollins added the incomplete Insufficient reproduction. Without more info, we won't take further actions/provide help. label Aug 5, 2020
@iaincollins
Copy link
Member

MySQL, Postgres, Microsoft SQL Server and MongoDB are supported.

If you want to use a Redis database you would need to write your own adapter.

Redis would be a really unconventional choice in a context like this and not something support is planned for.

@D10221
Copy link

D10221 commented Aug 5, 2020

Sorry
I referenced this issue by mistake
Miss typed it :(

@JakubKoralewski
Copy link

@iaincollins

Redis would be a really unconventional choice in a context like this and not something support is planned for.

Isn't storing sessions in Redis a good idea? https://stackoverflow.com/a/9153199/10854888
Or do you suggest just using JWT in this case?

@designbyadrian
Copy link

@nikitapilgrim Did you get anywhere with this? Care to share your solution, pretty please?

@LubomirGeorgiev
Copy link

@designbyadrian

@nikitapilgrim Did you get anywhere with this? Care to share your solution, pretty please?

You can use that one https://github.com/quanhua92/next-auth-ioredis-adapter-example/blob/main/lib/IORedisAdapter.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
incomplete Insufficient reproduction. Without more info, we won't take further actions/provide help. question Ask how to do something or how something works
Projects
None yet
Development

No branches or pull requests

7 participants