Fix: ALTCHA secret key not found.
This commit is contained in:
7
app.py
7
app.py
@@ -48,13 +48,6 @@ app.config.from_object(app_config) # for db init with required keys
|
|||||||
app.app_config = app_config
|
app.app_config = app_config
|
||||||
# app.config["config"] = app_config()
|
# app.config["config"] = app_config()
|
||||||
|
|
||||||
print('sql vars')
|
|
||||||
print(app.config['DB_PASSWORD'])
|
|
||||||
print(app.config['DB_USER'])
|
|
||||||
print(app.config['SQLALCHEMY_DATABASE_URI'])
|
|
||||||
print(app.config['SECRET_KEY'])
|
|
||||||
print(os.getenv('KEY_SECRET_FLASK'))
|
|
||||||
|
|
||||||
# logging
|
# logging
|
||||||
handler = RotatingFileHandler('app.log', maxBytes=10000, backupCount=3)
|
handler = RotatingFileHandler('app.log', maxBytes=10000, backupCount=3)
|
||||||
handler.setLevel(logging.DEBUG)
|
handler.setLevel(logging.DEBUG)
|
||||||
|
|||||||
@@ -86,11 +86,11 @@ def contact_post():
|
|||||||
|
|
||||||
@routes_core.route(Model_View_Contact.HASH_ALTCHA_CREATE_CHALLENGE, methods=['GET'])
|
@routes_core.route(Model_View_Contact.HASH_ALTCHA_CREATE_CHALLENGE, methods=['GET'])
|
||||||
def create_altcha_challenge():
|
def create_altcha_challenge():
|
||||||
Helper_App.console_log(f'secret key: {current_app.config["ALTCHA_SECRET_KEY"]}')
|
Helper_App.console_log(f'secret key: {current_app.app_config["ALTCHA_SECRET_KEY"]}')
|
||||||
options = ChallengeOptions(
|
options = ChallengeOptions(
|
||||||
expires = datetime.datetime.now() + datetime.timedelta(hours=1),
|
expires = datetime.datetime.now() + datetime.timedelta(hours=1),
|
||||||
max_number = 100000, # The maximum random number
|
max_number = 100000, # The maximum random number
|
||||||
hmac_key = current_app.config["ALTCHA_SECRET_KEY"],
|
hmac_key = current_app.app_config["ALTCHA_SECRET_KEY"],
|
||||||
)
|
)
|
||||||
challenge = create_challenge(options)
|
challenge = create_challenge(options)
|
||||||
print("Challenge created:", challenge)
|
print("Challenge created:", challenge)
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ class ALTCHAValidator:
|
|||||||
decoded_data = base64.b64decode(altcha_data).decode('utf-8')
|
decoded_data = base64.b64decode(altcha_data).decode('utf-8')
|
||||||
altcha_payload = json.loads(decoded_data)
|
altcha_payload = json.loads(decoded_data)
|
||||||
|
|
||||||
ok, err = verify_solution(altcha_payload, current_app.config["ALTCHA_SECRET_KEY"], check_expires=True)
|
ok, err = verify_solution(altcha_payload, current_app.app_config["ALTCHA_SECRET_KEY"], check_expires=True)
|
||||||
|
|
||||||
if err or not ok:
|
if err or not ok:
|
||||||
raise ValidationError(self.message + ': ' + (err or 'Invalid solution'))
|
raise ValidationError(self.message + ': ' + (err or 'Invalid solution'))
|
||||||
|
|||||||
Reference in New Issue
Block a user