mirror of
https://github.com/morpheus65535/bazarr
synced 2025-02-13 09:45:26 +00:00
Moving UI API key authentication to X-Api-Key header.
This commit is contained in:
parent
138af20bb6
commit
bb38d5397c
2 changed files with 5 additions and 9 deletions
|
@ -54,8 +54,11 @@ def authenticate(actual_method):
|
||||||
apikey_settings = settings.auth.apikey
|
apikey_settings = settings.auth.apikey
|
||||||
apikey_get = request.args.get('apikey')
|
apikey_get = request.args.get('apikey')
|
||||||
apikey_post = request.form.get('apikey')
|
apikey_post = request.form.get('apikey')
|
||||||
|
apikey_header = None
|
||||||
|
if 'X-Api-Key' in request.headers:
|
||||||
|
apikey_header = request.headers['X-Api-Key']
|
||||||
|
|
||||||
if apikey_settings in [apikey_get, apikey_post]:
|
if apikey_settings in [apikey_get, apikey_post, apikey_header]:
|
||||||
return actual_method(*args, **kwargs)
|
return actual_method(*args, **kwargs)
|
||||||
|
|
||||||
return abort(401, message="Unauthorized")
|
return abort(401, message="Unauthorized")
|
||||||
|
|
|
@ -495,14 +495,7 @@
|
||||||
|
|
||||||
// Add apikey to all AJAX requests.
|
// Add apikey to all AJAX requests.
|
||||||
$.ajaxSetup({
|
$.ajaxSetup({
|
||||||
data: {
|
headers: { 'X-Api-Key': "{{ settings.auth.apikey }}" }
|
||||||
apikey: "{{ settings.auth.apikey }}"
|
|
||||||
}
|
|
||||||
});
|
|
||||||
$.ajaxPrefilter(function (options, originalOptions, jqXHR) {
|
|
||||||
if (originalOptions.data instanceof FormData) {
|
|
||||||
originalOptions.data.append("apikey", "{{ settings.auth.apikey }}");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$(window).on('beforeunload', function () {
|
$(window).on('beforeunload', function () {
|
||||||
|
|
Loading…
Reference in a new issue