165 Commits

Author SHA1 Message Date
Veiko Aasa
aa2aa56c46
users: Add tests for the Samba user database
Fix: after renaming a user delete old username from the Samba password database

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-12-29 16:59:04 -05:00
Veiko Aasa
83cb305026
samba: private shares
- new share types - group and home shares
- users: when creating, deleting or changing user password, update also Samba
  tdbsam backend database
- users: new managed packages - samba-common-bin, tdb-tools
- module page: show current samba users who are in freedombox-share group
- module page: show users who should re-enter their password in the password change page
- fix: use os.path.ismount() from Python standard library to validate a mount point
- fix: samba share permissions, fixes #1729
- fix: delete a share - do not raise an exception if the share doesn't exist
- storage: show samba share type in the directory selection form

Closes #1727

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-12-20 21:01:12 -05:00
James Valleroy
83ca977dd4
users: Use service action to restart share group service
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
2019-12-15 19:08:18 -05:00
Veiko Aasa
ea48f9a74b
storage: Directory selection form and validator
Directory selection allows to:
- select from default directory
- select from available Samba shares
- specify subdirectory
- insert custom directory

- directory validator checks: path exists, is directory, is readable, is writable
- samba: action script: include share path in share list
- create freedombox-share group inside users module  instead of samba module

Closes #1703

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-12-15 19:08:10 -05:00
Alice Kile
eb83e00011
fix formatting issues
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-12-07 13:08:35 -05:00
Sunil Mohan Adapa
7cfb4cc683
users: Move create button into users section
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-12-01 16:52:29 -05:00
Sunil Mohan Adapa
ad0552adf6
users: Make UI close to rest of the apps
- Provide an app title, description and link to manual page.

- Use AppView and app.html to present most of the elements.

- Remove tabs and turn create user into a button.

Tested by running: py.test-3 --include-functional -k users-groups

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-10-04 18:03:50 -04:00
Sunil Mohan Adapa
a66d50fb89
users: Cosmetic yapf and isort fixes
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-08-25 15:52:15 -04:00
Sunil Mohan Adapa
2317e6bd94
users: Minor fix to return value when getting last admin user
Tests:

- When only when admin user is present, the users list does not show delete
  button next to the admin user. The checkbox for admin group is disabled (but
  checked) for that user in edit user form.

- When there are multiple admin users preset, the users list shows delete button
  against all admin users. The checkbox for admin group is enabled (but checked)
  for all admin users.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-08-25 15:52:12 -04:00
