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

avoid duplicating ldaptor code in LDAPServerWithUPNBind #161

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

Conversation

graingert
Copy link
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

codecov bot commented Feb 18, 2020

Codecov Report

Merging #161 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #161      +/-   ##
==========================================
- Coverage   93.35%   93.35%   -0.01%     
==========================================
  Files          72       72              
  Lines        9915     9914       -1     
  Branches      973      972       -1     
==========================================
- Hits         9256     9255       -1     
  Misses        537      537              
  Partials      122      122
Impacted Files Coverage Δ
ldaptor/protocols/ldap/ldapserver.py 80.45% <100%> (-0.07%) ⬇️
ldaptor/test/test_server.py 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7c6f5c3...e42ede9. Read the comment docs.

@adiroiban
Copy link
Member

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

@graingert
Copy link
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
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)

def _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
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
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
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