133 'group': 'main', 'level': 3, |
133 'group': 'main', 'level': 3, |
134 }), |
134 }), |
135 ('https-deny-anonymous', |
135 ('https-deny-anonymous', |
136 {'type': 'yn', |
136 {'type': 'yn', |
137 'default': False, |
137 'default': False, |
138 'help': 'Prevent anonymous user to browse thought https version of ' |
138 'help': 'Prevent anonymous user to browse through https version of ' |
139 'the site (https-url). Login form will then be displayed ' |
139 'the site (https-url). Login form will then be displayed ' |
140 'until logged', |
140 'until logged', |
141 'group': 'web', |
141 'group': 'web', |
142 'level': 2 |
142 'level': 2 |
143 } |
143 } |
294 """ |
294 """ |
295 return str(uuid4()) |
295 return str(uuid4()) |
296 |
296 |
297 def sign_text(self, text): |
297 def sign_text(self, text): |
298 """sign some text for later checking""" |
298 """sign some text for later checking""" |
|
299 # hmac.new expect bytes |
|
300 if isinstance(text, unicode): |
|
301 text = text.encode('utf-8') |
299 # replace \r\n so we do not depend on whether a browser "reencode" |
302 # replace \r\n so we do not depend on whether a browser "reencode" |
300 # original message using \r\n or not |
303 # original message using \r\n or not |
301 return hmac.new(self._instance_salt, |
304 return hmac.new(self._instance_salt, |
302 text.strip().replace('\r\n', '\n')).hexdigest() |
305 text.strip().replace('\r\n', '\n')).hexdigest() |
303 |
306 |
304 def check_text_sign(self, text, signature): |
307 def check_text_sign(self, text, signature): |
305 """check the text signature is equal to the given signature""" |
308 """check the text signature is equal to the given signature""" |
306 return self.sign_text(text) == signature |
309 return self.sign_text(text) == signature |
307 |
|
308 |
310 |
309 def locate_resource(self, rid): |
311 def locate_resource(self, rid): |
310 """return the (directory, filename) where the given resource |
312 """return the (directory, filename) where the given resource |
311 may be found |
313 may be found |
312 """ |
314 """ |