diff --git a/cps/oauth_bb.py b/cps/oauth_bb.py index 0a897fc7..7ec813bd 100644 --- a/cps/oauth_bb.py +++ b/cps/oauth_bb.py @@ -30,8 +30,9 @@ from flask_dance.consumer import oauth_authorized, oauth_error from flask_dance.contrib.github import make_github_blueprint, github from flask_dance.contrib.google import make_google_blueprint, google from oauthlib.oauth2 import TokenExpiredError, InvalidGrantError -from .cw_login import login_user, current_user, login_required +from .cw_login import login_user, current_user from sqlalchemy.orm.exc import NoResultFound +from .usermanagement import user_login_required from . import constants, logger, config, app, ub diff --git a/cps/opds.py b/cps/opds.py index 34c12885..3d8c78b9 100644 --- a/cps/opds.py +++ b/cps/opds.py @@ -129,8 +129,7 @@ def feed_best_rated(): @opds.route("/opds/hot") -#@requires_basic_auth_if_no_ano -@auth.login_required +@requires_basic_auth_if_no_ano def feed_hot(): if not auth.current_user().check_visibility(constants.SIDEBAR_HOT): abort(404) @@ -154,8 +153,7 @@ def feed_hot(): @opds.route("/opds/author") -#@requires_basic_auth_if_no_ano -@auth.login_required +@requires_basic_auth_if_no_ano def feed_authorindex(): if not auth.current_user().check_visibility(constants.SIDEBAR_AUTHOR): abort(404) @@ -163,8 +161,7 @@ def feed_authorindex(): @opds.route("/opds/author/letter/") -#@requires_basic_auth_if_no_ano -@auth.login_required +@requires_basic_auth_if_no_ano def feed_letter_author(book_id): if not auth.current_user().check_visibility(constants.SIDEBAR_AUTHOR): abort(404) diff --git a/cps/ub.py b/cps/ub.py index 6048c462..70f0dd16 100644 --- a/cps/ub.py +++ b/cps/ub.py @@ -574,6 +574,21 @@ def add_missing_tables(engine, _session): Thumbnail.__table__.create(bind=engine) +# migrate all settings missing in registration table +def migrate_registration_table(engine, _session): + try: + # Handle table exists, but no content + cnt = _session.query(Registration).count() + if not cnt: + with engine.connect() as conn: + trans = conn.begin() + conn.execute(text("insert into registration (domain, allow) values('%.%',1)")) + trans.commit() + except exc.OperationalError: # Database is not writeable + print('Settings database is not writeable. Exiting...') + sys.exit(2) + + def migrate_user_session_table(engine, _session): try: _session.query(exists().where(User_Sessions.random)).scalar() @@ -592,6 +607,7 @@ def migrate_user_session_table(engine, _session): def migrate_Database(_session): engine = _session.bind add_missing_tables(engine, _session) + migrate_registration_table(engine, _session) migrate_user_session_table(engine, _session) @@ -603,6 +619,7 @@ def clean_database(_session): _session.commit() + # Save downloaded books per user in calibre-web's own database def update_download(book_id, user_id): check = session.query(Downloads).filter(Downloads.user_id == user_id).filter(Downloads.book_id == book_id).first() diff --git a/cps/usermanagement.py b/cps/usermanagement.py index 5295fe41..e42f70f0 100644 --- a/cps/usermanagement.py +++ b/cps/usermanagement.py @@ -40,6 +40,7 @@ def verify_password(username, password): if user.name.lower() == "guest": if config.config_anonbrowse == 1: return user + limiter.check() if config.config_login_type == constants.LOGIN_LDAP and services.ldap: login_result, error = services.ldap.bind_user(user.name, password) if login_result: @@ -89,8 +90,6 @@ def login_required_if_no_ano(func): if user: g.flask_httpauth_user = user return func(*args, **kwargs) - # proxy_auth.set_user(user) - # return proxy_auth.login_required(func)(*args, **kwargs) g.flask_httpauth_user = None if config.config_anonbrowse == 1: return func(*args, **kwargs) @@ -127,8 +126,6 @@ def load_user_from_reverse_proxy_header(req): @lm.user_loader def load_user(user_id, random, session_key): - # log.info(f"user {user_id}, random {random}") - # log.info(request) user = ub.session.query(ub.User).filter(ub.User.id == int(user_id)).first() if random and session_key: entry = ub.session.query(ub.User_Sessions).filter(ub.User_Sessions.random == random, diff --git a/test/Calibre-Web TestSummary_Linux.html b/test/Calibre-Web TestSummary_Linux.html index 042bdb8d..ae5d4d36 100644 --- a/test/Calibre-Web TestSummary_Linux.html +++ b/test/Calibre-Web TestSummary_Linux.html @@ -37,20 +37,20 @@
-

