jamescalam commited on
Commit
2335e48
1 Parent(s): 3f30e0e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -13
app.py CHANGED
@@ -3,23 +3,20 @@ import torch
3
  import io
4
  from PIL import Image
5
  import os
 
6
  from google.cloud import storage
7
  import pinecone
8
  import json
9
 
10
- # create Storage Cloud credentials
11
- G_API = {
12
- "type": os.environ["type"],
13
- "project_id": os.environ["project_id"],
14
- "private_key_id": os.environ["private_key_id"],
15
- "private_key": os.environ["private_key"],
16
- "client_email": os.environ["client_email"],
17
- "client_id": os.environ["client_id"],
18
- "auth_uri": os.environ["auth_uri"],
19
- "token_uri": os.environ["token_uri"],
20
- "auth_provider_x509_cert_url": os.environ["auth_provider_x509_cert_url"],
21
- "client_x509_cert_url": os.environ["client_x509_cert_url"]
22
- }
23
  with open('cloud-storage.json', 'w') as fp:
24
  fp.write(json.dumps(G_API, indent=4))
25
  del G_API
 
3
  import io
4
  from PIL import Image
5
  import os
6
+ from cryptography.fernet import Fernet
7
  from google.cloud import storage
8
  import pinecone
9
  import json
10
 
11
+ # decrypt Storage Cloud credentials
12
+ fernet = Fernet(os.environ['DECRYPTION_KEY'])
13
+
14
+ with open('cloud-storage.encrypted', 'rb') as fp:
15
+ encrypted = fp.read()
16
+ creds = json.loads(fernet.decrypt(encrypted).decode())
17
+ # then save creds to file
18
+ with open('cloud-storage.json', 'w', encoding='utf-8') as fp:
19
+ fp.write(json.dumps(creds, indent=4))
 
 
 
 
20
  with open('cloud-storage.json', 'w') as fp:
21
  fp.write(json.dumps(G_API, indent=4))
22
  del G_API