Commit 2a07e35e authored by jan.koester's avatar jan.koester
Browse files

test

parent 4d3116f6
Loading
Loading
Loading
Loading
Loading
+0 −11
Changes for src/admin.cpp: 0 added lines, 11 removed lines.
Original line number Diff line number Diff line
@@ -1782,8 +1782,6 @@ namespace authdb {
                    domain = curformdat.value;
            }

            std::cerr << "[LOGIN] user='" << username << "' domain='" << domain << "'" << std::endl;

            if (password.empty() || username.empty())
                throw AuthBackendError("login: password or username are empty!");

@@ -1812,22 +1810,13 @@ namespace authdb {
                size_t upos = sizeof(authdb::AuthHeader);
                user.info(*backend, udat, upos);

                std::cerr << "[LOGIN] found user='" << udat.getUsername()
                          << "'(len=" << udat.getUsername().size() << ")"
                          << " input='" << username << "'(len=" << username.size() << ")"
                          << " match=" << (username == udat.getUsername())
                          << " pw_match=" << (pwhash == udat.getPwHash()) << std::endl;

                if (!username.empty() && username == udat.getUsername() &&
                    !pwhash.empty() && pwhash == udat.getPwHash()) {

                    libhttppp::HttpCookie cookie;
                    uuid::uuid sid;
                    std::cerr << "[LOGIN] credentials OK, calling addSession did='" << did.c_str()
                              << "' uid='" << uid.c_str() << "'" << std::endl;
                    const SessionData *cses = AuthSession->addSession(*backend, did, udat.Data.ruid);
                    cses->getSid(sid);
                    std::cerr << "[LOGIN] addSession returned sid='" << sid.c_str() << "'" << std::endl;

                    if (!cses->checkGPO("888cd19b-352d-11f0-a8cc-3cecefce9ac2")) {
                        AuthSession->remSession(sid);
+0 −14
Changes for src/cluster.cpp: 0 added lines, 14 removed lines.
Original line number Diff line number Diff line
@@ -587,17 +587,11 @@ namespace authdb {
        sess.getSid(sid);
        uint64_t sid_gid = sidGroupId(sid);

        std::cerr << "[CLUSTER-SESSION] pushSession: sid=" << sid.c_str()
                  << " sid_gid=" << sid_gid
                  << " data_size=" << data.size() << std::endl;

        for (int attempt = 0; attempt < 3; ++attempt) {
            try {
                session_client_->store(sid_gid, data.data(), data.size());
                return;
            } catch (const std::exception &e) {
                std::cerr << "[CLUSTER-SESSION] pushSession: store attempt "
                          << attempt + 1 << "/3 FAILED: " << e.what() << std::endl;
                if (attempt < 2)
                    std::this_thread::sleep_for(std::chrono::milliseconds(200));
            }
@@ -794,26 +788,18 @@ namespace authdb {
                                     std::vector<std::pair<uuid::uuid, bool>> &gpo_results) {
        uint64_t sid_gid = sidGroupId(session_id);

        std::cerr << "[CLUSTER-SESSION] fetchBySid: sid=" << session_id.c_str()
                  << " sid_gid=" << sid_gid << std::endl;

        if (session_client_) {
            try {
                auto data = session_client_->retrieve(sid_gid);
                std::cerr << "[CLUSTER-SESSION] fetchBySid: retrieved " << data.size() << " bytes" << std::endl;
                if (!data.empty()) {
                    int64_t created_at;
                    if (SessionBlock::deserialize(data, sid, uid, did, members, username, gpo_results, created_at)) {
                        std::cerr << "[CLUSTER-SESSION] fetchBySid: deserialized OK, sid=" << sid.c_str() << std::endl;
                        return true;
                    }
                    std::cerr << "[CLUSTER-SESSION] fetchBySid: deserialize FAILED" << std::endl;
                }
            } catch (const std::exception &e) {
                std::cerr << "[CLUSTER-SESSION] fetchBySid: exception: " << e.what() << std::endl;
                return false;
            } catch (...) {
                std::cerr << "[CLUSTER-SESSION] fetchBySid: unknown exception" << std::endl;
                return false;
            }
        }
+0 −12
Changes for src/session.cpp: 0 added lines, 12 removed lines.
Original line number Diff line number Diff line
@@ -419,36 +419,26 @@ authdb::ClusterSession::ClusterSession() : LocalSession() {}
authdb::ClusterSession::~ClusterSession() {}

const authdb::SessionData *authdb::ClusterSession::addSession(AuthBackend &backend,uuid::uuid domainid,uuid::uuid userid){
    std::cerr << "[SESSION] addSession: enter, g_Cluster=" << (g_Cluster ? "yes" : "null")
              << " running=" << (g_Cluster ? g_Cluster->isRunning() : false)
              << " critical=" << (g_Cluster ? g_Cluster->isCritical() : false)
              << " did='" << domainid.c_str() << "' uid='" << userid.c_str() << "'" << std::endl;
    if (!g_Cluster || !g_Cluster->isRunning())
        throw AuthBackendError("cluster not ready — please try again later");
    if (g_Cluster->isCritical())
        throw AuthBackendError("cluster critical — too few nodes online, please try again later");

    // Create new session
    std::cerr << "[SESSION] addSession: calling createSessionData..." << std::endl;
    SessionData *newSession = nullptr;
    try {
        newSession = createSessionData(backend, domainid, userid);
    } catch (const std::exception &e) {
        std::cerr << "[SESSION] addSession: createSessionData FAILED: " << e.what() << std::endl;
        throw;
    }

    uuid::uuid newSid;
    newSession->getSid(newSid);
    std::cerr << "[SESSION] addSession: created sid=" << newSid.c_str()
              << " uid=" << userid.c_str() << " did=" << domainid.c_str() << std::endl;

    // Push to cluster
    try {
        g_Cluster->pushSession(*newSession);
        std::cerr << "[SESSION] addSession: pushSession OK" << std::endl;
    } catch (const std::exception &e) {
        std::cerr << "[SESSION] addSession: pushSession FAILED: " << e.what() << std::endl;
        delete newSession;
        throw AuthBackendError("session could not be stored in cluster — please try again");
    }
@@ -491,8 +481,6 @@ const authdb::SessionData *authdb::ClusterSession::getSession(uuid::uuid session
        return imported;
    }

    std::cerr << "[SESSION] getSession: sid=" << sessionid.c_str()
              << " not found in cluster" << std::endl;
    return nullptr;
}