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

[Important] Auth Module State

Open pi0 opened this issue 4 years ago • 57 comments

Nuxt 3 support

Nuxt 3 comes with built-in utilities to support session and authentication. We are working on a new official module. Meanwhile, we recommend:

other solutions:


Idea of auth module started back into 2017 as a way to standardize API authorization flow with nuxt applications using store state (almost same time we introduced modules concept to nuxt it was one of examples). By the time passing usage of module and varieties went way further of what it was initially designed to be.

Having a provider agnostic auth module is a really complicated problem:

  • Every auth provider has specific requirements and setup even when following standards like Oauth2
  • Non implicit authentication flows require a backend API to be also configured properly (like laravel or passport)
  • There is still no standard way to have universal state for nuxt applications
  • Isomorphic http requests require properly configured endpoints for server-side rendering and proxy
  • With static generated websites, we need to partially hydrate on client-side
  • Documentation area needs more attention for each provider

Simply saying there was no solution (with current design) to make every project happy

By each of last five major releases, we tried to adopt with new requirements and nuxt updates but still module is buggy because of complexities above and legacy code-base and almost impossible to accept new contributions without breaking changes -- one fix break another usage.

With v5 project and HUGE help of @JoaoPedroAS51 we started with a major typescript rewrite to improve architecture of module. Yet still there are framework requirements to complete v5 rewrite:

  • Built-in support for API routes in Nuxt framework (WIP)
  • Standard way to handle sessions (@nuxt/session WIP)
  • Partially auth state hydration for SSGs

Considering current status, auth module is not a stable or well-documented solution but also it doesn't means project is forgotten. We are trying hard to fill in the gap for missing core components for v5.

Some alternative packages suggested to make your own auth solution:

Update: Status page added to docs https://auth.nuxtjs.org/status Update: Thanks for all DMs for helping <3 Any help on docs is more than welcome via PRs

Regards and thanks for your patience 💚

pi0 avatar Dec 03 '20 15:12 pi0

@pi0 Thanks for the update.

I have a product using this module for oauth in production right now. It works, though with minor issues - unfortunately none of which are on your list of v5 requirements. It seems that your suggestion is that I drop this module and hand-code my own solution? Since none of your alternative packages support oauth.

A few of us have offered to step up and help maintain. For example, there are quite a few PRs for simple README and documentation updates that haven't been commented on. Are you open to that, instead?

bmulholland avatar Dec 03 '20 16:12 bmulholland

@bmulholland Glad to hear that. Actually current version is basically working but there is yet a big gap in documentation, DX and with small bugs as mentioned.

For example, there are quite a few PRs for simple README and documentation updates that haven't been commented on. Are you open to that, instead?

That's for sure! Please ping me on discord if interested to help for issue triage and maintenance :)

pi0 avatar Dec 03 '20 16:12 pi0

I saw one of your tweets (few days ago ?) saying that you had some hard time sometimes with OSS. I hope you feel better now... 😄

Thanks for this module. ❤️ I have to admit that it's my first time w/ the authentication thing. It was hard understanding all the various setups and how it works. After a few blog posts + github issues, I achieved to make 2 implementations:

  • Auth0 basic flow of email/password
  • JWT w/ a custom backend given by my teammates

And looking at it afterwards, the struggle was not that big, the configuration looks slick and it's working great. I do still have some real concerns about the whole httpOnly + secure cookie thing and the why tho. I also get that people's use cases can be unique and complex.

Meanwhile, you did a great job here ! So yeah, the documentation is maybe not crystal clear and few things are missing here and there but I wanted to send a huge thank you for your time and work ! 🙏🏻 Hope this project will continue and that you will get better. 👍🏻

kissu avatar Dec 04 '20 16:12 kissu

Where can I find the documentation for the v4?

soaresdude avatar Dec 13 '20 14:12 soaresdude

Where can I find the documentation for the v4?

Same question.

And if someone is interested: plugins/api.ts

import type { Auth } from '@nuxtjs/auth-next'

export default function ({ $auth }: { $auth: Auth }, inject: any) {
  console.log({ $auth })
  if (!$auth || !$auth.loggedIn) {
    return
  }
}

$auth undefined

nuxt.config.js

{
  modules: [
    '@nuxtjs/auth-next'
  ],
  auth: {
     plugins: [ '@/plugins/api' ]
  }
}

$auth defined

nuxt.config.js

{
  modules: [
    '@nuxtjs/auth-next'
  ],
  auth: {
     plugins: [ '@/plugins/api.ts' ]
  }
}

Micka33 avatar Dec 13 '20 17:12 Micka33

v4 docs are here: https://github.com/nuxt-community/auth-module/tree/master/docs

It would be very helpful to us if you could share why auth-next isn't working for you, though. We can't fix it if we don't know :)

bmulholland avatar Dec 15 '20 12:12 bmulholland

v4 docs are here: https://github.com/nuxt-community/auth-module/tree/master/docs

It would be very helpful to us if you could share why auth-next isn't working for you, though. We can't fix it if we don't know :)

