Skip to content

Commit

Permalink
don't require basic auth if login or password does not configured
Browse files Browse the repository at this point in the history
  • Loading branch information
pain64 committed Jan 16, 2017
1 parent 6019547 commit 2dbba49
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
22 changes: 11 additions & 11 deletions server.py
Expand Up @@ -17,7 +17,7 @@
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

Expand All @@ -33,7 +33,7 @@
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
Expand Down Expand Up @@ -199,7 +199,7 @@ def get(key):


@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)
Expand All @@ -221,7 +221,7 @@ def api_view(*args, **kwargs):


@route('/api/assets', method="POST")
@auth_basic(settings.check_user)
@auth_basic
@api
def add_asset():
asset = prepare_asset(request)
Expand All @@ -232,23 +232,23 @@ 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:
return assets_helper.read(conn, 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:
return assets_helper.update(conn, asset_id, prepare_asset(request))


@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:
Expand All @@ -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:
Expand All @@ -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}
Expand Down Expand Up @@ -310,7 +310,7 @@ def settings_page():


@route('/system_info')
@auth_basic(settings.check_user)
@auth_basic
def system_info():
viewlog = None
try:
Expand Down
5 changes: 5 additions & 0 deletions settings.py
Expand Up @@ -6,6 +6,7 @@
import ConfigParser
import logging
from UserDict import IterableUserDict
import bottle

CONFIG_DIR = '.screenly/'
CONFIG_FILE = 'screenly.conf'
Expand Down Expand Up @@ -128,3 +129,7 @@ def check_user(self, user, password):


settings = ScreenlySettings()


def auth_basic(orig):
return orig if not settings['user'] or not settings['password'] else bottle.auth_basic(settings.check_user)(orig)

0 comments on commit 2dbba49

Please sign in to comment.