mirror of
https://github.com/janeczku/calibre-web
synced 2024-12-26 01:50:31 +00:00
add basic auth for feed sites
This commit is contained in:
parent
f66d7ce29b
commit
8f4c444929
17
cps/web.py
17
cps/web.py
@ -96,10 +96,11 @@ def authenticate():
|
|||||||
'You have to login with proper credentials', 401,
|
'You have to login with proper credentials', 401,
|
||||||
{'WWW-Authenticate': 'Basic realm="Login Required"'})
|
{'WWW-Authenticate': 'Basic realm="Login Required"'})
|
||||||
|
|
||||||
def requires_basic_auth(f):
|
def requires_basic_auth_if_no_ano(f):
|
||||||
@wraps(f)
|
@wraps(f)
|
||||||
def decorated(*args, **kwargs):
|
def decorated(*args, **kwargs):
|
||||||
auth = request.authorization
|
auth = request.authorization
|
||||||
|
if config.ANO_SHOW_BOOKS != 1:
|
||||||
if not auth or not check_auth(auth.username, auth.password):
|
if not auth or not check_auth(auth.username, auth.password):
|
||||||
return authenticate()
|
return authenticate()
|
||||||
return f(*args, **kwargs)
|
return f(*args, **kwargs)
|
||||||
@ -201,7 +202,7 @@ def before_request():
|
|||||||
g.allow_upload = config.UPLOADING
|
g.allow_upload = config.UPLOADING
|
||||||
|
|
||||||
@app.route("/feed")
|
@app.route("/feed")
|
||||||
@login_required_if_no_ano
|
@requires_basic_auth_if_no_ano
|
||||||
def feed_index():
|
def feed_index():
|
||||||
xml = render_template('index.xml')
|
xml = render_template('index.xml')
|
||||||
response= make_response(xml)
|
response= make_response(xml)
|
||||||
@ -209,7 +210,7 @@ def feed_index():
|
|||||||
return response
|
return response
|
||||||
|
|
||||||
@app.route("/feed/osd")
|
@app.route("/feed/osd")
|
||||||
@login_required_if_no_ano
|
@requires_basic_auth_if_no_ano
|
||||||
def feed_osd():
|
def feed_osd():
|
||||||
xml = render_template('osd.xml')
|
xml = render_template('osd.xml')
|
||||||
response= make_response(xml)
|
response= make_response(xml)
|
||||||
@ -217,7 +218,7 @@ def feed_osd():
|
|||||||
return response
|
return response
|
||||||
|
|
||||||
@app.route("/feed/search", methods=["GET"])
|
@app.route("/feed/search", methods=["GET"])
|
||||||
@login_required_if_no_ano
|
@requires_basic_auth_if_no_ano
|
||||||
def feed_search():
|
def feed_search():
|
||||||
term = request.args.get("query")
|
term = request.args.get("query")
|
||||||
if term:
|
if term:
|
||||||
@ -231,7 +232,7 @@ def feed_search():
|
|||||||
return response
|
return response
|
||||||
|
|
||||||
@app.route("/feed/new")
|
@app.route("/feed/new")
|
||||||
@login_required_if_no_ano
|
@requires_basic_auth_if_no_ano
|
||||||
def feed_new():
|
def feed_new():
|
||||||
off = request.args.get("start_index")
|
off = request.args.get("start_index")
|
||||||
if off:
|
if off:
|
||||||
@ -246,7 +247,7 @@ def feed_new():
|
|||||||
|
|
||||||
|
|
||||||
@app.route("/feed/discover")
|
@app.route("/feed/discover")
|
||||||
@login_required_if_no_ano
|
@requires_basic_auth_if_no_ano
|
||||||
def feed_discover():
|
def feed_discover():
|
||||||
off = request.args.get("start_index")
|
off = request.args.get("start_index")
|
||||||
if off:
|
if off:
|
||||||
@ -260,7 +261,7 @@ def feed_discover():
|
|||||||
return response
|
return response
|
||||||
|
|
||||||
@app.route("/feed/hot")
|
@app.route("/feed/hot")
|
||||||
@login_required_if_no_ano
|
@requires_basic_auth_if_no_ano
|
||||||
def feed_hot():
|
def feed_hot():
|
||||||
off = request.args.get("start_index")
|
off = request.args.get("start_index")
|
||||||
if off:
|
if off:
|
||||||
@ -275,7 +276,7 @@ def feed_hot():
|
|||||||
return response
|
return response
|
||||||
|
|
||||||
@app.route("/feed/download/<int:book_id>/<format>")
|
@app.route("/feed/download/<int:book_id>/<format>")
|
||||||
@login_required
|
@requires_basic_auth_if_no_ano
|
||||||
@download_required
|
@download_required
|
||||||
def get_opds_download_link(book_id, format):
|
def get_opds_download_link(book_id, format):
|
||||||
format = format.split(".")[0]
|
format = format.split(".")[0]
|
||||||
|
Loading…
Reference in New Issue
Block a user