I'm doing some freelance jobs with nuxt-auth which already have the v4 implemented and I don't want to spend time to rewrite it to use the v5.

soaresdude avatar Dec 15 '20 22:12 soaresdude

The old plugin docs were removed ? I'm trying to find them, but I didn't yet

AllanPinheiroDeLima avatar Apr 22 '21 17:04 AllanPinheiroDeLima

Hi @AllanPinheiroDeLima! You can find the docs of auth v4 here

JoaoPedroAS51 avatar Apr 22 '21 19:04 JoaoPedroAS51

Hi. Does @nuxtjs/auth-next support nuxt 3 app?

hardcommitoneself avatar Jun 01 '22 01:06 hardcommitoneself

@hardcommitoneself ive been using this plugin with nuxt-bridge with no problems. I have updated to use the new composition api and to eventually migrate to nuxt3. If you have an already built application, I would suggest going on bridge first. Otherwise, I think it will work just fine, if you already how the module

AllanPinheiroDeLima avatar Jun 01 '22 01:06 AllanPinheiroDeLima

Thanks, @AllanPinheiroDeLima. The following is my problem when I run build. image Please check out and let me know what a problem.

Many thansk!

hardcommitoneself avatar Jun 01 '22 01:06 hardcommitoneself

@hardcommitoneself i can definitely say that I didn’t come across this error. I’ve had other errors, but most of them related to vite and nitro. Have ou tried to disable nitro in nuxt config to test it out?

AllanPinheiroDeLima avatar Jun 01 '22 01:06 AllanPinheiroDeLima

Before I add '@nuxtjs/auth-next' in nuxt.config.ts, it is working well. But after added, the error occurs.

hardcommitoneself avatar Jun 01 '22 01:06 hardcommitoneself

@hardcommitoneself there are other commenters on the issues saying that the plugin is not compatible with Nuxt3

  • https://github.com/nuxt-community/auth-module/issues/1719#issuecomment-1089928369

I can say, definetely that with nuxt bridge it is working fine, because I'm using it right now. But to make this plugin ( and NuxtI18nModule ) work, I had to disable Nitro and Vite. So if you're not willing to test disabling them, there is a good chance that they will not work. Well, to be completely honest, there is a chance that they will not work either way, since Nuxt3 changed so many things alongside Vue3. If it does not work, you'll have to decide which is better: leaving this module behind and doing authentication yourself, looking for another auth plugin or downgrading your project to Vue2/Nuxt2 or Vue2/Nuxt-Bridge

AllanPinheiroDeLima avatar Jun 01 '22 04:06 AllanPinheiroDeLima

Hi @AllanPinheiroDeLima. Actually, you are right. In order to properly support Nuxt 3 stack (and Nuxt 2 with all Bridge features), auth needs a major rewrite which will be introduced as a (new) official module. We are working on it piece by piece. In the meantime, you might implement simple auth flows with Composition API and useState for Nuxt 3 :)

pi0 avatar Jun 01 '22 06:06 pi0

@pi0 hi, thanks for your work. When to expect a module for nuxt 3?

zavvla avatar Jun 09 '22 19:06 zavvla

Roadmap is here: https://v3.nuxtjs.org/community/roadmap/#%EF%B8%8F-roadmap

bmulholland avatar Jun 10 '22 11:06 bmulholland

Hi guys, the roadmap says the release of a version compatible with Nuxt3 is scheduled for 2022. Can you give me a rough idea of when you expect a release to be available (more or less)? Thanks 😃

twei55 avatar Aug 18 '22 11:08 twei55

Yes: 2022.

bmulholland avatar Aug 18 '22 11:08 bmulholland

I meant more like september or december ;-)

twei55 avatar Aug 18 '22 11:08 twei55

Not to be snarky, but the point of the roadmap is to announce dates to the currently-known level of confidence. Having side conversations about dates to different levels of detail undermines the work put into maintaining the roadmap page. And, as with all roadmaps, dates and priorities are subject to change. The most current information is reflected on the roadmap, and any updates will be published there.

bmulholland avatar Aug 18 '22 12:08 bmulholland

Good thing it was planned in 2022

Vinccool96 avatar Feb 15 '23 18:02 Vinccool96

Is there an updated estimation on when a nuxt3 compatible version might be available?

mbergen avatar Feb 21 '23 15:02 mbergen

Any updates? 2023Q1 is coming to an end soon, and there's still nothing

Vinccool96 avatar Apr 20 '23 15:04 Vinccool96

Hi, Is there any way to implement Steam auth with Superbase in Nuxt?

bitcooker avatar May 12 '23 16:05 bitcooker

If anyone is looking at this thread and wondering what to use for Nuxt 3 auth :

Implement your own auth using something like Lucia

Hebilicious avatar May 14 '23 12:05 Hebilicious

Any updates?

smortexa avatar May 17 '23 06:05 smortexa

So, what is happening with the official Auth Module?

Vinccool96 avatar Sep 06 '23 13:09 Vinccool96

@Vinccool96 still in the works if I'm not mistaken. 😊

kissu avatar Sep 06 '23 13:09 kissu