Commit e60cd017 authored by jan.koester's avatar jan.koester
Browse files

test

parent f6a2315c
Loading
Loading
Loading
Loading
+34 −5
Changes for src/auth.cpp: 34 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -66,29 +66,58 @@ blogi::Auth::~Auth(){
}

void blogi::Auth::login(const int tid,const char* username, const char* password,uuid::uuid &authid, const std::string &ssid){
    libhttppp::HTTPException httpException;

    authdb::client::ClientConnection authcon;
    authcon.setUrl(_config.getAuthUrl());
    authcon.setClientName(_config.getClientName());
    authcon.setClientSecret(_config.getClientSecret());

    authdb::client::Client clt(authcon);
    if(!clt.ClientAuth())
        return;

    if(!clt.ClientAuth()){
        httpException[libhttppp::HTTPException::Error] << "ClientAuth failed!";
        throw httpException;
    }

    authcon.setUsername(username);
    authcon.setUserPassword(password);

    bool ret = clt.UserAuth();
    if(!ret)
        return;
    if(!ret) {
        httpException[libhttppp::HTTPException::Error] << "UserAuth failed (Invalid credentials)!";
        throw httpException;
    }

    try {
        ret = clt.GPOcheck("e7d3b8b3-4825-11f0-ae2b-3cecefce9cb6");

        if(ret){
            Session sess(*_dbconn[tid]);

            sess.addSessionData(ssid,"authid",authcon.getSessionID().c_str());

            class authdb::SessionData sdat;
        clt.SessionInfo(sdat);
            clt.SessionInfo(sdat); // Can throw AuthBackendError

            uuid::uuid uid;
            sdat.getUid(uid);
            sess.addSessionData(ssid,"uid",uid.c_str());

            authid = authcon.getSessionID();
        } else {
            clt.remSession();
            httpException[libhttppp::HTTPException::Error] << "User GPO check failed!";
            throw httpException;
        }
    } catch (authdb::AuthBackendError &e) {
        try {
            clt.remSession();
        } catch (authdb::AuthBackendError &cleanupE) {
        }

        httpException[libhttppp::HTTPException::Error] << "Authentication backend error: " << e.what();
        throw httpException;
    }
}

+0 −2
Changes for src/blogi.cpp: 0 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -196,8 +196,6 @@ void blogi::Blogi::loginPage(libhttppp::HttpRequest &curreq,const int tid,const
        }
    }

    std::cerr << username << ": " << password << std::endl;

    libhtmlpp::HtmlString out;

    libhtmlpp::HtmlElement index;