Auth-module: [Important] Auth Module State

Created on 3 Dec 2020  路  9Comments  路  Source: nuxt-community/auth-module

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 馃挌

Most helpful comment

@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?

All 9 comments

@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 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 :)

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. 馃憤馃徎

Where can I find the documentation for the v4?

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' ]
  }
}

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 :)

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.

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

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yuwacker picture yuwacker  路  3Comments

pi0 picture pi0  路  3Comments

weijinnx picture weijinnx  路  3Comments

manniL picture manniL  路  4Comments

Amoki picture Amoki  路  3Comments