Move definition of what commands are allowed without authentication from the auth filter to the request handlers
This commit is contained in:
parent
601a0f0a45
commit
3ac987ee47
@ -76,12 +76,14 @@ class MpdDispatcher(object):
|
||||
self.authenticated = True
|
||||
return self._call_next_filter(request, response, filter_chain)
|
||||
else:
|
||||
command = request.split(' ')[0]
|
||||
if command in (
|
||||
'close', 'commands', 'notcommands', 'password', 'ping'):
|
||||
command_name = request.split(' ')[0]
|
||||
command_names_not_requiring_auth = [
|
||||
command.name for command in mpd_commands
|
||||
if not command.auth_required]
|
||||
if command_name in command_names_not_requiring_auth:
|
||||
return self._call_next_filter(request, response, filter_chain)
|
||||
else:
|
||||
raise MpdPermissionError(command=command)
|
||||
raise MpdPermissionError(command=command_name)
|
||||
|
||||
|
||||
### Filter: command list
|
||||
|
||||
@ -3,7 +3,7 @@ from mopidy.frontends.mpd.protocol import handle_request
|
||||
from mopidy.frontends.mpd.exceptions import (MpdPasswordError,
|
||||
MpdPermissionError)
|
||||
|
||||
@handle_request(r'^close$')
|
||||
@handle_request(r'^close$', auth_required=False)
|
||||
def close(context):
|
||||
"""
|
||||
*musicpd.org, connection section:*
|
||||
@ -25,7 +25,7 @@ def kill(context):
|
||||
"""
|
||||
raise MpdPermissionError(command=u'kill')
|
||||
|
||||
@handle_request(r'^password "(?P<password>[^"]+)"$')
|
||||
@handle_request(r'^password "(?P<password>[^"]+)"$', auth_required=False)
|
||||
def password_(context, password):
|
||||
"""
|
||||
*musicpd.org, connection section:*
|
||||
@ -40,7 +40,7 @@ def password_(context, password):
|
||||
else:
|
||||
raise MpdPasswordError(u'incorrect password', command=u'password')
|
||||
|
||||
@handle_request(r'^ping$')
|
||||
@handle_request(r'^ping$', auth_required=False)
|
||||
def ping(context):
|
||||
"""
|
||||
*musicpd.org, connection section:*
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
from mopidy.frontends.mpd.protocol import handle_request, mpd_commands
|
||||
from mopidy.frontends.mpd.exceptions import MpdNotImplemented
|
||||
|
||||
@handle_request(r'^commands$')
|
||||
@handle_request(r'^commands$', auth_required=False)
|
||||
def commands(context):
|
||||
"""
|
||||
*musicpd.org, reflection section:*
|
||||
@ -49,7 +49,7 @@ def decoders(context):
|
||||
"""
|
||||
raise MpdNotImplemented # TODO
|
||||
|
||||
@handle_request(r'^notcommands$')
|
||||
@handle_request(r'^notcommands$', auth_required=False)
|
||||
def notcommands(context):
|
||||
"""
|
||||
*musicpd.org, reflection section:*
|
||||
|
||||
Loading…
Reference in New Issue
Block a user