From d9ec4abdc566bfdcc61081e16d731466c668de64 Mon Sep 17 00:00:00 2001 From: Gabor Adam Toth Date: Tue, 26 Jul 2011 11:34:11 +0200 Subject: [PATCH] hmac-sha1-shared auth: auto-register users & disable manual registration --- world/net/person.c | 18 +++++++++++++++--- world/net/usercmd.i | 8 ++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/world/net/person.c b/world/net/person.c index cfb2502..72233a0 100644 --- a/world/net/person.c +++ b/world/net/person.c @@ -757,9 +757,14 @@ checkPassword(try, method, salt, args, cb, varargs cbargs) { // why here? //while (remove_call_out(#'quit) != -1); #ifndef REGISTERED_USERS_ONLY +# ifdef AUTH_HMAC_SECRET + if (IS_NEWBIE && method != "hmac-sha1-shared") ARETURN(1) +# else if (IS_NEWBIE) ARETURN(1) // could auto-register here.. +# endif #endif - if (!try || try == "") ARETURN(0) + if (!try || try == "" || v("password") == "") ARETURN(0) + switch(method) { #if __EFUN_DEFINED__(sha1) case "SHA1": @@ -773,8 +778,15 @@ case "HMAC-SHA1": case "hmac-sha1": ARETURN(try == hmac(TLS_HASH_SHA1, v("password"), salt)) # ifdef AUTH_HMAC_SECRET +# define REGISTER_DISABLED case "hmac-sha1-shared": - ARETURN(try == hmac(TLS_HASH_SHA1, AUTH_HMAC_SECRET, salt + MYNICK)) + if (try == hmac(TLS_HASH_SHA1, AUTH_HMAC_SECRET, salt + MYNICK)) { + if (IS_NEWBIE) { + vSet("password", ""); + save(); + } + ARETURN(1); + } else ARETURN(0); # endif # endif #else @@ -809,7 +821,7 @@ default: P4(("plain text pw %O == %O?\n", try, v("password"))) #ifdef PASSWORDCHECK PASSWORDCHECK(v("password"), try) -#else +#else if (try == v("password")) ARETURN(1); #endif } diff --git a/world/net/usercmd.i b/world/net/usercmd.i index 29461ba..0362233 100644 --- a/world/net/usercmd.i +++ b/world/net/usercmd.i @@ -3056,6 +3056,14 @@ set(key, value) { w("_echo_set_default", "Setting [_key_set] has been reset to its default state.", ([ "_key_set" : key ]) ); +#ifdef REGISTER_DISABLED + } else if (key == "password" && IS_NEWBIE) { +# ifdef REGISTER_URL + w("_echo_set_password", "Registration disabled here. You can register at: " + REGISTER_URL); +# else + w("_echo_set_password", "Registration disabled."); +# endif +#endif } else { vSet(key, value); if (key == "password") w("_echo_set_password",