Skip to content

Commit

Permalink
Disable auth in dev mode
Browse files Browse the repository at this point in the history
  • Loading branch information
smlz committed Nov 29, 2018
1 parent d1e46c9 commit db5b1a1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions klangbecken_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@
############
class WebAPI:

def __init__(self, analyzers=None, processors=None):
def __init__(self, analyzers=None, processors=None, disable_auth=False):
self.data_dir = os.environ.get('KLANGBECKEN_DATA',
'/var/lib/klangbecken')
self.secret = os.environ['KLANGBECKEN_API_SECRET']

self.analyzers = analyzers or DEFAULT_ANALYZERS
self.processors = processors or DEFAULT_PROCESSORS
self.auth = not disable_auth

playlist_url = '/<any(' + ', '.join(PLAYLISTS) + '):playlist>/'
file_url = playlist_url + '<uuid:fileId><any(' + \
Expand All @@ -68,7 +69,8 @@ def __call__(self, environ, start_response):
request.client_session = session
try:
endpoint, values = adapter.match()
if endpoint != 'login' and (session.new or 'user' not in session):
if self.auth and endpoint != 'login' and \
(session.new or 'user' not in session):
raise Unauthorized()
response = getattr(self, 'on_' + endpoint)(request, **values)
except HTTPException as e:
Expand Down Expand Up @@ -415,7 +417,8 @@ def __init__(self):
),
file_tag_processor,
playlist_processor,
]
],
disable_auth=True
)})

self.app = app
Expand Down

0 comments on commit db5b1a1

Please sign in to comment.