Start Time: 2024-07-09 19:39:05

+

Start Time: 2024-07-14 21:21:23

-

Stop Time: 2024-07-10 13:56:20

+

Stop Time: 2024-07-15 02:27:32

-

Duration: 17h 7 min

+

Duration: 4h 2 min

@@ -234,11 +234,11 @@ - + TestBackupMetadata 21 - 20 - 1 + 21 + 0 0 0 @@ -374,31 +374,11 @@ - +
TestBackupMetadata - test_backup_change_custom_categories
- -
- FAIL -
- - - - + PASS @@ -482,11 +462,11 @@ AssertionError: ['Kulo', 'Smudo'] != None - + TestCli 13 - 13 - 0 + 12 + 1 0 0 @@ -595,11 +575,31 @@ AssertionError: ['Kulo', 'Smudo'] != None - +
TestCli - test_settingsdb_not_writeable
- PASS + +
+ FAIL +
+ + + + @@ -722,286 +722,57 @@ AssertionError: ['Kulo', 'Smudo'] != None - + TestEbookConvertCalibre - 18 - 9 - 1 - 8 + 15 + 15 + 0 + 0 0 - Detail + Detail - +
TestEbookConvertCalibre - test_calibre_log
- -
- ERROR -
- - - - + PASS - - -
TestEbookConvertCalibre - test_calibre_log
- - -
- ERROR -
- - - - - - - - - +
TestEbookConvertCalibre - test_convert_deactivate
- -
- ERROR -
- - - - + PASS - - -
TestEbookConvertCalibre - test_convert_deactivate
- - -
- ERROR -
- - - - - - - - - +
TestEbookConvertCalibre - test_convert_email
- -
- ERROR -
- - - - + PASS - - -
TestEbookConvertCalibre - test_convert_email
- - -
- ERROR -
- - - - - - - - - +
TestEbookConvertCalibre - test_convert_failed_and_email
- -
- ERROR -
- - - - + PASS - +
TestEbookConvertCalibre - test_convert_only
@@ -1010,37 +781,16 @@ ValueError: not enough values to unpack (expected 2, got 1) - +
TestEbookConvertCalibre - test_convert_options
- -
- FAIL -
- - - - + PASS - +
TestEbookConvertCalibre - test_convert_parameter
@@ -1049,7 +799,7 @@ AssertionError: Items in the first set but not the second: - +
TestEbookConvertCalibre - test_convert_wrong_excecutable
@@ -1058,7 +808,7 @@ AssertionError: Items in the first set but not the second: - +
TestEbookConvertCalibre - test_convert_xss
@@ -1067,7 +817,7 @@ AssertionError: Items in the first set but not the second: - +
TestEbookConvertCalibre - test_email_failed
@@ -1076,36 +826,16 @@ AssertionError: Items in the first set but not the second: - +
TestEbookConvertCalibre - test_email_only
- -
- ERROR -
- - - - + PASS - +
TestEbookConvertCalibre - test_kindle_send_not_configured
@@ -1114,7 +844,7 @@ ValueError: too many values to unpack (expected 2) - +
TestEbookConvertCalibre - test_ssl_smtp_setup_error
@@ -1123,7 +853,7 @@ ValueError: too many values to unpack (expected 2) - +
TestEbookConvertCalibre - test_starttls_smtp_setup_error
@@ -1132,7 +862,7 @@ ValueError: too many values to unpack (expected 2) - +
TestEbookConvertCalibre - test_user_convert_xss
@@ -1142,1276 +872,79 @@ ValueError: too many values to unpack (expected 2) - + TestEbookConvertCalibreGDrive - 14 + 7 + 7 + 0 0 - 1 - 13 0 - Detail + Detail - +
TestEbookConvertCalibreGDrive - test_convert_email
- -
- ERROR -
- - - - + PASS - - -
TestEbookConvertCalibreGDrive - test_convert_email
- - -
- ERROR -
- - - - - - - - - +
TestEbookConvertCalibreGDrive - test_convert_failed_and_email
- -
- ERROR -
- - - - + PASS - - -
TestEbookConvertCalibreGDrive - test_convert_failed_and_email
- - -
- ERROR -
- - - - - - - - - +
TestEbookConvertCalibreGDrive - test_convert_only
- -
- ERROR -
- - - - + PASS - - -
TestEbookConvertCalibreGDrive - test_convert_only
- - -
- ERROR -
- - - - - - - - - +
TestEbookConvertCalibreGDrive - test_convert_parameter
- -
- ERROR -
- - - - + PASS - - -
TestEbookConvertCalibreGDrive - test_convert_parameter
- - -
- ERROR -
- - - - - - - - - +
TestEbookConvertCalibreGDrive - test_email_failed
- -
- ERROR -
- - - - + PASS - - -
TestEbookConvertCalibreGDrive - test_email_failed
- - -
- ERROR -
- - - - - - - - - +
TestEbookConvertCalibreGDrive - test_email_only
- -
- ERROR -
- - - - + PASS - - -
TestEbookConvertCalibreGDrive - test_email_only
- - -
- ERROR -
- - - - - - - - - +
TestEbookConvertCalibreGDrive - test_thumbnail_cache
- -
- FAIL -
- - - - - - - - - - -
TestEbookConvertCalibreGDrive - test_thumbnail_cache
- - -
- ERROR -
- - - - + PASS @@ -3106,13 +1639,13 @@ urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', p TestEditAuthors - 9 - 9 + 8 + 8 0 0 0 - Detail + Detail @@ -3174,7 +1707,7 @@ urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', p -
TestEditAuthors - test_rename_author_emphasis_mark_onupload
+
TestEditAuthors - test_rename_author_accent_onupload
PASS @@ -3189,15 +1722,6 @@ urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', p - - - -
TestEditAuthors - test_rename_tag_emphasis_mark_onupload
- - PASS - - - @@ -3709,13 +2233,13 @@ IndexError: list index out of range - + TestSTARTTLS 3 - 0 - 0 3 0 + 0 + 0 Detail @@ -3723,141 +2247,40 @@ IndexError: list index out of range - +
TestSTARTTLS - test_STARTTLS
- -
- ERROR -
- - - - + PASS - +
TestSTARTTLS - test_STARTTLS_SSL_setup_error
- -
- ERROR -
- - - - + PASS - +
TestSTARTTLS - test_STARTTLS_resend_password
- -
- ERROR -
- - - - + PASS - + TestSSL 7 - 2 - 1 - 4 + 7 + 0 + 0 0 Detail @@ -3884,186 +2307,47 @@ dom.find/</<@chrome://remote/content/shared/DOM.sys.mjs:136:16 - +
TestSSL - test_SSL_logging_email
- -
- FAIL -
- - - - + PASS - +
TestSSL - test_SSL_non_admin_user
- -
- ERROR -
- - - - + PASS - +
TestSSL - test_SSL_only
- -
- ERROR -
- - - - + PASS - +
TestSSL - test_email_limit
- -
- ERROR -
- - - - + PASS - +
TestSSL - test_filepicker_two_file
- -
- ERROR -
- - - - + PASS @@ -4695,11 +2979,11 @@ IndexError: list index out of range - + TestSecurity 5 - 5 - 0 + 3 + 2 0 0 @@ -4718,11 +3002,31 @@ IndexError: list index out of range - +
TestSecurity - test_opds_limit
- PASS + +
+ FAIL +
+ + + + @@ -4745,11 +3049,1593 @@ IndexError: list index out of range - +
TestSecurity - test_register_limit
- PASS + +
+ FAIL +
+ + + + + + + + + + + _ErrorHolder + 18 + 0 + 0 + 18 + 0 + + Detail + + + + + + + +
tearDownClass (test_limiter)
+ + +
+ ERROR +
+ + + + + + + + + + +
tearDownClass (test_oauth)
+ + +
+ ERROR +
+ + + + + + + + + + +
setUpClass (test_opds_feed)
+ + +
+ ERROR +
+ + + + + + + + + + +
tearDownClass (test_pdf_metadata)
+ + +
+ ERROR +
+ + + + + + + + + + +
tearDownClass (test_reader)
+ + +
+ ERROR +
+ + + + + + + + + + +
tearDownClass (test_readonly_db)
+ + +
+ ERROR +
+ + + + + + + + + + +
tearDownClass (test_register)
+ + +
+ ERROR +
+ + + + + + + + + + +
tearDownClass (test_reverse_proxy)
+ + +
+ ERROR +
+ + + + + + + + + + +
tearDownClass (test_shelf)
+ + +
+ ERROR +
+ + + + + + + + + + +
tearDownClass (test_split_library)
+ + +
+ ERROR +
+ + + + + + + + + + +
tearDownClass (test_thumbnail_env)
+ + +
+ ERROR +
+ + + + + + + + + + +
tearDownClass (test_thumbnails)
+ + +
+ ERROR +
+ + + + + + + + + + +
setUpClass (test_updater)
+ + +
+ ERROR +
+ + + + + + + + + + +
tearDownClass (test_upload_epubs)
+ + +
+ ERROR +
+ + + + + + + + + + +
tearDownClass (test_user_list)
+ + +
+ ERROR +
+ + + + + + + + + + +
tearDownClass (test_user_load)
+ + +
+ ERROR +
+ + + + + + + + + + +
tearDownClass (test_user_template)
+ + +
+ ERROR +
+ + + + + + + + + + +
tearDownClass (test_visiblilitys)
+ + +
+ ERROR +
+ + + + @@ -4763,13 +4649,13 @@ IndexError: list index out of range 0 0 - Detail + Detail - +
TestCalibreWebListOrders - test_author_sort
@@ -4778,7 +4664,7 @@ IndexError: list index out of range - +
TestCalibreWebListOrders - test_download_sort
@@ -4787,7 +4673,7 @@ IndexError: list index out of range - +
TestCalibreWebListOrders - test_format_sort
@@ -4796,7 +4682,7 @@ IndexError: list index out of range - +
TestCalibreWebListOrders - test_formats_click_none
@@ -4805,7 +4691,7 @@ IndexError: list index out of range - +
TestCalibreWebListOrders - test_lang_sort
@@ -4814,7 +4700,7 @@ IndexError: list index out of range - +
TestCalibreWebListOrders - test_language_click_none
@@ -4823,7 +4709,7 @@ IndexError: list index out of range - +
TestCalibreWebListOrders - test_order_authors_all_links
@@ -4832,7 +4718,7 @@ IndexError: list index out of range - +
TestCalibreWebListOrders - test_order_series_all_links
@@ -4841,7 +4727,7 @@ IndexError: list index out of range - +
TestCalibreWebListOrders - test_publisher_click_none
@@ -4850,7 +4736,7 @@ IndexError: list index out of range - +
TestCalibreWebListOrders - test_publisher_sort
@@ -4859,7 +4745,7 @@ IndexError: list index out of range - +
TestCalibreWebListOrders - test_ratings_click_none
@@ -4868,7 +4754,7 @@ IndexError: list index out of range - +
TestCalibreWebListOrders - test_ratings_sort
@@ -4877,7 +4763,7 @@ IndexError: list index out of range - +
TestCalibreWebListOrders - test_series_click_none
@@ -4886,7 +4772,7 @@ IndexError: list index out of range - +
TestCalibreWebListOrders - test_series_sort
@@ -4895,7 +4781,7 @@ IndexError: list index out of range - +
TestCalibreWebListOrders - test_tags_click_none
@@ -4904,7 +4790,7 @@ IndexError: list index out of range - +
TestCalibreWebListOrders - test_tags_sort
@@ -4922,13 +4808,13 @@ IndexError: list index out of range 0 1 - Detail + Detail - +
TestLogging - test_access_log_recover
@@ -4937,7 +4823,7 @@ IndexError: list index out of range - +
TestLogging - test_debug_log
@@ -4946,7 +4832,7 @@ IndexError: list index out of range - +
TestLogging - test_debuginfo_download
@@ -4955,7 +4841,7 @@ IndexError: list index out of range - +
TestLogging - test_failed_login
@@ -4964,19 +4850,19 @@ IndexError: list index out of range - +
TestLogging - test_failed_register
- SKIP + SKIP
-