fix(wsgi+config): fault environment setup
chore: upgrade version
This commit is contained in:
parent
88851970d2
commit
fc367ed4cb
3 changed files with 15 additions and 6 deletions
|
|
@ -1,6 +1,6 @@
|
|||
[metadata]
|
||||
name = httpaste-victorykit
|
||||
version = 1.0.5-alpha
|
||||
version = 1.0.6-alpha
|
||||
author = Tiara Rodney
|
||||
author_email = t.rodney@victoryk.it
|
||||
description = a versatile HTTP pastebin
|
||||
|
|
|
|||
|
|
@ -143,6 +143,7 @@ from inspect import isclass
|
|||
from configparser import ConfigParser
|
||||
from ast import literal_eval
|
||||
from io import StringIO
|
||||
from os import environ
|
||||
|
||||
from connexion import FlaskApp
|
||||
from connexion.resolver import RestyResolver
|
||||
|
|
@ -158,7 +159,7 @@ from httpaste.helper.http import (
|
|||
UnauthorizedError)
|
||||
|
||||
|
||||
CONFIGPATH_ENVIRON = 'HTTPASTE_CONFIG'
|
||||
CONFIGPATH_ENVIRON = 'HTTPASTE_CONFIGPATH'
|
||||
|
||||
|
||||
def get_sanitized_config_charset(charset: str):
|
||||
|
|
@ -198,17 +199,17 @@ class ServerConfig:
|
|||
bind_address = None
|
||||
|
||||
|
||||
def get_config_path(environ: str = CONFIGPATH_ENVIRON):
|
||||
def get_config_path(var_name: str = CONFIGPATH_ENVIRON):
|
||||
"""
|
||||
"""
|
||||
|
||||
try:
|
||||
|
||||
return os.environ[environ]
|
||||
return environ[var_name]
|
||||
except KeyError as e:
|
||||
|
||||
raise ConfigError(
|
||||
'environment variable \'{environ}\' not set.') from e
|
||||
f'environment variable \'{var_name}\' not set.') from e
|
||||
|
||||
|
||||
def load_config(path: str) -> Tuple[Config, ServerConfig]:
|
||||
|
|
@ -322,6 +323,14 @@ def get_flask_app(
|
|||
with application.app.app_context():
|
||||
application.app.httpaste = config
|
||||
|
||||
#add header for browsers to present a sign-in prompt
|
||||
@application.app.after_request
|
||||
def rewrite_forbidden_request(response):
|
||||
|
||||
if response.status_code in [401]:
|
||||
response.headers['WWW-Authenticate'] = 'Basic realm="private"'
|
||||
return response
|
||||
|
||||
return application
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,6 @@
|
|||
"""
|
||||
from httpaste import load_config, get_flask_app, get_config_path
|
||||
|
||||
config, server_config = load_config(get_config_path)
|
||||
config, server_config = load_config(get_config_path())
|
||||
|
||||
application = get_flask_app(config, server_config)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue