Cuberite Forum
[Authentication] - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Cuberite (https://forum.cuberite.org/forum-4.html)
+--- Forum: Discussion (https://forum.cuberite.org/forum-5.html)
+--- Thread: [Authentication] (/thread-632.html)

Pages: 1 2


[Authentication] - SashaSansay - 11-21-2012

hello there;
can anyone tell me how works this function on the server side? how mcserver handle answer from auth-server? please, take me more information, cause I'm not very strong in c++



RE: [Authentication] - xoft - 11-21-2012

Authentication is described in the protocol wiki:
http://wiki.vg/Authentication#Server_operation

As for MCServer, it does exactly as written there. It receives the 0x02 handshake packet (cSocketThreads does the actual receiving, it sends data through cClientHandle into cProtocolRecognizer, that one recognizes the protocol and sends the packet into cProtocol142, which decodes the packet's meaning and calls cClientHandle's HandleHandshake and then HandleLogin (for historical reasons; earlier protocols had separate Login packets which triggerred the auth mechanism)). The HandleLogin function queues an auth-checking request with cAuthenticator.
The cAuthenticator is probably the object that you want to see the most. It runs a separate thread that processes each auth-checking request asynchronously. For each incoming request, it calls AuthFromAddress(), which connects to the auth server, sends the request and receives the answer using HTTP. If it receives a redirect request, it reconnects to the new URL and re-tries.
If successful, it sends an "auth ok" signal to the cClientHandle, through cRoot's AuthenticateUser. If not successfull, it kicks the user.

Is that good enough an explanation? Smile


RE: [Authentication] - SashaSansay - 11-21-2012

Yes Smile Thanls a lot!


RE: [Authentication] - SashaSansay - 11-22-2012

It's all so cool, but I don't understand, why server kicks me with DC "Bad Login", when auth in launcher is okay and all other Information is okay

This is checkserver.php
PHP Code:
<?php
define
('INCLUDE_CHECK',true);
include (
"connect.php");

$user mysql_real_escape_string($_GET['user']);
$serverid mysql_real_escape_string($_GET['serverId']);

$result mysql_query("Select $db_columnUser From $db_table Where $db_columnUser='$user'") or die ("Запрос к базе завершился ошибкой.");

if(
mysql_num_rows($result) == 1){
    echo 
"YES";
} else{
    echo 
"NO";
}

?>

and this is setting.ini
PHP Code:
[Authentication]
Server=http://tramway.in
Address=/auth/checkserver.php?user=%USERNAME
; &
serverId=%SERVERID%
Authenticate=

in MySQL Charset is UTF-8

UPD:
Also It doesn't works if
PHP Code:
<?php
define
('INCLUDE_CHECK',true);
include (
"connect.php");

$user mysql_real_escape_string($_GET['user']);
$serverid mysql_real_escape_string($_GET['serverId']);

$result mysql_query("Select $db_columnUser From $db_table Where $db_columnUser='$user'") or die ("Запрос к базе завершился ошибкой.");

if(
mysql_num_rows($result) == 1){
    echo 
"YES";
} else{
   echo 
"YES";
}

?>



RE: [Authentication] - FakeTruth - 11-22-2012

Isn't a bad login on the client side? That's not the server kicking you, that's the client refusing to connect.


RE: [Authentication] - SashaSansay - 11-22-2012

(11-22-2012, 11:09 AM)FakeTruth Wrote: Isn't a bad login on the client side? That's not the server kicking you, that's the client refusing to connect.

hm.. may be.. have you any ideas how can I fix it? or why client refus to connect?


RE: [Authentication] - FakeTruth - 11-22-2012

Are you using a valid login?


RE: [Authentication] - SashaSansay - 11-22-2012

(11-22-2012, 10:44 PM)FakeTruth Wrote: Are you using a valid login?

yep

UPD:
And one more question:
what file does replaces this ? "NetClientHandler.java"


RE: [Authentication] - FakeTruth - 11-23-2012

It seems to me it fails at step 5 of the client operations http://wiki.vg/Authentication#Server_operation
Quote:5. Client sends a HTTP request to
http://session.minecraft.net/game/joinserver.jsp?user=<username>&sessionId=<session id>&serverId=<server hash>
If the response is OK then continue, otherwise stop

Apparently response is not OK, so the client stops


RE: [Authentication] - SashaSansay - 11-23-2012

(11-23-2012, 01:39 AM)FakeTruth Wrote: It seems to me it fails at step 5 of the client operations http://wiki.vg/Authentication#Server_operation
Quote:5. Client sends a HTTP request to
http://session.minecraft.net/game/joinserver.jsp?user=<username>&sessionId=<session id>&serverId=<server hash>
If the response is OK then continue, otherwise stop

Apparently response is not OK, so the client stops


I think that's right. And to change the joinserver URL we need the analog of NetClientHandler.java. the file NetClientHandler.java of vanilla server. contains link to joinserver.jsp.