gluon-web-admin: add option to show/hide password-login and add minimum password length
This commit is contained in:
		
							parent
							
								
									b5a8959f59
								
							
						
					
					
						commit
						84d117ff73
					
				| @ -59,6 +59,7 @@ Several Freifunk communities in Germany use Gluon as the foundation of their Fre | |||||||
|    package/gluon-ebtables-filter-ra-dhcp |    package/gluon-ebtables-filter-ra-dhcp | ||||||
|    package/gluon-ebtables-segment-mld |    package/gluon-ebtables-segment-mld | ||||||
|    package/gluon-ebtables-source-filter |    package/gluon-ebtables-source-filter | ||||||
|  |    package/gluon-web-admin | ||||||
| 
 | 
 | ||||||
| .. toctree:: | .. toctree:: | ||||||
|    :caption: Releases |    :caption: Releases | ||||||
|  | |||||||
							
								
								
									
										27
									
								
								docs/package/gluon-web-admin.rst
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								docs/package/gluon-web-admin.rst
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,27 @@ | |||||||
|  | gluon-web-admin | ||||||
|  | =============== | ||||||
|  | 
 | ||||||
|  | This package allows the user to set options like the password for ssh access | ||||||
|  | within config mode. You can define in your ``site.conf`` whether it should be | ||||||
|  | possible to access the nodes via ssh with a password or not and what the mimimum | ||||||
|  | password length must be. | ||||||
|  | 
 | ||||||
|  | site.conf | ||||||
|  | --------- | ||||||
|  | 
 | ||||||
|  | config_mode.remote_login.show_password_form \: optional (defaults to ``false``) | ||||||
|  |   If ``show_password_form`` is set to ``true``, the password section in | ||||||
|  |   config mode is shown. | ||||||
|  | 
 | ||||||
|  | config_mode.remote_login.min_password_length \: optional (defaults to ``12``) | ||||||
|  |   This sets the minimum allowed password length. Set this to ``1`` to | ||||||
|  |   disable the length check. | ||||||
|  | 
 | ||||||
|  | If you want to enable the password login you can use this example:: | ||||||
|  | 
 | ||||||
|  |   config_mode = { | ||||||
|  |     remote_login = { | ||||||
|  |       show_password_form = true, -- default false | ||||||
|  |       min_password_length = 12 | ||||||
|  |     } | ||||||
|  |   } | ||||||
| @ -39,4 +39,9 @@ define Package/gluon-web-admin/install | |||||||
| 	$(call GluonInstallI18N,gluon-web-admin,$(1)) | 	$(call GluonInstallI18N,gluon-web-admin,$(1)) | ||||||
| endef | endef | ||||||
| 
 | 
 | ||||||
|  | define Package/gluon-web-admin/postinst | ||||||
|  | #!/bin/sh
 | ||||||
|  | $(call GluonCheckSite,check_site.lua) | ||||||
|  | endef | ||||||
|  | 
 | ||||||
| $(eval $(call BuildPackage,gluon-web-admin)) | $(eval $(call BuildPackage,gluon-web-admin)) | ||||||
|  | |||||||
							
								
								
									
										4
									
								
								package/gluon-web-admin/check_site.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								package/gluon-web-admin/check_site.lua
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,4 @@ | |||||||
|  | if need_table('config_mode', nil, false) and need_table('config_mode.remote_login', nil, false) then | ||||||
|  |   need_boolean('config_mode.remote_login.show_password_form', false) | ||||||
|  |   need_number('config_mode.remote_login.min_password_length', false) | ||||||
|  | end | ||||||
| @ -32,6 +32,9 @@ msgstr "Abbrechen" | |||||||
| msgid "Confirmation" | msgid "Confirmation" | ||||||
| msgstr "Bestätigung" | msgstr "Bestätigung" | ||||||
| 
 | 
 | ||||||
|  | msgid "%u characters min." | ||||||
|  | msgstr "Mindestens %u Zeichen" | ||||||
|  | 
 | ||||||
| msgid "Continue" | msgid "Continue" | ||||||
| msgstr "Fortfahren" | msgstr "Fortfahren" | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -33,6 +33,9 @@ msgstr "Annuler" | |||||||
| msgid "Confirmation" | msgid "Confirmation" | ||||||
| msgstr "Confirmation" | msgstr "Confirmation" | ||||||
| 
 | 
 | ||||||
