94 Commits

Author SHA1 Message Date
Sunil Mohan Adapa
f82136e559
users: Show and consume messages in user edit & password change 2017-02-15 21:08:39 +05:30
Rahul De
ad0b235dd7
users: Restrict groups and active user control to admins
- Only admins can now edit the groups of any user

- Only admins can mark any user as active or not

- Refactored all occurrences of admin checks to its own utility function
2017-02-15 21:07:54 +05:30
Sunil Mohan Adapa
dd5ab7612e
Minor refactoring and lint fixes
- Rename AdminMiddleware to AdminRequiredMiddleware to be consistent
  with stronghold/Django terminology

- Simplify .gitignore pattern

- Format single line docstrings as per PEP8.

- Add missing docstrings.

- Restrict lines to 79 characters.
2017-02-15 21:07:27 +05:30
lispyclouds
40ceb9a152
Deny access to non-admin users to other's pages
- This checks that the user making the request is the same user as the
  one logged in and prevents access to the pages of other users if its
  not admin
2017-02-15 21:05:40 +05:30
lispyclouds
79b27ea2ee
Make user edit and change password non-admin views
- This makes the user update and password change pages non admin so that
  non admin users can access
2017-02-15 21:04:40 +05:30
lispyclouds
3b23f78bdc
Implement middleware for admin views
- Add AdminMiddleware to deny non admin users
- Add decorator to mark views as "non admin"
2017-02-15 20:57:52 +05:30
James Valleroy
0fdc0ffe52
users: Fix marking first boot step as done 2016-12-04 15:24:51 -05:00
Sunil Mohan Adapa
f457a0bdd3
first_boot: Fix various issues and refactor
- Fix major regression so that steps can submitted multiple times in
  case of errors.

- Don't serve the welcome page (and other pages) only once.  Show it
  until action is an taken.  This does not apply to the final step.

- Eliminate all coupling of one first boot step on another.

- Move first boot helper methods to __init__.py instead of middleware as
  it is more generic than middleware.

- Implement caching the first boot state to avoid an SQL query on every
  page load.  The down side is that if first boot state is modified in
  the backend DB outside Plinth, Plinth will need to be restarted to
  catch the modified value.

- Mark some methods as private.

- Refactor middleware code for slightly more simplicity.

- Don't show sidebar in pagekite first boot step.  Set width like other
  pages.
2016-12-04 15:24:48 -05:00
Sunil Mohan Adapa
6cce89ed68
users: Update first boot step submit button text
'Box it up!' is confusing is and no longer relavent as there are more
steps after that step.
2016-12-04 15:24:45 -05:00
Sunil Mohan Adapa
56686b7148
firstboot: Rename views/urls to be non-numeric 2016-12-04 15:24:36 -05:00
Sunil Mohan Adapa
c37aa0fbd5
firstboot: Indentation & styling fixes
pycodestyle version used is 2.1.0 with default arguments.
2016-12-04 15:24:31 -05:00
mridulnagpal
a2d4719685
user delete fix 2016-12-04 14:04:44 -05:00
Hemanth Kumar Veeranki
6011a7adfa
Made Suggested Changes 2016-11-03 22:06:08 -04:00
Hemanth Kumar Veeranki
0290f68ae6
Removed redirection for login and help urls
Changed the redirection in state0 template
2016-11-03 22:06:05 -04:00
Hemanth Kumar Veeranki
0332d4489e
Added code for modules to register for first_boot #529 2016-11-03 22:06:00 -04:00
Sunil Mohan Adapa
ff0d117a89
Readjust the responsive widths of various tables
Most tables now occupy the full width of the container row.  Some of
them are otherwise squished.  Also make sure the new fixed container
layout has not reduced the originally intended width of a table.
2016-09-11 13:15:00 -04:00
Sunil Mohan Adapa
2c204429c6
Remove width management for forms
Now all forms will uniformly occupy the full width of the available
row.  Bootstrap originally designed forms this way.  However, we were
setting restricted widths on forms as they were too wide.  With the new
fixed container layout this is no longer necessary.
2016-09-11 13:14:57 -04:00
Sunil Mohan Adapa
5f94d6489f
users: Update the SSH set key error message
In a following pull request, we are expected to solve the cache timing
issue.  So, show a generic error message instead of one that suggests a
timing problem.
2016-08-23 21:37:51 +05:30
James Valleroy
d2950d9c5f
users: Display error message if unable to set SSH keys 2016-08-23 21:37:41 +05:30
Sunil Mohan Adapa
b7cbc56f8a
users: Fix checking restricted usernames
When editing an existing user, error is being thrown due to restricted
usernames check.  This is due to the username matching existing
username.

