def gh_oauth(): args = bottle.request.query if 'code' not in args or 'r' not in args: raise bottle.HTTPError(404, 'Missing arguments') response = requests.post('https://github.com/login/oauth/access_token', data={'client_id': cfg.github.oauth.client_id, 'client_secret': cfg.github.oauth.client_secret, 'code': args['code']}, headers={'Accept': 'application/json'}).json() if 'access_token' not in response: raise bottle.HTTPError(403, 'No response token from GitHub') token = utils.encrypt_data(response['access_token'].encode('ascii'), cfg.github.oauth.client_secret) scope = utils.encrypt_data(response['scope'].encode('ascii'), cfg.github.oauth.client_secret) bottle.response.set_cookie('gh_oauth_token', token, secure=True, httponly=True, path='/', secret=cfg.github.oauth.client_secret) bottle.response.set_cookie('gh_oauth_scope', scope, secure=True, httponly=True, path='/', secret=cfg.github.oauth.client_secret) bottle.redirect(args['r'])
def gh_oauth(): args = bottle.request.query if "code" not in args or "r" not in args: raise bottle.HTTPError(404, "Missing arguments") response = requests.post( "https://github.com/login/oauth/access_token", data={ "client_id": cfg.github.oauth.client_id, "client_secret": cfg.github.oauth.client_secret, "code": args["code"], }, headers={"Accept": "application/json"}, ).json() if "access_token" not in response: raise bottle.HTTPError(403, "No response token from GitHub") token = utils.encrypt_data(response["access_token"].encode("ascii"), cfg.github.oauth.client_secret) scope = utils.encrypt_data(response["scope"].encode("ascii"), cfg.github.oauth.client_secret) bottle.response.set_cookie( "gh_oauth_token", token, secure=True, httponly=True, path="/", secret=cfg.github.oauth.client_secret ) bottle.response.set_cookie( "gh_oauth_scope", scope, secure=True, httponly=True, path="/", secret=cfg.github.oauth.client_secret ) bottle.redirect(args["r"])
def send(self, sock, key, addr): """Creates a binary blob to send over the wire and then sends it encrypted""" p = pack("!h", len(self.user_id)) p += self.user_id p += pack("!I", int(self.timestamp.strftime("%s"))) p = pack("!b", CLI_AUTH) + encrypt_data(p, key) sock.sendto(p, addr)
def send(self, sock, key, addr): """Creates a binary blob to send over the wire and then sends it encrypted""" p = pack("!h", len(self.tgs_id)) p += str(self.tgs_id) p += pack("!I", int(self.valid_until.strftime("%s"))) p += pack("!I", int(self.timestamp.strftime("%s"))) p += self.session_key p = pack("!b", TGS_SESS_KEY) + encrypt_data(p, key) sock.sendto(p, addr)
def send(self, sock, key, addr): """Creates a binary blob to send over the wire and then sends it encrypted""" p = pack("!h", len(self.client_id)) p += self.client_id p += pack("!h", len(self.svc_id)) p += self.svc_id p += socket.inet_aton(self.net_addr) p = str(p) p += pack("!I", int(self.valid_until.strftime("%s"))) p += pack("!I", int(self.timestamp.strftime("%s"))) p += self.session_key p = pack("!b", SVC_TKT_RESP) + encrypt_data(p, key) sock.sendto(p, addr)