Commit 226eeb9d authored by DanmeiChen's avatar DanmeiChen Committed by François Grisez

add work for login with unescaped username

parent 56034cd5
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>
#define MAX_USERNAME_LENGTH 30
using namespace std; using namespace std;
......
...@@ -158,7 +158,13 @@ void SociAuthDB::getPasswordWithPool(const std::string &id, const std::string &d ...@@ -158,7 +158,13 @@ void SociAuthDB::getPasswordWithPool(const std::string &id, const std::string &d
SLOGD << "[SOCI] Pool acquired in " << DURATION_MS(start, stop) << "ms"; SLOGD << "[SOCI] Pool acquired in " << DURATION_MS(start, stop) << "ms";
start = stop; start = stop;
*sql << get_password_request, into(passwd.pass), use(id, "id"), use(domain, "domain"), use(authid, "authid"); char unescapedId[MAX_USERNAME_LENGTH];
// WARNING: it is necessary to create a temporary string here because use() function creates
// and returns an object that stores a reference on it. So, it must absolutely be destroyed
// at the end of this function.
string unescapedIdStr(url_unescape(unescapedId, id.c_str()));
*sql << get_password_request, into(passwd.pass), use(unescapedIdStr, "id"), use(domain, "domain"), use(authid, "authid");
passwd.passmd5 = passwd.pass; // TODO passwd.passmd5 = passwd.pass; // TODO
stop = steady_clock::now(); stop = steady_clock::now();
SLOGD << "[SOCI] Got pass for " << id << " in " << DURATION_MS(start, stop) << "ms"; SLOGD << "[SOCI] Got pass for " << id << " in " << DURATION_MS(start, stop) << "ms";
......
...@@ -91,7 +91,9 @@ void AuthDbBackend::declareConfig(GenericStruct *mc) { ...@@ -91,7 +91,9 @@ void AuthDbBackend::declareConfig(GenericStruct *mc) {
string AuthDbBackend::createPasswordKey(const string &user, const string &auth_username) { string AuthDbBackend::createPasswordKey(const string &user, const string &auth_username) {
ostringstream key; ostringstream key;
key << user << "#" << auth_username; char unescapedId[MAX_USERNAME_LENGTH];
url_unescape(unescapedId, auth_username.c_str());
key << user << "#" << unescapedId;
return key.str(); return key.str();
} }
......
...@@ -40,6 +40,8 @@ ...@@ -40,6 +40,8 @@
#include "sofia-sip/auth_module.h" #include "sofia-sip/auth_module.h"
#include "sofia-sip/auth_plugin.h" #include "sofia-sip/auth_plugin.h"
#define MAX_USERNAME_LENGTH 30
enum AuthDbResult { PENDING, PASSWORD_FOUND, PASSWORD_NOT_FOUND, AUTH_ERROR }; enum AuthDbResult { PENDING, PASSWORD_FOUND, PASSWORD_NOT_FOUND, AUTH_ERROR };
struct passwd_algo_t { struct passwd_algo_t {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment