Skip to content

Commit

Permalink
Merge pull request #24 from zopefoundation/1801-remove-setAuthCookie
Browse files Browse the repository at this point in the history
re Plone #1801: Refactoring to simplify overriding ``updateCredentials``
  • Loading branch information
dataflake committed Oct 3, 2018
2 parents 67ecbdd + b3926ce commit 9d5829e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Change Log
------------------
- Add new event to be able to notify group creation.

- Refactoring to make it easier to override ``updateCredentials``.


2.0b1 (2018-05-18)
------------------
Expand Down
9 changes: 7 additions & 2 deletions Products/PluggableAuthService/plugins/CookieAuthHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,18 @@ def challenge(self, request, response, **kw):
return self.unauthorized()

@security.private
def updateCredentials(self, request, response, login, new_password):
""" Respond to change of credentials (NOOP for basic auth). """
def get_cookie_value(self, login, new_password):
cookie_str = b':'.join([
hexlify(login.encode('utf-8')),
hexlify(new_password.encode('utf-8'))])
cookie_val = encodestring(cookie_str)
cookie_val = cookie_val.rstrip()
return cookie_val

@security.private
def updateCredentials(self, request, response, login, new_password):
""" Respond to change of credentials (NOOP for basic auth). """
cookie_val = self.get_cookie_value(login, new_password)
response.setCookie(self.cookie_name, quote(cookie_val), path='/')

@security.private
Expand Down

0 comments on commit 9d5829e

Please sign in to comment.