Skip to content

Commit

Permalink
feat(credssp): add Negotiate server support
Browse files Browse the repository at this point in the history
Auth identity not required for inbound use. Also fix an error message
Pku2u vs Ntlm.

This is required for IronRDP#558.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
  • Loading branch information
elmarco authored and CBenoit committed Oct 24, 2024
1 parent b015d4d commit d38a106
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
12 changes: 3 additions & 9 deletions src/credssp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,15 +441,9 @@ impl<C: CredentialsProxy<AuthenticationData = AuthIdentity>> CredSspServer<C> {
.take()
.expect("CredSsp client mode should never be empty")
{
ClientMode::Negotiate(_) => {
return Err(ServerError {
ts_request,
error: crate::Error::new(
ErrorKind::UnsupportedFunction,
"Negotiate module is not supported for the CredSsp server",
),
})
}
ClientMode::Negotiate(neg_config) => Some(CredSspContext::new(SspiContext::Negotiate(
try_cred_ssp_server!(Negotiate::new(neg_config), ts_request),
))),
ClientMode::Kerberos(kerberos_config) => Some(CredSspContext::new(SspiContext::Kerberos(
try_cred_ssp_server!(Kerberos::new_server_from_config(kerberos_config), ts_request),
))),
Expand Down
18 changes: 11 additions & 7 deletions src/negotiate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,15 +421,19 @@ impl SspiImpl for Negotiate {
kerberos.acquire_credentials_handle_impl(builder)?;
}
NegotiatedProtocol::Ntlm(ntlm) => {
let auth_identity = if let Some(Credentials::AuthIdentity(identity)) = builder.auth_data {
identity
let auth_identity = if builder.credential_use == CredentialUse::Outbound {
if let Some(Credentials::AuthIdentity(identity)) = builder.auth_data {
Some(identity)
} else {
return Err(Error::new(
ErrorKind::NoCredentials,
"Auth identity is not provided for the Ntlm",
));
}
} else {
return Err(Error::new(
ErrorKind::NoCredentials,
"Auth identity is not provided for the Pku2u",
));
None
};
let new_builder = builder.full_transform(Some(auth_identity));
let new_builder = builder.full_transform(auth_identity);
new_builder.execute(ntlm)?;
}
};
Expand Down

0 comments on commit d38a106

Please sign in to comment.