15 Commits

Author SHA1 Message Date
James Valleroy
2ea575806d
middleware: Skip 'installed' message for essential apps
Closes #1085.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
2018-04-09 19:10:49 +05:30
Sunil Mohan Adapa
1da594c32d
Support Django 2.0
This is the final change required for Django 2.0 support. Instead of using
MIDDLEWARE_CLASSES use MIDDLEWARE setting. Support for new style middleware was
provided in version 0.3.0, so depend on that version. Django built-in middleware
already supports new style and plinth middleware will now support new style.

The actual semantics of the middleware don't need changes. See:
https://docs.djangoproject.com/en/2.0/topics/http/middleware/#upgrading-pre-django-1-10-style-middleware

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-03-12 17:27:26 -04: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
1247f2ef93
setup: Prioritize FirstSetupMiddle over some others
- Minor PEP8 fixes.
- Add doc strings.
- Make a few methods private.
- Remove unused global declarations.
- Remove unused imports.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
2017-10-11 18:13:14 +05:30
Joseph Nuthalpati
7ce56864e9
setup: Fix Plinth startup issues
- Selectively run setup for modules
- Middleware pending

Fixes #1024

Signed-off-by: Joseph Nuthalpati <njoseph@thoughtworks.com>
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2017-10-11 18:12:45 +05:30
Soumya97
6a53dd015e
context_processor: Cache whether user is admin (Closes: #781) 2017-04-18 16:01:48 +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
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
Sunil Mohan Adapa
b7a974e326
setup: Fix an infinite redirect in a rare case
Don't try to show setup view for login page.  This happens under a rare
circumstance that user does not usually face.  If 'users' module has not
been setup but we try to run first boot and last part of the firstboot
process is not yet completed and when user is not already logged in, an
infinite redirect happens.

Simply don't try to show setup view for login URL under any
circumstance.  This is similar to how firstboot middleware itself does
not meddle with login URL.
2017-01-19 18:46:06 -05:00
fonfon
da91981ff5
Prevent anonymous users from accessing any setup page
Anonymous users were able to access pages that used
the 'public' decorator of stronghold. If such a page
showed the installation routine of the setup module
they were able to access and use it, in other words:
Anonymous users were able to install software.
2016-12-28 19:35:04 -05:00
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
Sunil Mohan Adapa
cde615aee6
middleware: Don't interfere in 404 URLs in setup
Don't raise a 404 exception when a page is not found.  Instead, simply
bypass the setup middleware so that other middleware have a chance to
process further.

Slight modification so that resolve method can be mocked during
unittests.
2016-06-02 20:13:40 -04:00
Sunil Mohan Adapa
f34cb78867
middleware: Fix anonymous access to setup view
Django runs process_request() on all the middleware classes in order.
Then it runs process_view() on all of them again.  During the runs, if
any of the views return a HttpResponse.  Further processing is ignored.

Setup middleware was handling process_request() and returning
HttpResponse if the application as not setup.  However, stronghold
middleware handles process_view().  Since process_request happens first
and response is being returned there, stronghold middleware is never
called.

Make setup middleware use process_view() instead.
2016-06-02 20:13:35 -04:00
Sunil Mohan Adapa
8dcafe3e0e
middleware: New middleware to check need for setup
- Call the setup helper to check if a installation or update of a module
  is required.

- Show installation and progress using the setup view.
2016-02-13 13:50:16 +05:30