Skip to content

Releases: sidebase/nuxt-auth

0.3.0

08 Dec 15:42
75974b7
Compare
Choose a tag to compare

To use the new version:

npm i -D @sidebase/[email protected]

See the docs here: https://sidebase.io/nuxt-auth/getting-started

What's Changed

This release is a bigger one and contains some breaking things, which is why we go from 0.2 to 0.3. If you were already using 0.3.0-alpha.X you're fine and none of the below breaking changes apply to you.

In comparison to 0.2.x this release:

  • feat: delegates auth- and session-lifecycle management to a plugin
  • feat!: makes useSession sync based on this change: no more await in your setup code
  • feat: adds lastRefreshedAt to the session properties to allow you to act based on this time
  • feat!: adds a auth middleware, use it:
  • feat!: getCsrfToken returns the token string directly, instead of an object that contains the token
  • refactors the internal structure a bit: add utils/ folders, clean up some typing and comments

Breaking changes

  1. feat!: makes useSession sync

useSession is now synchronous. The initial session is fetched via a plugin that is loaded on app-startup. In your app replace:

// 1. old way to get data and status without forcing auth
const { data, status } = await useSession({ required: false })

// 2. old way to force auth
await useSession()

with:

// 1. new way to get data and status without forcing auth
const { data, status } = useSession()

// 2. new way to force auth: there's 2
// - recommended: use middlewares, read on in breaking change number (2) below or in docs https://github.com/sidebase/nuxt-auth#middleware
// - possible to support old-style manual checks:
const { getSession } = useSession()
await getSession()

and you're good to go. Note that useSession will also not directly force a login anymore. This is instead done via the new authentication middleware, see the related change below at number (2).

  1. feat!: adds a auth middleware

This is a new approach to page protection that works either globally for the whole app or locally for certain pages. Check out the docs on this here: https://github.com/sidebase/nuxt-auth#middleware

If you want to keep using the 0.2.x approach of writing protection middlewares yourself, you can do this as follows:

const { getSession } = useSession()

// This will trigger a redirect if not logged in, just as `await useSession()` used to do. Also supports same additional options like `callbackUrl`
await getSession({ required: true })  
  1. feat!: getCsrfToken returns the token string directly, instead of an object that contains the token

The return of getCsrfToken changed:

// old
console.log(await getCsrfToken())
// outputs: { token: 'asdfjklasdhjklasdhjlasdjlasdjkljklasd' }


// new
console.log(await getCsrfToken())
// outputs: 'asdfjklasdhjklasdhjlasdjlasdjkljklasd'

Commites

New Contributors

Full Changelog: 0.2.1...0.3.0

0.3.0-alpha.3

05 Dec 17:00
ee86d5d
Compare
Choose a tag to compare
0.3.0-alpha.3 Pre-release
Pre-release

To use the new version:

npm i -D @sidebase/[email protected]

What's Changed

Full Changelog: 0.3.0-alpha.2...0.3.0-alpha.3

0.3.0-alpha.2

05 Dec 16:52
dc89c4d
Compare
Choose a tag to compare
0.3.0-alpha.2 Pre-release
Pre-release

To use the new version:

npm i -D @sidebase/[email protected]

What's Changed

New Contributors

Full Changelog: 0.3.0-alpha.1...0.3.0-alpha.2

0.3.0-alpha.1

01 Dec 17:19
ebe7671
Compare
Choose a tag to compare
0.3.0-alpha.1 Pre-release
Pre-release

To use the new version:

npm i -D @sidebase/[email protected]

A big thanks to @JoaoPedroAS51 who gave the inspiration + code examples and reviewed the code for this 鉂わ笍

What's Changed

This release is a bigger one and contains some breaking things, which is why we go from 0.2 to 0.3. This release:

  • feat: delegates auth- and session-lifecycle management to a plugin
  • feat!: makes useSession sync based on this change: no more await in your setup code
  • feat: adds lastRefreshedAt to the session properties to allow you to act based on this time
  • feat!: adds a auth middleware, use it:
  • feat!: getCsrfToken returns the token string directly, instead of an object that contains the token
  • refactors the internal structure a big

