def validate_headers(headers, secret_filename): headers = dict((key.lower(), val) for key, val in headers.items() if key.lower().startswith("x-opencore")) hash = headers.pop("x-opencore-validation-key", None) if hash is None: return None _headers = sorted(headers.items()) _headers = "&".join("=".join((key, val)) for key, val in _headers) secret = get_secret(secret_filename) if generate_cookie_value(_headers, secret) != hash: return False return True
def build_headers(project, application, environment, object, author, notification_list_address, secret_filename): headers = [ ("X-Opencore-Project", project), ("X-Opencore-Application", application), ("X-Opencore-Application-Environment", environment), ("X-Opencore-Object-Id", object), ("X-Opencore-Initiated-By", author), ("X-Opencore-Do-Not-Send-To", author), ("X-Opencore-Send-From", notification_list_address), ] _headers = sorted(headers) _headers = "&".join("=".join((key.lower(), val)) for key, val in _headers) secret = get_secret(secret_filename) hash = generate_cookie_value(_headers, secret) headers.append(("X-Opencore-Validation-Key", hash)) return sorted(headers)
team = app.unrestrictedTraverse(team_path) active_states=team.getActiveStates() mship_brains = cat(highestTeamRole='ProjectAdmin', portal_type='OpenMembership', path=team_path, review_state=active_states, ) for mbrain in mship_brains: if mbrain.highestTeamRole == 'ProjectAdmin': mem = portal.acl_users.getUser(mbrain.getId) if not mem: continue mem = mem.__of__(portal.acl_users) print "Setting user to %s" % mbrain.getId newSecurityManager(None, mem) cookie = generate_cookie_value(mbrain.getId, SECRET) break else: print "couldn't find suitable admin user for %s" % proj_id print "Exporting %s..." % proj_id status = get_status(proj_id, context_url='/'.join([BASEURL, proj_id]), cookie=cookie) path = qview.export(proj_id, status) print "Exported %s" % path print "=" * 60
active_states=team.getActiveStates() mship_brains = cat(highestTeamRole='ProjectAdmin', portal_type='OpenMembership', path=team_path, review_state=active_states, ) for mbrain in mship_brains: if mbrain.highestTeamRole == 'ProjectAdmin': mem = portal.acl_users.getUser(mbrain.getId) if not mem: continue mem = mem.__of__(portal.acl_users) print "Setting user to %s" % mbrain.getId newSecurityManager(None, mem) cookie = generate_cookie_value(mbrain.getId, SECRET) break else: print "couldn't find suitable admin user for %s" % proj_id cookie = generate_cookie_value("admin", SECRET) print "Exporting %s..." % proj_id status = get_status(proj_id, context_url='/'.join([BASEURL, proj_id]), cookie=cookie, features=["wikipages", "mailinglists", "wikihistory"]) path = qview.export(proj_id, status) print "Exported %s" % path print "=" * 60