Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
funkwhale
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nykopol
funkwhale
Commits
75959362
Verified
Commit
75959362
authored
May 09, 2018
by
Agate
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
See #75: added a preference do enable/disable the subsonic API on the instance level
parent
632aca51
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
0 deletions
+39
-0
api/config/settings/common.py
api/config/settings/common.py
+1
-0
api/funkwhale_api/subsonic/dynamic_preferences_registry.py
api/funkwhale_api/subsonic/dynamic_preferences_registry.py
+22
-0
api/funkwhale_api/subsonic/views.py
api/funkwhale_api/subsonic/views.py
+11
-0
front/src/store/instance.js
front/src/store/instance.js
+5
-0
No files found.
api/config/settings/common.py
View file @
75959362
...
...
@@ -133,6 +133,7 @@ LOCAL_APPS = (
'funkwhale_api.providers.audiofile'
,
'funkwhale_api.providers.youtube'
,
'funkwhale_api.providers.acoustid'
,
'funkwhale_api.subsonic'
,
)
# See: https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
...
...
api/funkwhale_api/subsonic/dynamic_preferences_registry.py
0 → 100644
View file @
75959362
from
dynamic_preferences
import
types
from
dynamic_preferences.registries
import
global_preferences_registry
from
funkwhale_api.common
import
preferences
subsonic
=
types
.
Section
(
'subsonic'
)
@
global_preferences_registry
.
register
class
APIAutenticationRequired
(
types
.
BooleanPreference
):
section
=
subsonic
show_in_api
=
True
name
=
'enabled'
default
=
True
verbose_name
=
'Enabled Subsonic API'
help_text
=
(
'Funkwhale supports a subset of the Subsonic API, that makes '
'it compatible with existing clients such as DSub for Android '
'or Clementine for desktop. However, Subsonic protocol is less '
'than ideal in terms of security and you can disable this feature '
'completely using this flag.'
)
api/funkwhale_api/subsonic/views.py
View file @
75959362
...
...
@@ -4,11 +4,13 @@ from django.utils import timezone
from
rest_framework
import
exceptions
from
rest_framework
import
permissions
as
rest_permissions
from
rest_framework
import
renderers
from
rest_framework
import
response
from
rest_framework
import
viewsets
from
rest_framework.decorators
import
list_route
from
rest_framework.serializers
import
ValidationError
from
funkwhale_api.common
import
preferences
from
funkwhale_api.favorites.models
import
TrackFavorite
from
funkwhale_api.music
import
models
as
music_models
from
funkwhale_api.music
import
utils
...
...
@@ -61,6 +63,15 @@ class SubsonicViewSet(viewsets.GenericViewSet):
authentication_classes
=
[
authentication
.
SubsonicAuthentication
]
permissions_classes
=
[
rest_permissions
.
IsAuthenticated
]
def
dispatch
(
self
,
request
,
*
args
,
**
kwargs
):
if
not
preferences
.
get
(
'subsonic__enabled'
):
r
=
response
.
Response
({},
status
=
405
)
r
.
accepted_renderer
=
renderers
.
JSONRenderer
()
r
.
accepted_media_type
=
'application/json'
r
.
renderer_context
=
{}
return
r
return
super
().
dispatch
(
request
,
*
args
,
**
kwargs
)
def
handle_exception
(
self
,
exc
):
# subsonic API sends 200 status code with custom error
# codes in the payload
...
...
front/src/store/instance.js
View file @
75959362
...
...
@@ -24,6 +24,11 @@ export default {
value
:
true
}
},
subsonic
:
{
enabled
:
{
value
:
true
}
},
raven
:
{
front_enabled
:
{
value
:
false
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment