Skip to content

Conversation

@atinux
Copy link
Owner

@atinux atinux commented Sep 11, 2024

Resolves #169

Adding a 3rd argument to setUserSession and replaceUserSession to overwrite the SessionConfig

await setUserSession(event, { ... } , {
  maxAge: 60 * 60 * 24 * 7 // 1 week
})

Resolves #47

It is now possible to set private data using the secure property in the session data:

await setUserSession(event, {
  // User data
  user: {
    login: 'atinux'
  },
  // Private data accessible on server/ routes
  secure: {
    apiToken: '1234567890'
  },
  // Any extra fields for the session data
  loggedInAt: new Date()
})

// Server-side
const { secure, user } = await requireUserSession(event)

// App-side
const { session } = useUserSession()
session.value.secure // undefined

@atinux atinux merged commit 875dd5b into main Sep 11, 2024
@atinux atinux deleted the improvements branch September 11, 2024 14:50
atinux added a commit to Gerbuuun/nuxt-auth-utils that referenced this pull request Sep 25, 2024
atinux added a commit that referenced this pull request Sep 30, 2024
* feat: add passkey specific webauthn authentication support

* feat: playground passkey implementation

* feat: initial docs

* fix: composable type and availability functions

* fix: types and webauthn config functions

* fix: auto import

* fix: composable jsdoc

* feat: handle attempts internally and change config to respective options name

* chore: update README.md

* fix: make sure attempt is always removed from storage!

* chore: make playground implementation more consistent

* refactor: use 'webauthn' and 'credential' terms instead of 'passkey'

* refactor: use body instead of query param for `attemptId`

* chore: rename passkey terms

* chore: improvements

* up

* lint fix

* feat: use session to store challenge by default

* feat: base64 encode publicKey by default

* chore: types cleanup and typo fixes

* feat: improve example and documentation

* chore: proofread readme

* fix: typo

* docs: add frontend example

* docs: fix typo

Change useServerSession() to useUserSession()

* refactor: request token

* refactor: request token

* chore: fix import

* up

* up

* Merge branch 'main' into refactor/request-token

* [autofix.ci] apply automated fixes

* chore: fix types issue

* chore: lint

---------

Co-authored-by: Sébastien Chopin <seb@nuxt.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>

* feat: add tiktok provider

* feat: add tiktok provider

* docs: add tiktok

* feat: add tiktok .env example

* chore: remove console logs

* [autofix.ci] apply automated fixes

* chore: remove unused authorizationParams

* chore: use new utils

* fix: extends from RequestAccesTokenBody interface

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>

* chore: update deps

* chore(release): v0.3.6

* fix: paypal tokens request requires encoded `redirect_uri`

* fix: encode paypal `redirect_uri`

* chore: add comment

* chore: update deps

* chore(release): v0.3.7

* docs: add note about cookie size

* feat: add Gitlab provider

* feat: add yandex oauth

* chore: linting

* update: change FormData to URLSearchParams & add config.emailRequired

* up

* [autofix.ci] apply automated fixes

* chore(release): v0.2.0

* style: add lint script

* style: add lint script

* ci: update lint fix command

* [autofix.ci] apply automated fixes

* feat: add gitlab provider

* [autofix.ci] apply automated fixes

* update Supported OAuth Providers in readme

* Apply suggestions from code review

---------

Co-authored-by: Sébastien Chopin <seb@nuxt.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Estéban <esteban.soubiran@insa-cvl.fr>
Co-authored-by: Sébastien Chopin <seb@nuxtlabs.com>

* docs: Add note to readme about session API route

* Add note about session API route

* Update README.md

* Update README.md

---------

Co-authored-by: Sébastien Chopin <seb@nuxtlabs.com>

* feat: add instagram provider

* feat(instagram): new provider

* chore(instagram): add provider to readme

* fix(instagram): oauth query

---------

Co-authored-by: Sébastien Chopin <seb@nuxt.com>

* chore: add emailRequired for testing Gitlab

* feat: add vk provider

* feat: add yandex oauth

* chore: linting

* update: change FormData to URLSearchParams & add config.emailRequired

* up

* [autofix.ci] apply automated fixes

* chore(release): v0.2.0

* style: add lint script

* style: add lint script

* ci: update lint fix command

* [autofix.ci] apply automated fixes

* feat: add gitlab provider

* [autofix.ci] apply automated fixes

* update Supported OAuth Providers in readme

* feat: add vk provider

* [autofix.ci] apply automated fixes

* up

---------

Co-authored-by: Sébastien Chopin <seb@nuxt.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Estéban <esteban.soubiran@insa-cvl.fr>

* fix: ensure plugin declaration files are emitted (#170)

* feat: add support for private data & config argument (#171)

* chore: up

* chore(release): v0.3.8

* fix: UserSession secure type augmentation (#181)

* fix: UserSession secure type augmentation

* docs: add readme example

* chore: update deps

* chore(release): v0.3.9

* feat: add Dropbox as supported oauth provider (#183)

* feat: add Dropbox as supported oauth provider

* chore: remove no needed config

* fix(steam): improve open id validation (#184)

* fix(steam): open id validation

* chore: lint

* chore: check steam id

* [autofix.ci] apply automated fixes

* chore: update error message

* chore: adjust steam id checker

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>

* feat!: call `fetch` hook if session is not empty instead of user defined (#188)

* feat!: rename `oauth<Provider>EventHandler` to`defineOAuth<Provider>EventHandler` (#189)

* up

* lint fix

* up

* type error

* [autofix.ci] apply automated fixes

* fix all types

* [autofix.ci] apply automated fixes

* chore: use logger

* [autofix.ci] apply automated fixes

* Update autofix.yml

* rename to useWebAuthn

* [autofix.ci] apply automated fixes

* update readme

* [autofix.ci] apply automated fixes

* feat: allow for extra data fields to be included in the registration body

* [autofix.ci] apply automated fixes

* fix: component name

* Update autofix.yml

* chore: update

* up

* chore: fix types

* add validateUser method

* chore: small update

* add allowCredentials and improve validateUser

* lint

* feat: infer registration body and credential data

* chore: remove unnecessary generic param

* chore: add demo

---------

Co-authored-by: Sébastien Chopin <seb@nuxt.com>
Co-authored-by: Ivailo Panamski <ipanamski@gmail.com>
Co-authored-by: Estéban <e.soubiran25@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Ahmed Rangel <ahmedrangel@outlook.com>
Co-authored-by: Yizack Rangel <yizackr@gmail.com>
Co-authored-by: Alex Blumgart <dev.blumgart@yandex.ru>
Co-authored-by: Estéban <esteban.soubiran@insa-cvl.fr>
Co-authored-by: Sébastien Chopin <seb@nuxtlabs.com>
Co-authored-by: Rudo Kemper <31662219+rudokemper@users.noreply.github.com>
Co-authored-by: Sandro Circi <sandro.circi@digitoolmedia.com>
Co-authored-by: Daniel Roe <daniel@roe.dev>
Co-authored-by: Israel Ortuño <ai.ortuno@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

setUserSession specify max age Only expose public data part of session

2 participants