Code Monkey home page Code Monkey logo

Comments (6)

endel avatar endel commented on June 11, 2024

Hi @hunkydoryrepair, thanks for the feedback.

For the uWebSockets transport I had to pass a "mocked" version of the request due to the optimizations uWebSockets does internally pruning the instance. (request is not available on async calls)

So far only the headers are present in that mocked object: 600534c

Can you share how are you currently retrieving the IP address from the uWebSockets' so we can include it as well?

I think this is a good opportunity to start thinking on unifying all transports into a single API. For WebTransport I'm afraid we'll need a similar approach.

The mocked structure would look like this so far:

{
  ip: "xxx.xxx.xxx.xxx",
  headers: {
    key: "value"
  },
}

(Might be a good idea to provide URLs, protocol, paths, etc as well 🤔 )

from colyseus.

endel avatar endel commented on June 11, 2024

On the regular ws library this is the recommendation we have in the documentation, but I'm afraid it doesn't cover all cases, using behind a proxy and/or different load-balancers:

request.headers['x-forwarded-for'] || request.socket.remoteAddress

from colyseus.

hunkydoryrepair avatar hunkydoryrepair commented on June 11, 2024

Sorry, I guess I was referring to an earlier version that did not pass in the request at all (at least, was not documented). Yes, we use x-forwarded-for and the request.connection.remoteAddress...I've never seen a request.socket on the request, so that's odd.

The issue we have remaining is we need the options passed to joinById. We have a lot of data we need to do our authentication in the options passed in:

this.client.joinById( roomId, {
        mapId,
        token: token || 'iamguest',
        isGuest: !token,
        cryptoWallet: {...},
        username,
        world: worldId,
        ver: GAME_CLIENT_VERSION,
        ...spawnParams,
        avatar: !!token || !avatar ? '' : JSON.stringify(avatar),
        lastSavedAt,
        recaptchaKey,
      }

We check bots, require a matching client version, require our own token registered with Stytch, we validate that the player hasn't changed since with authenticated using the save date, etc. We need it all. Switching to static onAuth not an option without the data.

from colyseus.

hunkydoryrepair avatar hunkydoryrepair commented on June 11, 2024

We do other checks, too, that require the room state, but those can probably be moved to onJoin

from colyseus.

hunkydoryrepair avatar hunkydoryrepair commented on June 11, 2024

can close this. would be nice to have the options in the onAsync, but not required.

from colyseus.

endel avatar endel commented on June 11, 2024

Thanks @hunkydoryrepair, let's keep this open for discussion, though - as I think for v1.0 we could provide a unified "request/context" object that is the same for every transport during static onAuth 🙏

from colyseus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.