Merge remote-tracking branch 'opds-500-unauthenticated-request/fix/opds-500-unauthenticated-request'
This commit is contained in:
-12
@@ -140,7 +140,6 @@ def convert_to_kobo_timestamp_string(timestamp):
|
|||||||
|
|
||||||
@kobo.route("/v1/library/sync")
|
@kobo.route("/v1/library/sync")
|
||||||
@requires_kobo_auth
|
@requires_kobo_auth
|
||||||
# @limiter.limit("3/minute", key_func=get_remote_address)
|
|
||||||
def HandleSyncRequest():
|
def HandleSyncRequest():
|
||||||
if not current_user.role_download():
|
if not current_user.role_download():
|
||||||
log.info("Users need download permissions for syncing library to Kobo reader")
|
log.info("Users need download permissions for syncing library to Kobo reader")
|
||||||
@@ -336,7 +335,6 @@ def generate_sync_response(sync_token, sync_results, set_cont=False):
|
|||||||
@kobo.route("/v1/library/<book_uuid>/metadata")
|
@kobo.route("/v1/library/<book_uuid>/metadata")
|
||||||
@requires_kobo_auth
|
@requires_kobo_auth
|
||||||
@download_required
|
@download_required
|
||||||
# @limiter.limit("3/minute", key_func=get_remote_address)
|
|
||||||
def HandleMetadataRequest(book_uuid):
|
def HandleMetadataRequest(book_uuid):
|
||||||
if not current_app.wsgi_app.is_proxied:
|
if not current_app.wsgi_app.is_proxied:
|
||||||
log.debug('Kobo: Received unproxied request, changed request port to external server port')
|
log.debug('Kobo: Received unproxied request, changed request port to external server port')
|
||||||
@@ -508,7 +506,6 @@ def get_metadata(book):
|
|||||||
@csrf.exempt
|
@csrf.exempt
|
||||||
@kobo.route("/v1/library/tags", methods=["POST", "DELETE"])
|
@kobo.route("/v1/library/tags", methods=["POST", "DELETE"])
|
||||||
@requires_kobo_auth
|
@requires_kobo_auth
|
||||||
# @limiter.limit("3/minute", key_func=get_remote_address)
|
|
||||||
# Creates a Shelf with the given items, and returns the shelf's uuid.
|
# Creates a Shelf with the given items, and returns the shelf's uuid.
|
||||||
def HandleTagCreate():
|
def HandleTagCreate():
|
||||||
# catch delete requests, otherwise they are handled in the book delete handler
|
# catch delete requests, otherwise they are handled in the book delete handler
|
||||||
@@ -544,7 +541,6 @@ def HandleTagCreate():
|
|||||||
@csrf.exempt
|
@csrf.exempt
|
||||||
@kobo.route("/v1/library/tags/<tag_id>", methods=["DELETE", "PUT"])
|
@kobo.route("/v1/library/tags/<tag_id>", methods=["DELETE", "PUT"])
|
||||||
@requires_kobo_auth
|
@requires_kobo_auth
|
||||||
# @limiter.limit("3/minute", key_func=get_remote_address)
|
|
||||||
def HandleTagUpdate(tag_id):
|
def HandleTagUpdate(tag_id):
|
||||||
shelf = ub.session.query(ub.Shelf).filter(ub.Shelf.uuid == tag_id,
|
shelf = ub.session.query(ub.Shelf).filter(ub.Shelf.uuid == tag_id,
|
||||||
ub.Shelf.user_id == current_user.id).one_or_none()
|
ub.Shelf.user_id == current_user.id).one_or_none()
|
||||||
@@ -599,7 +595,6 @@ def add_items_to_shelf(items, shelf):
|
|||||||
@csrf.exempt
|
@csrf.exempt
|
||||||
@kobo.route("/v1/library/tags/<tag_id>/items", methods=["POST"])
|
@kobo.route("/v1/library/tags/<tag_id>/items", methods=["POST"])
|
||||||
@requires_kobo_auth
|
@requires_kobo_auth
|
||||||
# @limiter.limit("3/minute", key_func=get_remote_address)
|
|
||||||
def HandleTagAddItem(tag_id):
|
def HandleTagAddItem(tag_id):
|
||||||
items = None
|
items = None
|
||||||
try:
|
try:
|
||||||
@@ -630,7 +625,6 @@ def HandleTagAddItem(tag_id):
|
|||||||
@csrf.exempt
|
@csrf.exempt
|
||||||
@kobo.route("/v1/library/tags/<tag_id>/items/delete", methods=["POST"])
|
@kobo.route("/v1/library/tags/<tag_id>/items/delete", methods=["POST"])
|
||||||
@requires_kobo_auth
|
@requires_kobo_auth
|
||||||
# @limiter.limit("3/minute", key_func=get_remote_address)
|
|
||||||
def HandleTagRemoveItem(tag_id):
|
def HandleTagRemoveItem(tag_id):
|
||||||
items = None
|
items = None
|
||||||
try:
|
try:
|
||||||
@@ -764,7 +758,6 @@ def create_kobo_tag(shelf):
|
|||||||
@csrf.exempt
|
@csrf.exempt
|
||||||
@kobo.route("/v1/library/<book_uuid>/state", methods=["GET", "PUT"])
|
@kobo.route("/v1/library/<book_uuid>/state", methods=["GET", "PUT"])
|
||||||
@requires_kobo_auth
|
@requires_kobo_auth
|
||||||
# @limiter.limit("3/minute", key_func=get_remote_address)
|
|
||||||
def HandleStateRequest(book_uuid):
|
def HandleStateRequest(book_uuid):
|
||||||
book = calibre_db.get_book_by_uuid(book_uuid)
|
book = calibre_db.get_book_by_uuid(book_uuid)
|
||||||
if not book or not book.data:
|
if not book or not book.data:
|
||||||
@@ -921,7 +914,6 @@ def get_current_bookmark_response(current_bookmark):
|
|||||||
@kobo.route("/<book_uuid>/<width>/<height>/<isGreyscale>/image.jpg", defaults={'Quality': ""})
|
@kobo.route("/<book_uuid>/<width>/<height>/<isGreyscale>/image.jpg", defaults={'Quality': ""})
|
||||||
@kobo.route("/<book_uuid>/<width>/<height>/<Quality>/<isGreyscale>/image.jpg")
|
@kobo.route("/<book_uuid>/<width>/<height>/<Quality>/<isGreyscale>/image.jpg")
|
||||||
@requires_kobo_auth
|
@requires_kobo_auth
|
||||||
# @limiter.limit("3/minute", key_func=get_remote_address)
|
|
||||||
def HandleCoverImageRequest(book_uuid, width, height, Quality, isGreyscale):
|
def HandleCoverImageRequest(book_uuid, width, height, Quality, isGreyscale):
|
||||||
try:
|
try:
|
||||||
if int(height) > 1000:
|
if int(height) > 1000:
|
||||||
@@ -958,7 +950,6 @@ def TopLevelEndpoint():
|
|||||||
@csrf.exempt
|
@csrf.exempt
|
||||||
@kobo.route("/v1/library/<book_uuid>", methods=["DELETE"])
|
@kobo.route("/v1/library/<book_uuid>", methods=["DELETE"])
|
||||||
@requires_kobo_auth
|
@requires_kobo_auth
|
||||||
# @limiter.limit("3/minute", key_func=get_remote_address)
|
|
||||||
def HandleBookDeletionRequest(book_uuid):
|
def HandleBookDeletionRequest(book_uuid):
|
||||||
log.info("Kobo book delete request received for book %s" % book_uuid)
|
log.info("Kobo book delete request received for book %s" % book_uuid)
|
||||||
book = calibre_db.get_book_by_uuid(book_uuid)
|
book = calibre_db.get_book_by_uuid(book_uuid)
|
||||||
@@ -1069,7 +1060,6 @@ def make_calibre_web_auth_response():
|
|||||||
@kobo.route("/v1/auth/refresh", methods=["POST"])
|
@kobo.route("/v1/auth/refresh", methods=["POST"])
|
||||||
@kobo.route("/v1/auth/device", methods=["POST"])
|
@kobo.route("/v1/auth/device", methods=["POST"])
|
||||||
@requires_kobo_auth
|
@requires_kobo_auth
|
||||||
# @limiter.limit("3/minute", key_func=get_remote_address)
|
|
||||||
def HandleAuthRequest():
|
def HandleAuthRequest():
|
||||||
log.error(limiter.current_limit)
|
log.error(limiter.current_limit)
|
||||||
log.error(limiter.current_limit)
|
log.error(limiter.current_limit)
|
||||||
@@ -1084,7 +1074,6 @@ def HandleAuthRequest():
|
|||||||
|
|
||||||
@kobo.route("/v1/initialization")
|
@kobo.route("/v1/initialization")
|
||||||
@requires_kobo_auth
|
@requires_kobo_auth
|
||||||
# @limiter.limit("3/minute", key_func=get_remote_address)
|
|
||||||
def HandleInitRequest():
|
def HandleInitRequest():
|
||||||
log.info('Init')
|
log.info('Init')
|
||||||
|
|
||||||
@@ -1160,7 +1149,6 @@ def HandleInitRequest():
|
|||||||
@kobo.route("/download/<book_id>/<book_format>")
|
@kobo.route("/download/<book_id>/<book_format>")
|
||||||
@requires_kobo_auth
|
@requires_kobo_auth
|
||||||
@download_required
|
@download_required
|
||||||
# @limiter.limit("3/minute", key_func=get_remote_address)
|
|
||||||
def download_book(book_id, book_format):
|
def download_book(book_id, book_format):
|
||||||
return get_download_link(book_id, book_format, "kobo")
|
return get_download_link(book_id, book_format, "kobo")
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -24,7 +24,7 @@ from flask import request
|
|||||||
|
|
||||||
|
|
||||||
def request_username():
|
def request_username():
|
||||||
return request.authorization.username
|
return request.authorization.username if request.authorization else ""
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|||||||
Reference in New Issue
Block a user