|  | msgid "%u characters min." | ||||||
|  | msgstr "Au moins %u caractères" | ||||||
|  | 
 | ||||||
| msgid "Continue" | msgid "Continue" | ||||||
| msgstr "Continuer" | msgstr "Continuer" | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -19,6 +19,9 @@ msgstr "" | |||||||
| msgid "Confirmation" | msgid "Confirmation" | ||||||
| msgstr "" | msgstr "" | ||||||
| 
 | 
 | ||||||
|  | msgid "%u characters min." | ||||||
|  | msgstr "" | ||||||
|  | 
 | ||||||
| msgid "Continue" | msgid "Continue" | ||||||
| msgstr "" | msgstr "" | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -13,6 +13,7 @@ You may obtain a copy of the License at | |||||||
| local nixio = require "nixio" | local nixio = require "nixio" | ||||||
| local fs = require "nixio.fs" | local fs = require "nixio.fs" | ||||||
| local util = require "gluon.util" | local util = require "gluon.util" | ||||||
|  | local site = require 'gluon.site_config' | ||||||
| 
 | 
 | ||||||
| local f_keys = Form(translate("SSH keys"), translate("You can provide your SSH keys here (one per line):"), 'keys') | local f_keys = Form(translate("SSH keys"), translate("You can provide your SSH keys here (one per line):"), 'keys') | ||||||
| local s = f_keys:section(Section) | local s = f_keys:section(Section) | ||||||
| @ -30,11 +31,24 @@ function keys:write(value) | |||||||
| 	end | 	end | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
|  | local config = (site.config_mode or {}).remote_login or {} | ||||||
|  | if not config.show_password_form then | ||||||
|  | 	-- password login is disabled in site.conf | ||||||
|  | 	return f_keys | ||||||
|  | end | ||||||
| 
 | 
 | ||||||
| local f_password = Form(translate("Password"), | local min_password_length = config.min_password_length or 12 | ||||||
| 	translate( | local mintype = 'minlength(' .. min_password_length .. ')' | ||||||
|                 "Alternatively, you can set a password to access your node. Please choose a secure password you don't use anywhere else.<br /><br />" | local length_hint | ||||||
|                 .. "If you set an empty password, login via password will be disabled. This is the default." | 
 | ||||||
|  | if min_password_length > 1 then | ||||||
|  | 	length_hint = translatef("%u characters min.", min_password_length) | ||||||
|  | end | ||||||
|  | 
 | ||||||
|  | local f_password = Form(translate("Password"), translate( | ||||||
|  | 	"Alternatively, you can set a password to access your node. Please choose a " | ||||||
|  | 	.. "secure password you don't use anywhere else.<br /><br />If you set an empty " | ||||||
|  | 	.. "password, login via password will be disabled. This is the default." | ||||||
| 	), 'password' | 	), 'password' | ||||||
| ) | ) | ||||||
| f_password.reset = false | f_password.reset = false | ||||||
| @ -43,12 +57,16 @@ local s = f_password:section(Section) | |||||||
| 
 | 
 | ||||||
| local pw1 = s:option(Value, "pw1", translate("Password")) | local pw1 = s:option(Value, "pw1", translate("Password")) | ||||||
| pw1.password = true | pw1.password = true | ||||||
|  | pw1.optional = true | ||||||
|  | pw1.datatype = mintype | ||||||
| function pw1.cfgvalue() | function pw1.cfgvalue() | ||||||
| 	return '' | 	return '' | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
| local pw2 = s:option(Value, "pw2", translate("Confirmation")) | local pw2 = s:option(Value, "pw2", translate("Confirmation"), length_hint) | ||||||
| pw2.password = true | pw2.password = true | ||||||
|  | pw2.optional = true | ||||||
|  | pw2.datatype = mintype | ||||||
| function pw2.cfgvalue() | function pw2.cfgvalue() | ||||||
| 	return '' | 	return '' | ||||||
| end | end | ||||||
| @ -93,7 +111,7 @@ function f_password:write() | |||||||
| 
 | 
 | ||||||
| 	local pw = pw1.data | 	local pw = pw1.data | ||||||
| 
 | 
 | ||||||
| 	if #pw > 0 then | 	if pw ~= nil and #pw > 0 then | ||||||
| 		if set_password(pw) then | 		if set_password(pw) then | ||||||
| 			f_password.message = translate("Password changed.") | 			f_password.message = translate("Password changed.") | ||||||
| 		else | 		else | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user