1.1 --- a/ApproveChangesSupport.py Tue Oct 11 01:20:51 2011 +0200
1.2 +++ b/ApproveChangesSupport.py Wed Oct 12 00:04:21 2011 +0200
1.3 @@ -17,14 +17,6 @@
1.4
1.5 from MoinMoin import user
1.6 import re
1.7 -import base64
1.8 -import md5
1.9 -import hmac
1.10 -
1.11 -try:
1.12 - from hashlib import sha1
1.13 -except ImportError:
1.14 - from sha import new as sha1
1.15
1.16 acl_pattern = re.compile(ur"^#acl .*$", re.UNICODE | re.MULTILINE)
1.17
1.18 @@ -55,6 +47,9 @@
1.19 request.dicts.has_member(get_approved_editors_group(request), request.user.name) or \
1.20 request.user.isSuperUser())
1.21
1.22 +def is_queued_changes_user(request):
1.23 + return request.user.valid and request.user.name == get_queued_changes_user(request)
1.24 +
1.25 def is_queued_changes_page(request, pagename):
1.26
1.27 "Return whether 'pagename' is a queued changes page by testing its name."
1.28 @@ -108,8 +103,8 @@
1.29
1.30 # Add the ACL.
1.31
1.32 - parts.insert(0, "#acl %s:read,write,delete,revert,admin %s:write All:\n" % (
1.33 - get_page_reviewers_group(request), get_queued_changes_user(request)))
1.34 + parts.insert(0, "#acl %s:read,write,delete,revert,admin All:\n" %
1.35 + get_page_reviewers_group(request))
1.36 return "".join(parts)
1.37
1.38 def remove_access_control(request, body):
1.39 @@ -127,45 +122,6 @@
1.40
1.41 return body
1.42
1.43 -def get_page_signature(request, body):
1.44 -
1.45 - """
1.46 - Using the 'request', return a signature/digest for the given page 'body'
1.47 - using a secret known only by the server.
1.48 - """
1.49 -
1.50 - secret_key = get_secret_key(request)
1.51 - hash = hmac.new(secret_key, body.encode("utf-8"), sha1)
1.52 - return base64.standard_b64encode(hash.digest())
1.53 -
1.54 -def sign_page(request, body):
1.55 -
1.56 - """
1.57 - Using the 'request', sign the page 'body' using a secret known only by the
1.58 - server.
1.59 - """
1.60 -
1.61 - return "#signature %s\n%s" % (get_page_signature(request, body), body)
1.62 -
1.63 -def check_page(request, body):
1.64 -
1.65 - """
1.66 - Using the 'request', find and check the signature in the page 'body',
1.67 - returning the original page or None (if no valid signature is found).
1.68 - """
1.69 -
1.70 - lines = body.split("\n")
1.71 - body = "\n".join(lines[1:])
1.72 -
1.73 - try:
1.74 - directive, signature = lines[0].split()
1.75 - if directive == "#signature" and signature == get_page_signature(request, body):
1.76 - return body
1.77 - except ValueError:
1.78 - pass
1.79 -
1.80 - return None
1.81 -
1.82 # Utility classes and associated functions.
1.83 # NOTE: These are a subset of EventAggregatorSupport.
1.84