diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2016-07-06 18:07:22 +0100 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2016-07-19 17:56:22 +0100 |
commit | 6afbfe45183412e35e8e846fd0d4a9d846c8644b (patch) | |
tree | 3f5cb6173c08a571811f0a31508b45acf31d69f7 /bin/createsuperuser | |
parent | 65545553b5171f1ef1d611ea93c38f138451fb31 (diff) |
Use normal user authentication to control access to /admin
- Adds is_superuser flag to User
- Logged-in user must be a superuser or have from_body set in order to access
anything within /admin
- has_permission_to on a superuser will always return true
- Only superusers can create/grant superusers
- New `createsuperuser` command for creating superusers
Diffstat (limited to 'bin/createsuperuser')
-rwxr-xr-x | bin/createsuperuser | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/bin/createsuperuser b/bin/createsuperuser new file mode 100755 index 000000000..98b36aa36 --- /dev/null +++ b/bin/createsuperuser @@ -0,0 +1,33 @@ +#!/usr/bin/env perl + +# createsuperuser: +# Create superusers or grant is_superuser flag to existing users. +# +# Usage: +# +# Create a new superuser with password 'password123' +# $ bin/createsuperuser user1@example.org password123 +# +# Grant superuser status to an existing user: +# $ bin/createsuperuser user2@example.org +# +# Superusers can create superusers and grant/rescind superuser status via /admin +# +# Copyright (c) 2016 UK Citizens Online Democracy. All rights reserved. +# Email: davea@mysociety.org. WWW: http://www.mysociety.org + +use strict; +use warnings; + +BEGIN { + use File::Basename qw(dirname); + use File::Spec; + my $d = dirname(File::Spec->rel2abs($0)); + require "$d/../setenv.pl"; +} + + +use FixMyStreet; +use FixMyStreet::Script::CreateSuperuser; + +FixMyStreet::Script::CreateSuperuser::createsuperuser(); |