Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-domain logins for Windows Desktop #51275

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

probakowski
Copy link
Contributor

@probakowski probakowski commented Jan 20, 2025

This change allows users to login to Windows desktop using multiple different domains as long as the trust is setup between them and LDAP returns proper referrals for the other domain.
If you have domain1 configured in Teleport and domain2 that domain1 trusts then loggins as user1 will be treated as user1@domain1, and user1@domain1 and user2@domain2 will use users from respective domains (and still log you in to the requested desktop in the domain1).

changelog: Add multi-domain logins for Windows Desktop

lib/auth/windows/ldap.go Outdated Show resolved Hide resolved
lib/auth/windows/ldap.go Show resolved Hide resolved
lib/auth/windows/ldap.go Show resolved Hide resolved
lib/auth/windows/ldap.go Outdated Show resolved Hide resolved
@@ -591,6 +594,7 @@ func (s *WindowsService) initializeLDAP() error {
}

conn.SetTimeout(ldapRequestTimeout)
s.lc.SetConnectionCreator(createLDAPConnection)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need this connection creator thing? (Instead of just using ldap.Dial directly)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We set up TLS here but we create new connection inside ldap.ReadWithFilter (when we get new referral to check in the response). This way we have factory for these connection with certificates and so on

Copy link
Contributor

Choose a reason for hiding this comment

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

AFAICT it's called only in WindowsService.initializeLDAP, so is SetClient. Feels like s.lc could be created here instead and then we could avoid those setters and mutex. LDAPConfig is available in s.cfg.LDAPConfig anyway. Chances are I'm missing something here.

@probakowski probakowski requested a review from zmb3 January 21, 2025 21:42
@@ -244,6 +244,8 @@ require (
software.sslmate.com/src/go-pkcs12 v0.5.0
)

require github.com/go-asn1-ber/asn1-ber v1.5.7
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps should be included in the require block above.

Comment on lines +283 to +286
var ldapErr *ldap.Error
if !errors.As(err, &ldapErr) {
return nil, trace.Wrap(err, "fetching LDAP object %q with filter %q", dn, filter)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it would be cleaner to do this check inside extractReferrals, so we'd avoid writing the error string twice.

@@ -327,7 +333,7 @@ var EnhancedKeyUsageExtension = pkix.Extension{
}

// SubjectAltNameExtension fills in the SAN for a Windows certificate
func SubjectAltNameExtension(user, domain string) (pkix.Extension, error) {
func SubjectAltNameExtension(userPrincipalName string) (pkix.Extension, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason this isn't private?

@@ -591,6 +594,7 @@ func (s *WindowsService) initializeLDAP() error {
}

conn.SetTimeout(ldapRequestTimeout)
s.lc.SetConnectionCreator(createLDAPConnection)
Copy link
Contributor

Choose a reason for hiding this comment

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

AFAICT it's called only in WindowsService.initializeLDAP, so is SetClient. Feels like s.lc could be created here instead and then we could avoid those setters and mutex. LDAPConfig is available in s.cfg.LDAPConfig anyway. Chances are I'm missing something here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants