php - Is this a valid setup for Websockets and JWT -


i'm trying create programming exercise setting simple push notification system. i'm not sure have right, , honest can't why other feels wrong. on paper, seems should work this:

  1. client requests page web server flag token. if token exists in database , isn't expired (using "expired at" timestamp), return otherwise generate new one. generate them using php's openssl_random_pseudo_bytes method.

  2. once response returned client, check if websocket , close if 1 exists. open new 1 token.

  3. at future time when event occurs, post request sent websocket server web server containing token destination user , message.

  4. if websocket server has active connection matching user's token, send message if not discard it. inform web server if successful or not. if unsuccessful, web server create notification on user's next login, message.

is sufficient simple? there i'm missing, there potential problems? said, exercise if tried implement in production environment need consider security?


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -