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:
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.once response returned client, check if websocket , close if 1 exists. open new 1 token.
at future time when event occurs, post request sent websocket server web server containing token destination user , message.
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
Post a Comment