Breaking changes

  1. feat!: makes useSession sync

useSession is now synchronous. The initial session is fetched via a plugin that is loaded on app-startup. In your app replace:

// 1. old way to get data and status without forcing auth
const { data, status } = await useSession({ required: false })

// 2. old way to force auth
await useSession()

with:

// 1. new way to get data and status without forcing auth
const { data, status } = useSession()

// 2. new way to force auth: there's 2
// - recommended: use middlewares, read on in breaking change number (2) below or in docs https://github.com/sidebase/nuxt-auth#middleware
// - possible to support old-style manual checks:
const { getSession } = useSession()
await getSession()

and you're good to go. Note that useSession will also not directly force a login anymore. This is instead done via the new authentication middleware, see the related change below at number (2).

  1. feat!: adds a auth middleware

This is a new approach to page protection that works either globally for the whole app or locally for certain pages. Check out the docs on this here: https://github.com/sidebase/nuxt-auth#middleware

If you want to keep using the 0.2.x approach of writing protection middlewares yourself, you can do this as follows:

const { getSession } = useSession()

// This will trigger a redirect if not logged in, just as `await useSession()` used to do. Also supports same additional options like `callbackUrl`
await getSession({ required: true })  
  1. feat!: getCsrfToken returns the token string directly, instead of an object that contains the token

The return of getCsrfToken changed:

// old
console.log(await getCsrfToken())
// outputs: { token: 'asdfjklasdhjklasdhjlasdjlasdjkljklasd' }


// new
console.log(await getCsrfToken())
// outputs: 'asdfjklasdhjklasdhjlasdjlasdjkljklasd'

Commits

Full Changelog: 0.2.1...0.3.0-alpha.1

First Time Contributor

As above, can not be stated enough: A big thanks to @JoaoPedroAS51 who gave the inspiration + code examples and reviewed the code for this 鉂わ笍

0.2.1

01 Dec 14:10
c27d5a2
Compare
Choose a tag to compare

To use the new version:

npm i -D @sidebase/[email protected]

What's Changed

New Contributors

Full Changelog: 0.2.0...0.2.1

0.2.0

24 Nov 19:51
76188b2
Compare
Choose a tag to compare

To use the new version:

npm i -D @sidebase/[email protected]

What's Changed

Full Changelog: 0.1.3...0.2.0

0.1.3

23 Nov 10:25
3519f60
Compare
Choose a tag to compare

To upgrade:

npm i -D @sidebase/[email protected]

What's Changed

Full Changelog: 0.1.2...0.1.3

0.1.2

17 Nov 17:12
94c4f08
Compare
Choose a tag to compare

To upgrade:

npm i -D @sidebase/[email protected]

What's Changed

Full Changelog: 0.1.1...0.1.2

0.1.1

17 Nov 14:04
a7ad9a6
Compare
Choose a tag to compare

To upgrade:

npm i -D @sidebase/[email protected]

Noteworthy addition:

// Trigger a sign out and send the user to the sign out page afterwards
await signOut({ calbackUrl: '/signout' })

What's Changed

Full Changelog: 0.1.0...0.1.1

0.1.0

17 Nov 07:40
3a615fd
Compare
Choose a tag to compare

This is the first non-beta release of nuxt-auth 馃帄

To upgrade:

npm i -D @sidebase/nuxt-auth

What's Changed

  • feat: make useSession isomorph 馃帄 by @BracketJohn in #31
  • docs: add security section (#31)
  • docs: add custom sign in page section (#31)
  • fix(docs): credentials provider example becomes more realistic (#31)
  • release: 0.1.0 by @BracketJohn in #33

Available at: https://www.npmjs.com/package/@sidebase/nuxt-auth

Full Changelog: 0.0.1-beta.7...0.1.0