topfreegames / pitaya

Scalable game server framework with clustering support and client libraries for iOS, Android, Unity and others through the C SDK.
MIT License
2.35k stars 482 forks source link

How to implement the authentication policy #336

Closed iEfoam closed 1 year ago

iEfoam commented 1 year ago

Excuse me, I am a pitaya white, I now need an authentication policy, I used python channel before, the policy is to use the token after the url address to detect whether the token is legitimate, for example:

WsURL: 127.0.0.1:8000/ws/94a08da1fecbb6e8b46990538c7b50b2

I had two plans, but neither came to fruition

  1. Get the token string after the url but unfortunately can't find the method
  2. Intermediate key processing saved the token into the session but I couldn't get 'route' I use a builder. HandlerHooks. BeforeHandler. PushBack (middlewareServer. RequestBefore) if you can't get to the route, that this scheme also makes no sense I also tried using the 'addRoute' method but for some reason it didn't work

I hope you can give us relevant plans. The time is urgent. Thank you

felipejfc commented 1 year ago

you can just create a authentication hook that runs before dispatching the message to the handler

iEfoam commented 1 year ago

thank you