diff --git a/magneticow/magneticow/__main__.py b/magneticow/magneticow/__main__.py index dd0f777..369032c 100644 --- a/magneticow/magneticow/__main__.py +++ b/magneticow/magneticow/__main__.py @@ -75,8 +75,15 @@ def parse_args() -> argparse.Namespace: "--port", action="store", type=int, required=True, help="the port number magneticow web server should listen on" ) - parser.add_argument( - "--user", action="append", nargs=2, metavar=("USERNAME", "PASSWORD"), type=str, required=True, + + auth_group = parser.add_mutually_exclusive_group(required=True) + + auth_group.add_argument( + "--no-auth", dest='noauth', action="store_true", default=False, + help="make the web interface available without authentication" + ) + auth_group.add_argument( + "--user", action="append", nargs=2, metavar=("USERNAME", "PASSWORD"), type=str, help="the pair(s) of username and password for basic HTTP authentication" ) diff --git a/magneticow/magneticow/authorization.py b/magneticow/magneticow/authorization.py index 519bfb4..ac9bf97 100644 --- a/magneticow/magneticow/authorization.py +++ b/magneticow/magneticow/authorization.py @@ -45,8 +45,9 @@ def requires_auth(f): @functools.wraps(f) def decorated(*args, **kwargs): auth = flask.request.authorization - if not auth or not is_authorized(auth.username, auth.password): - return authenticate() + if not flask.current_app.arguments.noauth: + if not auth or not is_authorized(auth.username, auth.password): + return authenticate() return f(*args, **kwargs) return decorated # END OF THE 3RD PARTY COPYRIGHTED CONTENT