86 Commits

Author SHA1 Message Date
Michael Pimmer
00ac068133
Merge ./run --debug into --develop option
Signed-off-by: Michael Pimmer <info@fonfon.at>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-06-18 19:27:38 -04:00
Michael Pimmer
425f7fbd92
Adapt test and documentation to changes of '--develop' option
And re-activate cfg.get_config_paths() for easier testing

Signed-off-by: Michael Pimmer <info@fonfon.at>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-06-18 19:27:31 -04:00
Michael Pimmer
cab5b694cf
Add ./run --develop option to use relative config/file paths
Signed-off-by: Michael Pimmer <info@fonfon.at>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-06-18 19:27:23 -04:00
Sunil Mohan Adapa
c6bccaaac0
Workaround security issues in django-axes
Newer versions of Django axes have newly way to get the IP address of a client
using ipware library. This has multiple security issues
https://github.com/jazzband/django-axes/issues/286 . Workaround them by
controlling the X-FORWARDED-FOR header sent from Apache to FreedomBox and by
limiting the headers that ipware uses.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-03-22 19:09:38 -04:00
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
6bf5109108
Rename Plinth to FreedomBox in code messages
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-02-16 20:10:51 -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
Joseph Nuthalapati
fc9ce8e6dd
Override monkey-patched LoginView from django-axes 3.0.3
- Fixes #1154
- Fixes #1138

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2017-11-30 20:22:01 -05:00
Johannes Keyser
5fb68b459c
Enable django SecurityMiddleware, mitigates issue #1111.
Signed-off-by: Johannes Keyser <johanneskeyser@posteo.de>
Reviewed-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
2017-11-06 11:38:57 +05:30
Joseph Nuthalpati
ab235be2fc
captcha: fix tests failing to start
Signed-off-by: Joseph Nuthalpati <njoseph@thoughtworks.com>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2017-10-17 22:08:17 -04:00
Joseph Nuthalpati
03e1006dc3
sso: utility to fetch client ip address
(django-axes + django-simple-captcha) with sso is working at this point.

Signed-off-by: Joseph Nuthalpati <njoseph@thoughtworks.com>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2017-10-17 22:08:07 -04:00
Joseph Nuthalpati
f330d09ec9
sso: Add captcha validation on 3 failed attempts
- clearing ip address correctly is not implemented yet
- currently clearing all ip addresses

Signed-off-by: Joseph Nuthalpati <njoseph@thoughtworks.com>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2017-10-17 22:07:57 -04:00
Joseph Nuthalpati
31cd97e71e
sso: Add django-axes to project
Signed-off-by: Joseph Nuthalpati <njoseph@thoughtworks.com>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2017-10-17 22:07:48 -04:00
Joseph Nuthalpati
d3c428d58b
captcha: Add flite tts for accessibility
Signed-off-by: Joseph Nuthalpati <njoseph@thoughtworks.com>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2017-10-17 22:07:30 -04:00
Joseph Nuthalpati
6e26c92441
captcha: Fix issue with captcha path when captcha entered is wrong
Signed-off-by: Joseph Nuthalpati <njoseph@thoughtworks.com>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2017-10-17 22:07:22 -04:00
Joseph Nuthalpati
62f26433e8
Add django-simple-captcha in the login page
User will be shown captcha in the second attempt to login if login
fails in the first attempt.

Signed-off-by: Joseph Nuthalpati <njoseph@thoughtworks.com>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2017-10-17 22:07:12 -04: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
Joseph Nuthalpati
2e73d442e9
password: add Django password validators
Added all default Django password validators.

Not enforcing special characters.
https://blog.codinghorror.com/password-rules-are-bullshit/

Signed-off-by: Joseph Nuthalpati <njoseph@thoughtworks.com>

Reviewed-by: Johannes Keyser <johanneskeyser@posteo.de>
2017-09-09 11:34:45 +02:00
Joseph Nuthalpati
bb5571b7ab
first-run: Skip installation of essential modules from Plinth
- Essential modules would be installed by apt as they are already
dependencies of plinth.
- Plinth trying to trigger an installation is unnecessary.
- Plinth installing deb packages might also cause problems with plinth
startup if automatic upgrades are running.
- Added back the --setup option
- setup doesn't run when something else like diagnostics is invoked

Signed-off-by: Joseph Nuthalpati <njoseph@thoughtworks.com>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2017-09-01 20:38:54 -04:00
Sunil Mohan Adapa
c2cf591e1b
Capture and log all Python warnings
- Capture all Python warnings so that they can shown as part of logging system
  on console and in log file.

- Also capture deprecation warnings into logging system if debug mode is
  enabled. Current versions of Python disable deprecation warnings by default.
  Django 1.11 also follows this approach now.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>

Reviewed-by: Johannes Keyser <johanneskeyser@posteo.de>
2017-09-01 13:32:14 +02:00
Joseph Nuthalpati
5403d00e85
SSO: Generate keys during plinth startup
- Removed key generation for mod_auth_pubtkt from first boot.
- Running setup every time plinth starts so that new essential modules
can be setup properly.

Partially fixes #875
2017-06-24 14:59:03 -04:00
Sunil Mohan Adapa
ee7cc98fee
apps, system: Remove modules and merge into main
- Remove apps and system modules and merge their views into main views.