Sunil Mohan Adapa
e1e654554e
users: Minor cosmetic refactoring
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-08-25 15:52:06 -04:00
Sunil Mohan Adapa
b01ac54dd3
users: Don't delete 'admin' group when running unit tests
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-08-25 15:52:03 -04:00
Nikolas Nyby
5439084c84
Add flake8 to gitlib-ci - closes #58
And fix the rest of the flake8 errors.

Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2019-07-25 11:07:06 -07:00
Nikolas Nyby
f81b1751ce
Fix typos in module init docs
Intialize -> Initialize

Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2019-07-24 14:55:22 -07:00
Nikolas Nyby
d2e987ef3c
Fix a handful of typos in docs and comments
Found with [codespell](https://github.com/codespell-project/codespell/)

Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2019-07-24 12:39:11 -07:00
Sunil Mohan Adapa
b0d797a84a
Minor yapf and isort changes
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-07-21 09:06:04 -04:00
Sunil Mohan Adapa
0f807bcd48
sso: Use new features of axes, log axes messages
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-07-21 09:05:58 -04:00
Sunil Mohan Adapa
46f162d093
app: Add unique ID to each app class
Also maintain a global list of apps

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-06-13 20:17:59 -04:00
Sunil Mohan Adapa
b96d901071
Introduce component architecture and menu component
- Introduce base class for all apps that will contain components. With
  unittests.

- Introduce base classes for components. With unittests.

- Turn Menu class into an app component.

  - Further cleanup Menu class.

  - Update tests.

  - Maintain a global list of menu items and look them up easily. Generalize
    such that subsubmenus can later be merged into Menu class.

  - Cleanup scope of main menu initialization.

  - Use None instead of empty strings for various values. Ensure that
    printing short_description does not show 'None' in output.

  - Use enable/disable instead of promote/demote.

- Use menu component in all apps.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
2019-06-07 11:48:04 -07:00
Sunil Mohan Adapa
e9adeed958
users: Convert tests to pytest style
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
2019-05-12 17:15:16 +05:30
Sunil Mohan Adapa
ff247fa5aa
setup: Move app data files into respective apps
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-03-17 16:20:57 -04:00
Sunil Mohan Adapa
fdcbd46513
setup: Move app enabling files to respective apps
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-03-17 16:20:54 -04:00
James Valleroy
d4fa87bbf1
users: When ssh used in tests, add users to admin group
This allows the tests to pass even if logins are restricted by
security module.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2019-03-01 20:09:43 -08:00
Joseph Nuthalapati
a4887ef0d0
users: Add nscd as a dependency
Currently, nscd comes as a recommended package of nslcd, which is a dependency
of Plinth. Plinth needs nscd to work. An installation with the --no-recommends
option will cause errors in Plinth.

Users is an essential package in plinth. nscd is now a managed package of users.

Fixes #1213

Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2019-02-26 11:07:24 -08:00
Prachi Srivastava
743d976d50
security: Moves input field focus javascript to django forms
Signed-off-by: Prachi Srivastava <prachi.chs.2009@gmail.com>
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2019-01-28 17:39:22 -08:00
Prachi Srivastava
5d68f6bf52
Replace glyphicons with forkawesome icons
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2019-01-14 17:37:58 -08:00
Michael Pimmer
4eeceaa695
Backups: allow testing the connection of ssh locations
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-12-13 18:27:17 -05:00
James Valleroy
292597d894
users: Reset groups before testing register_group
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
2018-09-24 19:40:09 +05:30
Joseph Nuthalapati
b740a37a1e
users: Replace disabled with readonly for admin group checkbox
- Added validation logic in the backend to compensate

Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-07-04 08:28:55 -04:00
Joseph Nuthalapati
a50b40ee56
Change get-group-users to a simpler implementation
Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-07-04 08:28:51 -04:00
Joseph Nuthalapati
825db6ef15
users: Redirect to users list on successful user creation
- Closes #1316

Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-07-01 13:01:57 -04:00
James Valleroy
4dc83f135a
users: Update Change Password menu for non-admin users
Don't show Create User menu item to non-admin users. Previously this
was fixed for the Edit User page, and this fixes it also for the
Change Password page.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
2018-06-26 21:41:34 -04:00
Joseph Nuthalapati
15c7202a6b
users: Don't show Create User form to non-admin users
For non-admin users, the subsubmenu containing both Edit and Create forms is
shown. Removed the subsubmenu so that only the update form is shown.

Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-06-26 21:31:55 -04:00
Hemanth Kumar Veeranki
b9963a45cd
Restrict removal of last admin user
- Don't allow disabling the only available admin account.
- Don't allow deletion of the only available admin account.
- Don't allow removing admin privileges of the only available admin account.

Signed-off-by: Hemanth Kumar Veeranki <hems.india1997@gmail.com>
Reviewed-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
2018-06-21 20:09:02 +05:30
Sunil Mohan Adapa
6fc6efad1e
users: Remove unnecessary column sizing
Signed-off-by: Manish Tripathy <manisht@thougtworks.com>
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2018-06-18 20:21:16 +05:30
Joseph Nuthalapati
4151ab3f10
users: internationalize a string
Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2018-06-04 13:14:53 +05:30
Joseph Nuthalapati
642ac0f997
users: Fix user permissions not being saved
Fixes #1299

Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2018-06-04 13:14:42 +05:30
Joseph Nuthalapati
14442b1db2
users: Fix admin group appearing twice in permissions
Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-04-08 10:56:52 -04:00
Sunil Mohan Adapa
87dbdf6f3d
users: Generalize styling for multi-select widget
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
2018-03-12 18:26:18 +05:30
Sunil Mohan Adapa
6090d5c37d
locale: Split the language selection form into a mixin
- It may not be a good thing for the user created/edit forms to inherit from
  Django Form and ModelForm at the same time. So, simply by introducing a
  minimal mixin.

- Save only when committing.

- Use auto-saving feature.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-02-21 21:08:33 +01:00
Sunil Mohan Adapa
90932e78af
locale: Implement utilities for setting/getting language
Separate language cookie are only used if sessions (session middleware) are not
available. Otherwise, even anonymous users have their language preference in
sessions instead of cookies. This is default Django behavior, conform to it.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-02-21 21:07:47 +01:00
Sai Kiran Naragam
837e0b8384
locale: Adds preferred language for logged in user
- UserProfile model is created, it has one-to-one relationship with User.

- Language selection dropdown added to UserCreate and UserUpdate forms.

- Adds None to language selection dropdown to explicitly unselect.

- LANGUAGE_SESSION_KEY is set to User's preferred language on LogIn activity.

- LANGUAGE_SESSION_KEY is deleted on User's LogOut activity.

Signed-off-by: Sai Kiran Naragam <saikiran.rguiiit@gmail.com>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2018-02-21 21:06:14 +01:00
Sunil Mohan Adapa
90f2117554
Rename Plinth to FreedomBox in comments
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-02-16 20:10:45 -05:00
Sunil Mohan Adapa
8f0e2d6381
Rename Plinth to FreedomBox in module doc strings
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-02-16 20:10:25 -05:00
Sunil Mohan Adapa
dea4af17fb
Rename Plinth to FreedomBox in license headers
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-02-16 20:10:09 -05:00
Sunil Mohan Adapa
0609f6a107
groups: Don't duplicate checking of group existence
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
2018-01-12 14:42:56 +05:30
Aakanksha Saini
0dea420ffe
groups: Consistent listing of groups
- Remove conditional registration of groups on module initialization.
- Create uninitialized groups on addition/update of groups for user.
- Remove group creation on setup/installation of a module.

Tested for:
- Multi registration of groups.
- Manual UI test to check visibility of groups irrespective of whether module is
  installed/enabled.

Signed-off-by: Aakanksha Saini <aakanksa@thoughtworks.com>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2018-01-12 14:42:43 +05:30
Sunil Mohan Adapa
15f2e7d0c3
users: Make sure first run actually works
During the first setup, older_version is sent as 0 instead of None. Make sure
that is actually works by doing proper condition check.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2017-12-29 14:20:15 -05:00
Joseph Nuthalapati
81f4d7ec42
users: tests: restore previous value of restricted access
Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2017-12-14 08:51:11 -05:00
Joseph Nuthalapati
8da56c0fb4
Fix failing root tests
- There are tests checking whether a user can login to ssh which fail with the
  default security settings.
- Toggling the security settings in the setup and teardown of the test suite to
  allow non-admin users to login to ssh as well.

Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2017-12-14 08:50:45 -05:00
James Valleroy
87eecb7c62
users: Handle upgrade for ldapscripts config
Increment users module version so existing users will get FreedomBox
copy of ldapscripts config file.

Avoid reconfiguration of slapd during module upgrade, because this
will move the existing database.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2017-12-14 11:43:07 +05:30