Also:

- Raise the validation error on the field instead of the entire form.

- Send error code along with validation error message.

- End the validation error message with a full stop for consistency.
2016-08-16 12:31:52 -04:00
Sunil Mohan Adapa
fff0a6c562
users: Fix editing users without SSH keys
When SSH keys are not available for a user, the current user edit form
errors out.  Fix this by ignoring ssh key load errors.
2016-08-12 16:10:32 -04:00
Sunil Mohan Adapa
e719966c4b
users: Refactor valid user name checking for reuse
- Supress output from getent

- More accurate message
2016-08-12 19:32:19 +05:30
James Valleroy
c8c6bc377b
users: Add list of restricted usernammes
List is derived from optional services installed.
2016-08-12 18:48:16 +05:30
James Valleroy
3a69958165
users: Avoid username conflicts with system users
When creating or renaming a user, check if the new username is in use by
any system user.
2016-08-12 18:47:52 +05:30
Sunil Mohan Adapa
18996b5c56
Import urlresolvers from django.urls
In Django 1.10, django.core.urlresolvers is available from
django.urls. Use it.
2016-08-11 18:03:00 -04:00
James Valleroy
956416ef37
Configure users module packages after installation
Preseeding settings with debconf won't have any effect if the packages
are already installed. Instead, provide an override database to
dpkg-reconfigure.
2016-07-30 08:49:22 +05:30
Sunil Mohan Adapa
5f548a9e36
packages: Make modules declare managed packages
This can then be used by a privileged action to verify that packages
requested for installation are in fact valid.  This slightly improves
security of those privileged actions.
2016-06-11 12:11:32 -04:00
Sunil Mohan Adapa
ad61028a3a
menu: Sort menu items for all locales
Currently menu items are shown in alphabetical order in applications and
no clear order in system configuration.  This is done using static
weights for menu items based on English names that does not work for
other locales.

Sorting can't be done at the time of adding menu items as users of
multiple locales may use the interface at the same time.

Implement a sorting mechanism based on existing order as well as labels
of menu item.  This allows the flexiblity of grouping menu items in
future as it may be need for system configuration.  In case of help menu

Remove sort order for all modules except for help menu as here we want
that specific order.
2016-06-06 17:44:59 -04:00
James Valleroy
f01575e2ea
Move ldap setup from freedombox-setup to plinth. 2016-05-21 16:06:18 -04:00
Sunil Mohan Adapa
f04e1c1657
Minor PEP8 & spelling fixes in various modules 2016-02-28 19:38:53 +05:30
Sunil Mohan Adapa
bee0260af7
users: Use new setup mechanism 2016-02-13 13:52:22 +05:30
Sunil Mohan Adapa
7f4c5f7410
Make app names as module identifiers
- The last part of the module import path is the module name.  This also
  becomes the Django app name.  Apps names have to be unique.  Hence,
  there is no scope for two different modules with same name but
  different load path to exist in the project.

- Most uses of list of loaded modules are dealing with app names instead
  of full module load path.  This is due to the fact that Django deals
  with app names and not module paths.

- It is also somewhat clumsy to access a loaded module as we are
  re-importing every time to get access module.

- Simplify all of the above by using app names are module identifiers
  and maintaing an ordered dictionary of app names to loadded modules.

- Remove unused imports.

