Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def post(self):
client_id = self.get_argument("client")
channels = self.get_arguments("channels")
logging.info("{0} wants to subscribe on {1}".format(client_id, ", ".join(channels)))
to_return = {}
for channel in channels:
info = json.dumps({
'channel_extra_info_example': 'you can add additional JSON data when authorizing'
})
to_return[channel] = {
"sign": generate_channel_sign(options.project_secret, client_id, channel, info=info),
"info": info
}
# but here we allow to join any private channel and return additional
# JSON info specific for channel
self.set_header('Content-Type', 'application/json; charset="utf-8"')
self.write(json.dumps(to_return))
def signed_response(channel, client):
signature = generate_channel_sign(SECRET_KEY, client, channel, info="")
return {"sign": signature}