diff options
author | Mårten Nordheim <marten.nordheim@qt.io> | 2020-09-04 19:57:19 +0200 |
---|---|---|
committer | Mårten Nordheim <marten.nordheim@qt.io> | 2020-09-10 19:23:17 +0200 |
commit | 219ed70957cc93640a79e1f8098987256efbe212 (patch) | |
tree | 273448666fa55a6fc677ac29071332c31d66f5b7 /src/network | |
parent | b41a7afb000bfd86eb98f1e9e1b2711d6c4fb104 (diff) |
QAuthenticator(Negotiate): Try provided credential
Windows only so far, need a similar patch for *nix, or an alternate
approach when there is no server set up.
Pick-to: 5.15
Task-number: QTBUG-85123
Change-Id: Iff7a6b1540a2f1984153a237eea07c7bb1970064
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/kernel/qauthenticator.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/network/kernel/qauthenticator.cpp b/src/network/kernel/qauthenticator.cpp index 1ac98602a2..45c8217701 100644 --- a/src/network/kernel/qauthenticator.cpp +++ b/src/network/kernel/qauthenticator.cpp @@ -1532,12 +1532,25 @@ static QByteArray qSspiStartup(QAuthenticatorPrivate *ctx, QAuthenticatorPrivate ctx->sspiWindowsHandles.reset(new QSSPIWindowsHandles); memset(&ctx->sspiWindowsHandles->credHandle, 0, sizeof(CredHandle)); + SEC_WINNT_AUTH_IDENTITY auth; + auth.Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE; + bool useAuth = false; + if (method == QAuthenticatorPrivate::Negotiate && !ctx->user.isEmpty()) { + auth.Domain = const_cast<ushort *>(ctx->userDomain.utf16()); + auth.DomainLength = ctx->userDomain.size(); + auth.User = const_cast<ushort *>(ctx->user.utf16()); + auth.UserLength = ctx->user.size(); + auth.Password = const_cast<ushort *>(ctx->password.utf16()); + auth.PasswordLength = ctx->password.size(); + useAuth = true; + } + // Acquire our credentials handle SECURITY_STATUS secStatus = pSecurityFunctionTable->AcquireCredentialsHandle( - nullptr, - (SEC_WCHAR*)(method == QAuthenticatorPrivate::Negotiate ? L"Negotiate" : L"NTLM"), - SECPKG_CRED_OUTBOUND, nullptr, nullptr, nullptr, nullptr, - &ctx->sspiWindowsHandles->credHandle, &expiry + nullptr, + (SEC_WCHAR *)(method == QAuthenticatorPrivate::Negotiate ? L"Negotiate" : L"NTLM"), + SECPKG_CRED_OUTBOUND, nullptr, useAuth ? &auth : nullptr, nullptr, nullptr, + &ctx->sspiWindowsHandles->credHandle, &expiry ); if (secStatus != SEC_E_OK) { ctx->sspiWindowsHandles.reset(nullptr); |