Skip to content

feat(server): add CredentialValidator trait for server-side auth#1172

Open
Greg Lamberson (glamberson) wants to merge 2 commits intoDevolutions:masterfrom
lamco-admin:feat/credential-validator
Open

feat(server): add CredentialValidator trait for server-side auth#1172
Greg Lamberson (glamberson) wants to merge 2 commits intoDevolutions:masterfrom
lamco-admin:feat/credential-validator

Conversation

@glamberson
Copy link
Contributor

Closes #1154

Summary

Add a CredentialValidator trait that lets servers validate client
credentials during connection setup, after the acceptor extracts them
from ClientInfoPdu (enabled by #1155).

This follows up on the API discussion in #1150: Option
is the wrong type to carry security policy. The trait makes auth an
explicit, application-supplied component rather than an implicit
builder default.

What it does

  • CredentialValidator trait with validate(&self, &Credentials) -> Result
  • RdpServer::set_credential_validator() to wire it in
  • Validation runs in client_accepted() before session start
  • No validator configured = no credential check (existing behavior)
  • Validator configured but no credentials received = connection rejected

Design

For TLS-only connections, Client Info credentials are the only
credentials the application layer receives (no CredSSP). This trait
gives server implementations a clean hook to validate them against
PAM, LDAP, databases, or any external system.

Not used for CredSSP/Hybrid connections, where authentication happens
during the NTLM challenge-response exchange before ClientInfoPdu.

Example

struct PamValidator;

impl CredentialValidator for PamValidator {
    fn validate(&self, creds: &Credentials) -> Result<bool> {
        pam_authenticate(&creds.username, &creds.password)
    }
}

server.set_credential_validator(Arc::new(PamValidator));

Test plan

  • cargo check -p ironrdp-server
  • cargo clippy -p ironrdp-server -- -D warnings
  • cargo xtask check fmt/lints/tests/typos/locks (all pass)
  • Existing tests pass (trait is additive, no behavior change without opt-in)

Add a CredentialValidator trait that allows servers to validate
client credentials during connection setup. Called after the
acceptor phase extracts credentials from ClientInfoPdu.

This enables PAM, LDAP, and other validate-on-receipt auth flows
for TLS-mode connections. Not used for CredSSP/Hybrid connections
which handle authentication through NTLM challenge-response.

- Add CredentialValidator trait with validate() method
- Add set_credential_validator() to RdpServer
- Validate credentials in client_accepted() before session start
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a server-side hook to validate client-supplied credentials (from ClientInfoPdu) during connection setup, enabling external authentication backends (PAM/LDAP/DB) in ironrdp-server.

Changes:

  • Introduces a new public CredentialValidator trait.
  • Adds an optional validator to RdpServer with a setter API.
  • Invokes credential validation in client_accepted before entering the session loop.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

- Skip validation when credentials are None (reactivation, CredSSP)
  instead of bailing, consistent with Devolutions#1150/Devolutions#1155 design
- Remove username from log messages to avoid leaking sensitive data
- Keep validator error details in structured tracing field only
- Add spawn_blocking guidance to trait doc for blocking backends
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Support server-side credential validation (e.g. PAM) via CredentialValidator trait

2 participants