Skip to content

Commit

Permalink
fix(sspi): only add password and domain if they are provided
Browse files Browse the repository at this point in the history
Users on windows may want to use their local account for
authentication, bypassing the need to send a password. In these
cases the password must be null, but we were sending a single
byte, null-terminated string here because of the use of
`std::string`.

NODE-1479
  • Loading branch information
mbroadst committed Oct 30, 2018
1 parent 187aab7 commit bc48814
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/win32/kerberos_sspi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,16 @@ auth_sspi_client_init(WCHAR* service,
if (*user) {
authIdentity.User = (unsigned short*)user;
authIdentity.UserLength = ulen;
authIdentity.Password = (unsigned short*)password;
authIdentity.PasswordLength = plen;
authIdentity.Domain = (unsigned short*)domain;
authIdentity.DomainLength = dlen;

if (*password) {
authIdentity.Password = (unsigned short*)password;
authIdentity.PasswordLength = plen;
}

if (*domain) {
authIdentity.Domain = (unsigned short*)domain;
authIdentity.DomainLength = dlen;
}

authIdentity.Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;
}
Expand Down

0 comments on commit bc48814

Please sign in to comment.