Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removes API keys from source code. They are now fetched at runtime from
the server.
- Loading branch information
1 parent
58a887a
commit 74eff44
Showing
6 changed files
with
69 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env python | ||
import rsa | ||
import base64 | ||
from flask import Flask, request, jsonify | ||
|
||
KEYS = dict( | ||
LASTFM_API_KEY="REDACTED", | ||
LASTFM_API_SECRET="READACTED", | ||
GOOGLE_DEVELOPER_KEY="READACTED", | ||
) | ||
|
||
app = Flask(__name__) | ||
|
||
|
||
@app.route("/", methods=["POST"]) | ||
def submit_person(): | ||
req_data = request.json | ||
pub_key = rsa.PublicKey.load_pkcs1(req_data["public_key"]) | ||
keys = {} | ||
for id_ in req_data["ids"]: | ||
crypt_bytes = rsa.encrypt(KEYS[id_].encode(), pub_key) | ||
b64_utf = base64.encodebytes(crypt_bytes).decode() | ||
keys[id_] = b64_utf | ||
return jsonify(keys) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
requests | ||
rsa>=4.0 | ||
requests>=2.21.0 | ||
gmusicapi==11.0.0 | ||
urwid==2.0.1 | ||
pyYAML>=4.2b1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,22 @@ | ||
def sec_to_min_sec(sec_tot): | ||
s = int(sec_tot or 0) | ||
return s // 60, s % 60 | ||
|
||
|
||
def lookup_keys(*key_ids): | ||
import rsa | ||
import base64 | ||
import requests | ||
|
||
(pub, priv) = rsa.newkeys(512) | ||
|
||
host = "https://tuijam.fangmeier.tech" | ||
|
||
res = requests.post( | ||
host, json={"public_key": pub.save_pkcs1().decode(), "ids": key_ids} | ||
) | ||
|
||
keys = [] | ||
for id_, key_enc in res.json().items(): | ||
keys.append(rsa.decrypt(base64.decodebytes(key_enc.encode()), priv).decode()) | ||
return keys |