- Move main_menu from cfg into menu.py.

- Remove dependencies of other modules on apps and system modules.

- Update tests.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
2017-05-05 22:31:45 -04:00
Sunil Mohan Adapa
dd196c504d
module_loader: Split the URLs inclusion step
This is useful if we need to perform URL reversing operations before loading
modules.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
2017-05-05 22:31:32 -04:00
Sunil Mohan Adapa
2a3381415e
Prioritize stronghold over admin require middlerware
Not logged-in users accessing restricted URLs will be required to
login page instead of being show access denied page.
2017-02-15 21:08:00 +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
Sunil Mohan Adapa
4699b201a9
Remove use of stronghold whitelisting
This is no longer necessary as both the URLs have been explicitly
marked as public views.
2017-02-15 21:07:19 +05:30
lispyclouds
3e0f7a007e
Update default page after login
- This fixes the redirect to the index page instead of apps:index post
  login
2017-02-15 20:58:05 +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
70a858597a
Refactor module list command 2016-12-14 15:32:44 -05:00
mridulnagpal
fac840ec48
Add command line argument to list modules 2016-12-14 14:34:04 -05:00
Sunil Mohan Adapa
375f594808
Add argument to list packages needed by apps 2016-09-17 13:48:46 -04:00
Sunil Mohan Adapa
8ce6312190
Tune log message verbosity
It is no longer very important to show Django configured applications
and module import messages because in practice we have rarely ever seen
being useful anywhere but for development.  Just print the module load
order just once.
2016-09-17 13:48:42 -04:00
Sunil Mohan Adapa
314eddfcae
Print django migrate messages only in debug 2016-09-17 13:48:39 -04:00
Sunil Mohan Adapa
b097731e40
setup: Fix arguments to setup without install
- When arguments are passed to --setup-no-install, use them correctly.

- Explicitly initialize member in constructor

- Minor indentation
2016-09-03 11:28:58 +05:30
James Valleroy
548e0ebd60
Add --setup-no-install command
Acts the same as --setup, but does not install any packages. Will
raise an error if any required package is not already installed.
2016-09-03 10:02:54 +05:30
Sunil Mohan Adapa
2f1fe8af22
Remove unused setting LOGOUT_URL
Django 1.10 officially does not use the setting LOGOUT_URL anymore.
Django stronghold incorrectly uses it as a URL rather than named url.
2016-08-11 18:02:56 -04:00
Sunil Mohan Adapa
0856d7b090
Work around script prefix problem in stronghold 2016-08-11 18:02:48 -04:00
Hemanth Kumar Veeranki
42e44ec689
Fixed issue with lost menus in Django 1.10 2016-08-11 18:02:36 -04:00
Sunil Mohan Adapa
69a7f847aa
Properly fix setup argument checking 2016-08-01 20:38:42 +05:30
Hemanth Kumar Veeranki
29d20265c1
Removed a small bug of running setup always 2016-08-01 18:58:00 +05:30
Hemanth Kumar Veeranki
60e808e9bb
Added option for plinth --setup
Now plinth --setup could take a list of modules to setup
2016-07-31 14:15:57 +05:30
Sunil Mohan Adapa
9078ec5a2b
Don't write to PID file
When running under systemd, PID is known and maintained by systemd.
Process don't have write PIDs to a PID file.
2016-05-29 21:07:07 +05:30
Sunil Mohan Adapa
1f53321b51
Don't use init.d file, don't daemonize
We pretty much only run in systemd environment and I don't see that
changing any time soon.  By relying on it, we can reduce some burden.
Remove init script.

Daemonizing is not needed for systemd.  Remove code related
daemonization.
2016-05-29 20:32:12 +05:30
Sunil Mohan Adapa
d72abb8539
config: Don't restrict supported languages
- There is no reason to limit the number of languages supported by the
  application.  This is what happens when LANGUAGES is set during Django
  configuration.  Users should be able to set a language using browser
  preferences and see at least the Django translated messages even if
  Plinth messages are not translated (example user create/edit form).

- If we wish to limit the number of language options shown duing
  language selection (for quality perception reasons), we should perform
  the limiting at the time of configuration.

- Note that when a new language is requested in translation tool, we
  create an empty file and that may lead to language being shown but
  with few strings actually translated.  This will have poor impact on
  user experience.  I wonder if we should filter language at all,
  keeping this in mind.
2016-02-26 00:46:09 +05:30
James Valleroy
88c649d310
Handle _ in language codes. 2016-02-26 00:46:02 +05:30
Sunil Mohan Adapa
2c836046a6
main: Add command argument to setup essential apps
- The --setup argument sets up all applications that declare themselves
  as essential.

- This is done synchronously.

- Plinth exits after the setup is complete.

- Plinth fails with an error in case any of the setup tasks fail.  The
  process will be continued on next invocation or access of application
  from UI.
2016-02-13 13:50:20 +05:30
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
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
a1d5486c82 config: Refactor for easy testing
- Split the read method into two separate methods for getting the config
  file and for reading config file.

- Use logging module for printing error.

- Fix global variable naming.

- Get/set/show the realpath of the config file.

- Convert config items into a list so that the order is more
  predictable.  This is the reason for unpredictable failures in test
  cases.
2015-12-05 09:51:50 -05:00