adonisjs / auth

Official Authentication package for AdonisJS
https://docs.adonisjs.com/guides/auth/introduction
MIT License
187 stars 65 forks source link

Question: How to validade an API token outside of a HTTP request #216

Closed un-versed closed 1 year ago

un-versed commented 1 year ago

It's possible to check an api token outside of a HTTP request?

I'm trying to implement socket.io server in my existing adonis application, but I didn't figure out how to authenticate the socket.io connection.

I already have the token input, I just need to verify it

Ws.io.use((socket, next) => {
  const token = socket.handshake.auth.token

  if (token) {
    console.log(token)
  }

  next()
})

Any tips on this?

RomainLanz commented 1 year ago

Duplicate of https://github.com/adonisjs/core/discussions/4165