Server Authentication Through PHP Session

I have a little question about the possibilities to change authentication on my C # server from the Login \ Password session to PHP. I use PHP, HTML5 and JavaScript as the client side, and the C # server with WebSockets lib as the server. I already have an authorization code, but it only works with login and password.

Well, I have the same authentication code that checks login and password through PHP. But how can I authorize a client on a C # server using WebSockets with a PHP session, instead of the login name and password of the account?

Little rice:

Is it possible? And any piece of code, demo, etc. For him?

+4
source share
1

, #. :

PHP # (, 64 randcom)

PHP /, : , , . . - :

$random = base64_encode(mcrypt_create_iv(32));
$token = $random . '_' . $userID . '_' . hash_hmac('sha256', $random . '_' . $userID, SHARED_SECRET);

# , HMAC $random $token . , # $userID MySQL.

JS- https, .

P.S.: , JS . .

+2

Source: https://habr.com/ru/post/1621892/


All Articles