禁用 Deluge-Web 验证

IT, 其他
没有评论

通常情况下,在使用 Deluge-Web 界面时你需要输入密码并且选择你需要连接的 daemon 才能通过 WebUI 对 deluged 进行管理,那么如果我们在 Deluge-Web 上增加了反向代理 (通常是增加ssl加密传输,并且添加 htpasswd 验证), Deluge-Web 界面上的密码认证就会显得非常累赘,下面就介绍一种方法来屏蔽此处的认证。

首先停止 Deluge-Web 服务:

killall deluged
killall deluge-web

然后开始修改相关文件:

[deluge.egg]/ui/web/js/deluge-all.js,通常情况下 [deluge.egg] 的路径为 /usr/lib/python2.7/dist-packages/deluge/ 或者 /usr/lib/python2.7/dist-packages/deluge-1.3.15-py2.7.egg/deluge,修改 deluge.LoginWindow 内容如下,此代码存在于末尾:


onShow:function(){this.onLogin();}

[deluge.egg]/ui/web/auth.py,修改如下内容:


#if s.hexdigest() == config["pwd_sha1"]:
#    return True
return True

或者直接使用补丁:


diff -Nur deluge-1.3.15-py2.7.egg/deluge/ui/web/auth.py deluge-1.3.15-py2.7.egg-noauth/deluge/ui/web/auth.py
--- deluge-1.3.15-py2.7.egg/deluge/ui/web/auth.py	2018-12-26 04:37:43.734788434 -0500
+++ deluge-1.3.15-py2.7.egg-noauth/deluge/ui/web/auth.py	2018-12-26 04:38:54.250879522 -0500
@@ -200,8 +200,9 @@
             s = hashlib.sha1()
             s.update(config["pwd_salt"])
             s.update(utf8_encoded(password))
-            if s.hexdigest() == config["pwd_sha1"]:
-                return True
+            #if s.hexdigest() == config["pwd_sha1"]:
+            #    return True
+            return True
 
         else:
             # Can't detect which method we should be using so just deny
diff -Nur deluge-1.3.15-py2.7.egg/deluge/ui/web/js/deluge-all.js deluge-1.3.15-py2.7.egg-noauth/deluge/ui/web/js/deluge-all.js
--- deluge-1.3.15-py2.7.egg/deluge/ui/web/js/deluge-all.js	2018-12-26 04:37:43.734788434 -0500
+++ deluge-1.3.15-py2.7.egg-noauth/deluge/ui/web/js/deluge-all.js	2018-12-26 05:35:16.141247100 -0500
@@ -1437,7 +1437,7 @@
  * this exception statement from your version. If you delete this exception
  * statement from all source files in the program, then also delete it here.
  */
-Deluge.LoginWindow=Ext.extend(Ext.Window,{firstShow:true,bodyStyle:"padding: 10px 5px;",buttonAlign:"center",closable:false,closeAction:"hide",iconCls:"x-deluge-login-window-icon",layout:"fit",modal:true,plain:true,resizable:false,title:_("Login"),width:300,height:120,initComponent:function(){Deluge.LoginWindow.superclass.initComponent.call(this);this.on("show",this.onShow,this);this.addButton({text:_("Login"),handler:this.onLogin,scope:this});this.form=this.add({xtype:"form",baseCls:"x-plain",labelWidth:120,labelAlign:"right",defaults:{width:110},defaultType:"textfield"});this.passwordField=this.form.add({xtype:"textfield",fieldLabel:_("Password"),grow:true,growMin:"110",growMax:"145",id:"_password",name:"password",inputType:"password"});this.passwordField.on("specialkey",this.onSpecialKey,this)},logout:function(){deluge.events.fire("logout");deluge.client.auth.delete_session({success:function(a){this.show(true)},scope:this})},show:function(a){if(this.firstShow){deluge.client.on("error",this.onClientError,this);this.firstShow=false}if(a){return Deluge.LoginWindow.superclass.show.call(this)}deluge.client.auth.check_session({success:function(b){if(b){deluge.events.fire("login")}else{this.show(true)}},failure:function(b){this.show(true)},scope:this})},onSpecialKey:function(b,a){if(a.getKey()==13){this.onLogin()}},onLogin:function(){var a=this.passwordField;deluge.client.auth.login(a.getValue(),{success:function(b){if(b){deluge.events.fire("login");this.hide();a.setRawValue("")}else{Ext.MessageBox.show({title:_("Login Failed"),msg:_("You entered an incorrect password"),buttons:Ext.MessageBox.OK,modal:false,fn:function(){a.focus(true,10)},icon:Ext.MessageBox.WARNING,iconCls:"x-deluge-icon-warning"})}},scope:this})},onClientError:function(c,b,a){if(c.error.code==1){deluge.events.fire("logout");this.show(true)}},onShow:function(){this.passwordField.focus(true,300)}});
+Deluge.LoginWindow=Ext.extend(Ext.Window,{firstShow:true,bodyStyle:"padding: 10px 5px;",buttonAlign:"center",closable:false,closeAction:"hide",iconCls:"x-deluge-login-window-icon",layout:"fit",modal:true,plain:true,resizable:false,title:_("Login"),width:300,height:120,initComponent:function(){Deluge.LoginWindow.superclass.initComponent.call(this);this.on("show",this.onShow,this);this.addButton({text:_("Login"),handler:this.onLogin,scope:this});this.form=this.add({xtype:"form",baseCls:"x-plain",labelWidth:120,labelAlign:"right",defaults:{width:110},defaultType:"textfield"});this.passwordField=this.form.add({xtype:"textfield",fieldLabel:_("Password"),grow:true,growMin:"110",growMax:"145",id:"_password",name:"password",inputType:"password"});this.passwordField.on("specialkey",this.onSpecialKey,this)},logout:function(){deluge.events.fire("logout");deluge.client.auth.delete_session({success:function(a){this.show(true)},scope:this})},show:function(a){if(this.firstShow){deluge.client.on("error",this.onClientError,this);this.firstShow=false}if(a){return Deluge.LoginWindow.superclass.show.call(this)}deluge.client.auth.check_session({success:function(b){if(b){deluge.events.fire("login")}else{this.show(true)}},failure:function(b){this.show(true)},scope:this})},onSpecialKey:function(b,a){if(a.getKey()==13){this.onLogin()}},onLogin:function(){var a=this.passwordField;deluge.client.auth.login(a.getValue(),{success:function(b){if(b){deluge.events.fire("login");this.hide();a.setRawValue("")}else{Ext.MessageBox.show({title:_("Login Failed"),msg:_("You entered an incorrect password"),buttons:Ext.MessageBox.OK,modal:false,fn:function(){a.focus(true,10)},icon:Ext.MessageBox.WARNING,iconCls:"x-deluge-icon-warning"})}},scope:this})},onClientError:function(c,b,a){if(c.error.code==1){deluge.events.fire("logout");this.show(true)}},onShow:function(){this.onLogin();}});
 /*
  * Deluge.Menus.js
  *


拷贝补丁到[deluge.egg],运行:


patch -p1 < disable-auth.patch

 

, , ,
上一篇文章
Transmission 多用户实例
下一篇文章
在 ubuntu 18.04 编译 rtorrent-0.9.4

发表评论

电子邮件地址不会被公开。 必填项已用*标注

Fill out this field
Fill out this field
请输入正确的电子邮件地址。

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据

菜单