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

Bind cache entries also contain the app marker now #24

Merged
merged 1 commit into from
Jun 29, 2017

Conversation

fredreichbier
Copy link
Contributor

This makes it impossible to abuse the bind cache
to authenticate to another app using the same credentials.

Closes #20

This makes it impossible to abuse the bind cache
to authenticate to another app using the same credentials.

Closes #20
@fredreichbier
Copy link
Contributor Author

This also fixes another potential issue:
Prior to this commit, Bind requests which were handled by the bind cache were automatically authenticated as the service user in any case (not respecting the bind-service-account config option).

if self.factory.bind_service_account:
yield self.bind_service_account()
self.bound = True
if self.factory.is_bind_cached(request.dn, app_marker, request.auth):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is potentially inefficient because it resolves the username in any case before checking if the (DN, app marker, password) tuple is contained in the bind cache.
But this is also a security feature if the user was removed in the meantime :)

Copy link
Member

Choose a reason for hiding this comment

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

I think some people, who optimze away all ldap requests will not like this.
May be we can make this configurable - one day (undocumented) ;-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess so! :) I opened #25 to keep track of that.

self._cache = {}

def add_to_cache(self, dn, password):
def add_to_cache(self, dn, app_marker, password):
Copy link
Member

Choose a reason for hiding this comment

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

What is good pythonian?
Would we one day define a cacheObject instead of a tuple, which has the attributes

  • dn
  • app_markes
  • password

and then define comparison methods?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, good question! I'd probably go for something like def add_to_cache(self, cache_object, password), where cache_object=(dn, app_marker). Simply because it is no problem to print cache_object to the log, whereas we should never print password to the log :)

if self.factory.bind_service_account:
yield self.bind_service_account()
self.bound = True
if self.factory.is_bind_cached(request.dn, app_marker, request.auth):
Copy link
Member

Choose a reason for hiding this comment

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

I think some people, who optimze away all ldap requests will not like this.
May be we can make this configurable - one day (undocumented) ;-)

@fredreichbier fredreichbier merged commit 8fb6049 into master Jun 29, 2017
@fredreichbier fredreichbier deleted the 20/cache-app-marker branch June 29, 2017 17:32
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