mirror of
https://github.com/Screenly/Anthias.git
synced 2026-05-04 05:13:23 -04:00
don't require basic auth if login or password does not configured
This commit is contained in:
22
server.py
22
server.py
@@ -17,7 +17,7 @@ import os
|
||||
import traceback
|
||||
import uuid
|
||||
|
||||
from bottle import route, run, request, error, static_file, response, auth_basic
|
||||
from bottle import route, run, request, error, static_file, response
|
||||
from bottle import HTTPResponse
|
||||
from bottlehaml import haml_template
|
||||
|
||||
@@ -33,7 +33,7 @@ from lib.utils import url_fails
|
||||
from lib.utils import get_video_duration
|
||||
from dateutil import parser as date_parser
|
||||
|
||||
from settings import settings, DEFAULTS, CONFIGURABLE_SETTINGS
|
||||
from settings import settings, DEFAULTS, CONFIGURABLE_SETTINGS, auth_basic
|
||||
from werkzeug.wrappers import Request
|
||||
################################
|
||||
# Utilities
|
||||
@@ -199,7 +199,7 @@ def prepare_asset(request):
|
||||
|
||||
|
||||
@route('/api/assets', method="GET")
|
||||
@auth_basic(settings.check_user)
|
||||
@auth_basic
|
||||
def api_assets():
|
||||
with db.conn(settings['database']) as conn:
|
||||
assets = assets_helper.read(conn)
|
||||
@@ -221,7 +221,7 @@ def api(view):
|
||||
|
||||
|
||||
@route('/api/assets', method="POST")
|
||||
@auth_basic(settings.check_user)
|
||||
@auth_basic
|
||||
@api
|
||||
def add_asset():
|
||||
asset = prepare_asset(request)
|
||||
@@ -232,7 +232,7 @@ def add_asset():
|
||||
|
||||
|
||||
@route('/api/assets/:asset_id', method="GET")
|
||||
@auth_basic(settings.check_user)
|
||||
@auth_basic
|
||||
@api
|
||||
def edit_asset(asset_id):
|
||||
with db.conn(settings['database']) as conn:
|
||||
@@ -240,7 +240,7 @@ def edit_asset(asset_id):
|
||||
|
||||
|
||||
@route('/api/assets/:asset_id', method=["PUT", "POST"])
|
||||
@auth_basic(settings.check_user)
|
||||
@auth_basic
|
||||
@api
|
||||
def edit_asset(asset_id):
|
||||
with db.conn(settings['database']) as conn:
|
||||
@@ -248,7 +248,7 @@ def edit_asset(asset_id):
|
||||
|
||||
|
||||
@route('/api/assets/:asset_id', method="DELETE")
|
||||
@auth_basic(settings.check_user)
|
||||
@auth_basic
|
||||
@api
|
||||
def remove_asset(asset_id):
|
||||
with db.conn(settings['database']) as conn:
|
||||
@@ -263,7 +263,7 @@ def remove_asset(asset_id):
|
||||
|
||||
|
||||
@route('/api/assets/order', method="POST")
|
||||
@auth_basic(settings.check_user)
|
||||
@auth_basic
|
||||
@api
|
||||
def playlist_order():
|
||||
with db.conn(settings['database']) as conn:
|
||||
@@ -276,13 +276,13 @@ def playlist_order():
|
||||
|
||||
|
||||
@route('/')
|
||||
@auth_basic(settings.check_user)
|
||||
@auth_basic
|
||||
def viewIndex():
|
||||
return template('index')
|
||||
|
||||
|
||||
@route('/settings', method=["GET", "POST"])
|
||||
@auth_basic(settings.check_user)
|
||||
@auth_basic
|
||||
def settings_page():
|
||||
|
||||
context = {'flash': None}
|
||||
@@ -310,7 +310,7 @@ def settings_page():
|
||||
|
||||
|
||||
@route('/system_info')
|
||||
@auth_basic(settings.check_user)
|
||||
@auth_basic
|
||||
def system_info():
|
||||
viewlog = None
|
||||
try:
|
||||
|
||||
@@ -6,6 +6,7 @@ from sys import exit
|
||||
import ConfigParser
|
||||
import logging
|
||||
from UserDict import IterableUserDict
|
||||
import bottle
|
||||
|
||||
CONFIG_DIR = '.screenly/'
|
||||
CONFIG_FILE = 'screenly.conf'
|
||||
@@ -128,3 +129,7 @@ class ScreenlySettings(IterableUserDict):
|
||||
|
||||
|
||||
settings = ScreenlySettings()
|
||||
|
||||
|
||||
def auth_basic(orig):
|
||||
return orig if not settings['user'] or not settings['password'] else bottle.auth_basic(settings.check_user)(orig)
|
||||
Reference in New Issue
Block a user