- Minor styling fixes.
2016-02-13 13:49:23 +05:30
Sunil Mohan Adapa
506bff5c7b
users: Multiple SSH keys and better home creation
- Allow setting multiple SSH keys one per line (which is already
  allowed, but advertise it better).

- Use mkhomedir_helper to create the user's home directory.  Avoid
  security and accuracy complexities of creating a home directory.

- Allow homes that don't exist in /home.
2016-01-30 15:30:52 +05:30
James Valleroy
ad7d6db968
users: Add field to set user's SSH key. 2016-01-30 15:30:32 +05:30
Sunil Mohan Adapa
201837518f Update strings during edit/delete operations 2015-12-09 23:55:55 +05:30
Sunil Mohan Adapa
a69f419c3c Make Django urlpatterns list of url()s
- Support for legacy pattern() mechanism will be removed in Django
  1.10.  Currently we see a warning for each Plinth module.
2015-12-05 09:33:23 -05:00
Sunil Mohan Adapa
0b4f56c59d Fix bug in i18n of change password link 2015-11-14 12:05:27 +05:30
Sunil Mohan Adapa
01d50c7ae8 Fix i18n of template expressions 2015-11-14 11:42:32 +05:30
Sunil Mohan Adapa
3df1a88824 Switch to Django i18n for code strings
Django i18n layer is on top of gettext and provide may crucial features
such as per-request locales, lazy translations etc.
2015-11-13 22:08:43 +05:30
Sunil Mohan Adapa
02cd89b60d Internationalize strings in template files 2015-11-13 22:02:17 +05:30
Sunil Mohan Adapa
4210332bf6 users: Improve diagnostics
- Move diagnostics into main module instead of action script.

- Ability run diagnostics as non-root user (because it runs in Plinth
  instead of action).

- Diagnose whether LDAP server is listening.

- Diagnose directory entities created during setup.
2015-08-29 06:22:01 -04:00
Sunil Mohan Adapa
2ca130b154 users: Implement diagnostics 2015-07-28 21:58:17 +05:30
Sunil Mohan Adapa
d363d8db26 users: Use ldapscripts for user management
- Merge all ldap actions into one action.

- Setup ldapscripts using augeas.

- Use the default mechanisms used by ldapscripts.

- Remove adding admin users to 'sudo' group.  Mixing LDAP groups and
  local groups is not a good practice.  'admin' LDAP group will be added
  to sudoers in another patch to freedombox-setup.

- Make all users posixAccount and all groups posixGroup for simplicity.
  Shell access can be restricted in other ways.

- Work around ldapscripts not able to set password using SASL auth.

- Work around ldapscripts having issues with current locale.
2015-07-26 16:33:06 -04:00
Sunil Mohan Adapa
44ec564fd7 users: Fix incorrect replacement of _()
Apologies for the regression.
2015-07-26 13:34:23 -04:00
James Valleroy
d144f6634a Bug fixes:
Check if ejabberd is installed when running actions triggered by signals.
Encode LDAP passwords as bytes.
2015-07-23 22:30:50 +05:30
James Valleroy
cb7c9c26f7 Send LDAP user passwords to actions through stdin, not as arguments. 2015-07-23 22:30:50 +05:30
James Valleroy
86580c9121 Revert "Don't print LDAP user passwords in log."
This reverts commit b1c9c81d58c80d6b313dd2b8a5c5727ecdf6ac49.

Conflicts:
	plinth/modules/first_boot/forms.py
2015-07-23 22:30:50 +05:30
Sunil Mohan Adapa
2b86ce9fdb users: Remove unused code checking for LDAP user 2015-07-18 17:23:04 +05:30
Sunil Mohan Adapa
f35d4257c2 users: Improve Django group handling with LDAP
- Create groups on first boot a bit more safely

- Use get_or_create instead of get() and create()

- Fix issue with not showing a full list of groups in user modify page
  when there is are no users for that group.
2015-07-18 17:17:07 +05:30
Sunil Mohan Adapa
b0d65b4ead users: Use checkboxes for groups during create 2015-07-14 21:23:02 +05:30