mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2024-12-18 08:27:03 +02:00
Encode secret
This commit is contained in:
parent
8e85c04558
commit
c827d442ec
@ -402,7 +402,7 @@ def create_app(args):
|
|||||||
response = Response(render_template("app.js.template",
|
response = Response(render_template("app.js.template",
|
||||||
url_prefix=args.url_prefix,
|
url_prefix=args.url_prefix,
|
||||||
get_api_key_link=args.get_api_key_link,
|
get_api_key_link=args.get_api_key_link,
|
||||||
api_secret=secret.get_current_secret() if args.require_api_key_secret else ""), content_type='application/javascript; charset=utf-8')
|
api_secret=secret.get_current_secret_b64() if args.require_api_key_secret else ""), content_type='application/javascript; charset=utf-8')
|
||||||
|
|
||||||
if args.require_api_key_secret:
|
if args.require_api_key_secret:
|
||||||
response.headers['Last-Modified'] = http_date(datetime.now())
|
response.headers['Last-Modified'] = http_date(datetime.now())
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import base64
|
||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
|
|
||||||
@ -21,6 +22,9 @@ def secret_match(secret):
|
|||||||
def get_current_secret():
|
def get_current_secret():
|
||||||
return get_storage().get_str("secret_1")
|
return get_storage().get_str("secret_1")
|
||||||
|
|
||||||
|
def get_current_secret_b64():
|
||||||
|
return base64.b64encode(get_current_secret().encode("utf-8")).decode("utf-8")
|
||||||
|
|
||||||
def setup(args):
|
def setup(args):
|
||||||
if args.api_keys and args.require_api_key_secret:
|
if args.api_keys and args.require_api_key_secret:
|
||||||
s = get_storage()
|
s = get_storage()
|
||||||
|
@ -41,7 +41,7 @@ document.addEventListener('DOMContentLoaded', function(){
|
|||||||
filesTranslation: true,
|
filesTranslation: true,
|
||||||
frontendTimeout: 500,
|
frontendTimeout: 500,
|
||||||
|
|
||||||
apiSecret: "{{ api_secret }}"
|
apiSecret: atob("{{ api_secret }}")
|
||||||
},
|
},
|
||||||
mounted: function() {
|
mounted: function() {
|
||||||
const self = this;
|
const self = this;
|
||||||
|
Loading…
Reference in New Issue
Block a user