Add user information for aws authenticator

This commit is contained in:
Simon Stürz 2018-08-16 20:03:38 +02:00
parent da1d43a0c3
commit e9ff550e1c
6 changed files with 24 additions and 8 deletions

View File

@ -1,6 +1,5 @@
#include "authenticationprocess.h"
#include "loggingcategories.h"
#include "userinformation.h"
#include <QUrl>
#include <QFile>
@ -163,7 +162,7 @@ void AuthenticationProcess::onProcessFinished(int exitCode, QProcess::ExitStatus
UserInformation userInformation(email, cognitoUsername, vendorId, userPoolId);
emit authenticationFinished(Authenticator::AuthenticationErrorNoError);
emit authenticationFinished(Authenticator::AuthenticationErrorNoError, userInformation);
} else {
emit authenticationFinished(Authenticator::AuthenticationErrorAuthenticationFailed);
}

View File

@ -7,6 +7,7 @@
#include <QNetworkAccessManager>
#include "authenticator.h"
#include "userinformation.h"
namespace remoteproxy {
@ -37,7 +38,7 @@ private:
void cleanUp();
signals:
void authenticationFinished(Authenticator::AuthenticationError error);
void authenticationFinished(Authenticator::AuthenticationError error, const UserInformation &userInformation = UserInformation());
private slots:
void onDynamicCredentialsReady();

View File

@ -22,20 +22,24 @@ QString AwsAuthenticator::name() const
return "AWS authenticator";
}
void AwsAuthenticator::onAuthenticationProcessFinished(Authenticator::AuthenticationError error)
void AwsAuthenticator::onAuthenticationProcessFinished(Authenticator::AuthenticationError error, const UserInformation &userInformation)
{
AuthenticationProcess *process = static_cast<AuthenticationProcess *>(sender());
AuthenticationReply *reply = m_runningProcesses.take(process);
if (error == AuthenticationErrorNoError) {
qCDebug(dcAuthentication()) << name() << reply->proxyClient() << "finished successfully." << userInformation;
} else {
qCDebug(dcAuthentication()) << name() << reply->proxyClient() << "finished with error" << error;
}
setReplyError(reply, error);
setReplyFinished(reply);
qCDebug(dcAuthentication()) << name() << "finished with error" << error;
}
AuthenticationReply *AwsAuthenticator::authenticate(ProxyClient *proxyClient)
{
qCDebug(dcAuthentication()) << name() << "Start authenticating" << proxyClient << "using token" << proxyClient->token();
qCDebug(dcAuthentication()) << name() << "Start authenticating" << proxyClient;
AuthenticationReply *reply = createAuthenticationReply(proxyClient, this);
AuthenticationProcess *process = new AuthenticationProcess(m_manager, this);

View File

@ -24,7 +24,7 @@ private:
QHash<AuthenticationProcess *, AuthenticationReply *> m_runningProcesses;
private slots:
void onAuthenticationProcessFinished(Authenticator::AuthenticationError error);
void onAuthenticationProcessFinished(Authenticator::AuthenticationError error, const UserInformation &userInformation);
public slots:
AuthenticationReply *authenticate(ProxyClient *proxyClient) override;

View File

@ -39,4 +39,13 @@ bool UserInformation::isValid()
&& !m_userPoolId.isEmpty();
}
QDebug operator<<(QDebug debug, const UserInformation &userInformation)
{
debug.nospace() << "UserInformation(" << userInformation.email();
debug.nospace() << ", cognito:" << userInformation.cognitoUsername() << ") ";
debug.nospace() << ", vendor" << userInformation.vendorId() << ") ";
debug.nospace() << ", userpool" << userInformation.userPoolId() << ") ";
return debug;
}
}

View File

@ -1,6 +1,7 @@
#ifndef USERINFORMATION_H
#define USERINFORMATION_H
#include <QDebug>
#include <QString>
namespace remoteproxy {
@ -25,6 +26,8 @@ private:
QString m_userPoolId;
};
QDebug operator<<(QDebug debug, const UserInformation &userInformation);
}
#endif // USERINFORMATION_H