Skip to content

avoid duplicating ldaptor code in LDAPServerWithUPNBind#161

Open
graingert wants to merge 4 commits intotwisted:masterfrom
graingert:patch-1
Open

avoid duplicating ldaptor code in LDAPServerWithUPNBind#161
graingert wants to merge 4 commits intotwisted:masterfrom
graingert:patch-1

Conversation

@graingert
Copy link
Copy Markdown
Member

@graingert graingert commented Feb 18, 2020

Contributor Checklist:

  • I have updated the release notes at docs/source/NEWS.rst
  • I have updated the automated tests.
  • All tests pass on your local dev environment. See CONTRIBUTING.rst.

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 18, 2020

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.35%. Comparing base (c0bdfda) to head (e42ede9).
⚠️ Report is 217 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #161   +/-   ##
=======================================
  Coverage   93.35%   93.35%           
=======================================
  Files          72       72           
  Lines        9914     9914           
  Branches      972      972           
=======================================
  Hits         9255     9255           
  Misses        537      537           
  Partials      122      122           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@adiroiban
Copy link
Copy Markdown
Member

Thanks for the cleanup.
@graingert let us know when you think this is ready for review :)

@graingert
Copy link
Copy Markdown
Member Author

@adiroiban I think it's ready to go

Comment on lines +37 to +39
def _request():
if not (b"@" in request.dn and b"," not in request.dn):
defer.returnValue(request)
Copy link
Copy Markdown
Member

@adiroiban adiroiban Feb 26, 2020

Choose a reason for hiding this comment

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

Maybe something like this

Suggested change
def _request():
if not (b"@" in request.dn and b"," not in request.dn):
defer.returnValue(request)
def _resolveUPNBindDN():
"""
See if we have an MS UPN style BIND DN request and resolve it to the
actual LDAP BindDN.
UPN bind is in the form of User.Name@ad.example.tld
"""
if b"@" not in request.dn or b"," in request.dn:
# This is not an UPN bind request.
defer.returnValue(request)

if not (b"@" in request.dn and b"," not in request.dn):
defer.returnValue(request)
root = interfaces.IConnectedLDAPEntry(self.factory)
# This might be an UPN request.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
# This might be an UPN request.
# The the LDAP DN associated with the UPN request.

Comment on lines +44 to +45
if len(results) != 1:
defer.returnValue(request)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
if len(results) != 1:
defer.returnValue(request)
if len(results) != 1:
# We could not find an exact UPN match so we go with the
# requested Bind DN.
defer.returnValue(request)

Copy link
Copy Markdown
Member

@adiroiban adiroiban left a comment

Choose a reason for hiding this comment

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

Thanks for the cleanup.

Please see my comments.

Even thou I wrote this code a few months ago, I feel that it needs more documentation.
With the current version, at the first read it was hard to understand what is going on there and why we have all that logic.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants