mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +00:00
Enable Single Sign On for transmission
- Disabled login using username and password. Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
5e2b4b1c9e
commit
5ff459387e
@ -8,6 +8,10 @@
|
|||||||
##
|
##
|
||||||
<Location /transmission>
|
<Location /transmission>
|
||||||
ProxyPass http://localhost:9091/transmission
|
ProxyPass http://localhost:9091/transmission
|
||||||
|
Include includes/freedombox-single-sign-on.conf
|
||||||
|
<IfModule mod_auth_pubtkt.c>
|
||||||
|
TKTAuthToken "admin" "bit-torrent"
|
||||||
|
</IfModule>
|
||||||
## Send the scheme from user's request to enable Transmission to
|
## Send the scheme from user's request to enable Transmission to
|
||||||
## redirect URLs, set cookies, set absolute URLs (if any)
|
## redirect URLs, set cookies, set absolute URLs (if any)
|
||||||
## properly.
|
## properly.
|
||||||
|
|||||||
@ -14,7 +14,6 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Plinth module to configure Transmission server
|
Plinth module to configure Transmission server
|
||||||
"""
|
"""
|
||||||
@ -28,7 +27,7 @@ from plinth import frontpage
|
|||||||
from plinth import service as service_module
|
from plinth import service as service_module
|
||||||
from plinth.menu import main_menu
|
from plinth.menu import main_menu
|
||||||
from plinth.client import web_client
|
from plinth.client import web_client
|
||||||
|
from plinth.modules.users import add_group
|
||||||
|
|
||||||
version = 1
|
version = 1
|
||||||
|
|
||||||
@ -47,7 +46,7 @@ description = [
|
|||||||
_('Access the web interface at <a href="/transmission">/transmission</a>.')
|
_('Access the web interface at <a href="/transmission">/transmission</a>.')
|
||||||
]
|
]
|
||||||
|
|
||||||
web_clients = [web_client(name='Transmission',url='/transmission')]
|
web_clients = [web_client(name='Transmission', url='/transmission')]
|
||||||
|
|
||||||
reserved_usernames = ['debian-transmission']
|
reserved_usernames = ['debian-transmission']
|
||||||
|
|
||||||
@ -57,15 +56,20 @@ service = None
|
|||||||
def init():
|
def init():
|
||||||
"""Intialize the Transmission module."""
|
"""Intialize the Transmission module."""
|
||||||
menu = main_menu.get('apps')
|
menu = main_menu.get('apps')
|
||||||
menu.add_urlname(name, 'glyphicon-save', 'transmission:index', short_description)
|
menu.add_urlname(name, 'glyphicon-save', 'transmission:index',
|
||||||
|
short_description)
|
||||||
|
|
||||||
global service
|
global service
|
||||||
setup_helper = globals()['setup_helper']
|
setup_helper = globals()['setup_helper']
|
||||||
if setup_helper.get_state() != 'needs-setup':
|
if setup_helper.get_state() != 'needs-setup':
|
||||||
service = service_module.Service(
|
service = service_module.Service(
|
||||||
managed_services[0], name, ports=['http', 'https'],
|
managed_services[0],
|
||||||
is_external=True, is_enabled=is_enabled,
|
name,
|
||||||
enable=enable, disable=disable)
|
ports=['http', 'https'],
|
||||||
|
is_external=True,
|
||||||
|
is_enabled=is_enabled,
|
||||||
|
enable=enable,
|
||||||
|
disable=disable)
|
||||||
|
|
||||||
if is_enabled():
|
if is_enabled():
|
||||||
add_shortcut()
|
add_shortcut()
|
||||||
@ -75,32 +79,45 @@ def setup(helper, old_version=None):
|
|||||||
"""Install and configure the module."""
|
"""Install and configure the module."""
|
||||||
helper.install(managed_packages)
|
helper.install(managed_packages)
|
||||||
|
|
||||||
new_configuration = {'rpc-whitelist-enabled': False}
|
new_configuration = {
|
||||||
helper.call('post', actions.superuser_run, 'transmission',
|
'rpc-whitelist-enabled': False,
|
||||||
['merge-configuration'],
|
'rpc-authentication-required': False
|
||||||
input=json.dumps(new_configuration).encode())
|
}
|
||||||
|
helper.call(
|
||||||
|
'post',
|
||||||
|
actions.superuser_run,
|
||||||
|
'transmission', ['merge-configuration'],
|
||||||
|
input=json.dumps(new_configuration).encode())
|
||||||
|
|
||||||
helper.call('post', actions.superuser_run, 'transmission', ['enable'])
|
helper.call('post', actions.superuser_run, 'transmission', ['enable'])
|
||||||
global service
|
global service
|
||||||
if service is None:
|
if service is None:
|
||||||
service = service_module.Service(
|
service = service_module.Service(
|
||||||
managed_services[0], name, ports=['http', 'https'],
|
managed_services[0],
|
||||||
is_external=True, is_enabled=is_enabled,
|
name,
|
||||||
enable=enable, disable=disable)
|
ports=['http', 'https'],
|
||||||
|
is_external=True,
|
||||||
|
is_enabled=is_enabled,
|
||||||
|
enable=enable,
|
||||||
|
disable=disable)
|
||||||
helper.call('post', service.notify_enabled, None, True)
|
helper.call('post', service.notify_enabled, None, True)
|
||||||
helper.call('post', add_shortcut)
|
helper.call('post', add_shortcut)
|
||||||
|
add_group('bit-torrent')
|
||||||
|
|
||||||
|
|
||||||
def add_shortcut():
|
def add_shortcut():
|
||||||
frontpage.add_shortcut(
|
frontpage.add_shortcut(
|
||||||
'transmission', name, short_description=short_description, url='/transmission',
|
'transmission',
|
||||||
login_required=True)
|
name,
|
||||||
|
short_description=short_description,
|
||||||
|
url='/transmission',
|
||||||
|
login_required=True)
|
||||||
|
|
||||||
|
|
||||||
def is_enabled():
|
def is_enabled():
|
||||||
"""Return whether the module is enabled."""
|
"""Return whether the module is enabled."""
|
||||||
return (action_utils.service_is_enabled('transmission-daemon') and
|
return (action_utils.service_is_enabled('transmission-daemon')
|
||||||
action_utils.webserver_is_enabled('transmission-plinth'))
|
and action_utils.webserver_is_enabled('transmission-plinth'))
|
||||||
|
|
||||||
|
|
||||||
def enable():
|
def enable():
|
||||||
@ -121,7 +138,8 @@ def diagnose():
|
|||||||
|
|
||||||
results.append(action_utils.diagnose_port_listening(9091, 'tcp4'))
|
results.append(action_utils.diagnose_port_listening(9091, 'tcp4'))
|
||||||
results.append(action_utils.diagnose_port_listening(9091, 'tcp6'))
|
results.append(action_utils.diagnose_port_listening(9091, 'tcp6'))
|
||||||
results.extend(action_utils.diagnose_url_on_all(
|
results.extend(
|
||||||
'https://{host}/transmission', check_certificate=False))
|
action_utils.diagnose_url_on_all(
|
||||||
|
'https://{host}/transmission', check_certificate=False))
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
|||||||
@ -14,7 +14,6 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Plinth module for configuring Transmission.
|
Plinth module for configuring Transmission.
|
||||||
"""
|
"""
|
||||||
@ -32,13 +31,3 @@ class TransmissionForm(ServiceForm): # pylint: disable=W0232
|
|||||||
help_text=_('Directory where downloads are saved. If you change the '
|
help_text=_('Directory where downloads are saved. If you change the '
|
||||||
'default directory, ensure that the new directory exists '
|
'default directory, ensure that the new directory exists '
|
||||||
'and is writable by "debian-transmission" user.'))
|
'and is writable by "debian-transmission" user.'))
|
||||||
|
|
||||||
rpc_username = forms.CharField(
|
|
||||||
label=_('Username'),
|
|
||||||
help_text=_('Username to login to the web interface.'))
|
|
||||||
|
|
||||||
rpc_password = forms.CharField(
|
|
||||||
label=_('Password'),
|
|
||||||
help_text=_('Password to login to the web interface. Current '
|
|
||||||
'password is shown in a hashed format. To set a new '
|
|
||||||
'password, enter the password in plain text.'))
|
|
||||||
|
|||||||
@ -14,7 +14,6 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Plinth module for configuring Transmission Server
|
Plinth module for configuring Transmission Server
|
||||||
"""
|
"""
|
||||||
@ -42,11 +41,15 @@ class TransmissionServiceView(views.ServiceView):
|
|||||||
|
|
||||||
def get_initial(self):
|
def get_initial(self):
|
||||||
"""Get the current settings from Transmission server."""
|
"""Get the current settings from Transmission server."""
|
||||||
configuration = actions.superuser_run(
|
configuration = actions.superuser_run('transmission',
|
||||||
'transmission', ['get-configuration'])
|
['get-configuration'])
|
||||||
status = json.loads(configuration)
|
status = json.loads(configuration)
|
||||||
status = {key.translate(str.maketrans({'-': '_'})): value
|
status = {
|
||||||
for key, value in status.items()}
|
key.translate(str.maketrans({
|
||||||
|
'-': '_'
|
||||||
|
})): value
|
||||||
|
for key, value in status.items()
|
||||||
|
}
|
||||||
status['is_enabled'] = self.service.is_enabled()
|
status['is_enabled'] = self.service.is_enabled()
|
||||||
status['is_running'] = self.service.is_running()
|
status['is_running'] = self.service.is_running()
|
||||||
status['hostname'] = socket.gethostname()
|
status['hostname'] = socket.gethostname()
|
||||||
@ -58,17 +61,14 @@ class TransmissionServiceView(views.ServiceView):
|
|||||||
old_status = form.initial
|
old_status = form.initial
|
||||||
new_status = form.cleaned_data
|
new_status = form.cleaned_data
|
||||||
|
|
||||||
if old_status['download_dir'] != new_status['download_dir'] or \
|
if old_status['download_dir'] != new_status['download_dir']:
|
||||||
old_status['rpc_username'] != new_status['rpc_username'] or \
|
|
||||||
old_status['rpc_password'] != new_status['rpc_password']:
|
|
||||||
new_configuration = {
|
new_configuration = {
|
||||||
'download-dir': new_status['download_dir'],
|
'download-dir': new_status['download_dir'],
|
||||||
'rpc-username': new_status['rpc_username'],
|
|
||||||
'rpc-password': new_status['rpc_password'],
|
|
||||||
}
|
}
|
||||||
|
|
||||||
actions.superuser_run('transmission', ['merge-configuration'],
|
actions.superuser_run(
|
||||||
input=json.dumps(new_configuration).encode())
|
'transmission', ['merge-configuration'],
|
||||||
|
input=json.dumps(new_configuration).encode())
|
||||||
messages.success(self.request, _('Configuration updated'))
|
messages.success(self.request, _('Configuration updated'))
|
||||||
|
|
||||||
return super().form_valid(form)
|
return super().form_valid(form)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user