diff options
| author | Barry Warsaw | 2011-03-18 14:18:30 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2011-03-18 14:18:30 -0400 |
| commit | b81ebbf535e8a53b10d4b0f82ecedd8971314610 (patch) | |
| tree | 34e316aca6c61db56e31355fcee0ae10352d879c | |
| parent | ef3a4a87e2c0f4b640e31afc4828d2edbd005846 (diff) | |
| download | mailman-b81ebbf535e8a53b10d4b0f82ecedd8971314610.tar.gz mailman-b81ebbf535e8a53b10d4b0f82ecedd8971314610.tar.zst mailman-b81ebbf535e8a53b10d4b0f82ecedd8971314610.zip | |
| -rw-r--r-- | src/mailman/bin/mmsitepass.py | 113 | ||||
| -rw-r--r-- | src/mailman/rest/docs/users.txt | 16 | ||||
| -rw-r--r-- | src/mailman/rest/root.py | 8 | ||||
| -rw-r--r-- | src/mailman/rest/users.py | 38 |
4 files changed, 62 insertions, 113 deletions
diff --git a/src/mailman/bin/mmsitepass.py b/src/mailman/bin/mmsitepass.py deleted file mode 100644 index c17d87526..000000000 --- a/src/mailman/bin/mmsitepass.py +++ /dev/null @@ -1,113 +0,0 @@ -# Copyright (C) 1998-2011 by the Free Software Foundation, Inc. -# -# This file is part of GNU Mailman. -# -# GNU Mailman is free software: you can redistribute it and/or modify it under -# the terms of the GNU General Public License as published by the Free -# Software Foundation, either version 3 of the License, or (at your option) -# any later version. -# -# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -# more details. -# -# You should have received a copy of the GNU General Public License along with -# GNU Mailman. If not, see <http://www.gnu.org/licenses/>. - -import sys -import getpass -import optparse - -from mailman import Utils -from mailman import passwords -from mailman.configuration import config -from mailman.core.i18n import _ -from mailman.initialize import initialize -from mailman.version import MAILMAN_VERSION - - - -def parseargs(): - parser = optparse.OptionParser(version=MAILMAN_VERSION, - usage=_("""\ -%prog [options] [password] - -Set the site or list creator password. - -The site password can be used in most if not all places that the list -administrator's password can be used, which in turn can be used in most places -that a list user's password can be used. The list creator password is a -separate password that can be given to non-site administrators to delegate the -ability to create new mailing lists. - -If password is not given on the command line, it will be prompted for. -""")) - parser.add_option('-c', '--listcreator', - default=False, action='store_true', - help=_("""\ -Set the list creator password instead of the site password. The list -creator is authorized to create and remove lists, but does not have -the total power of the site administrator.""")) - parser.add_option('-p', '--password-scheme', - default='', type='string', - help=_("""\ -Specify the RFC 2307 style hashing scheme for passwords included in the -output. Use -P to get a list of supported schemes, which are -case-insensitive.""")) - parser.add_option('-P', '--list-hash-schemes', - default=False, action='store_true', help=_("""\ -List the supported password hashing schemes and exit. The scheme labels are -case-insensitive.""")) - parser.add_option('-C', '--config', - help=_('Alternative configuration file to use')) - opts, args = parser.parse_args() - if len(args) > 1: - parser.error(_('Unexpected arguments')) - if opts.list_hash_schemes: - for label in passwords.Schemes: - print str(label).upper() - sys.exit(0) - return parser, opts, args - - -def check_password_scheme(parser, password_scheme): - # shoule be checked after config is loaded. - if password_scheme == '': - password_scheme = config.PASSWORD_SCHEME - scheme = passwords.lookup_scheme(password_scheme.lower()) - if not scheme: - parser.error(_('Invalid password scheme')) - return scheme - - - -def main(): - parser, opts, args = parseargs() - initialize(opts.config) - opts.password_scheme = check_password_scheme(parser, opts.password_scheme) - if args: - password = args[0] - else: - # Prompt for the password - if opts.listcreator: - prompt_1 = _('New list creator password: ') - else: - prompt_1 = _('New site administrator password: ') - pw1 = getpass.getpass(prompt_1) - pw2 = getpass.getpass(_('Enter password again to confirm: ')) - if pw1 <> pw2: - print _('Passwords do not match; no changes made.') - sys.exit(1) - password = pw1 - Utils.set_global_password(password, - not opts.listcreator, opts.password_scheme) - if Utils.check_global_password(password, not opts.listcreator): - print _('Password changed.') - else: - print _('Password change failed.') - - - -if __name__ == '__main__': - main() diff --git a/src/mailman/rest/docs/users.txt b/src/mailman/rest/docs/users.txt new file mode 100644 index 000000000..418b07f4c --- /dev/null +++ b/src/mailman/rest/docs/users.txt @@ -0,0 +1,16 @@ +===== +Users +===== + +The REST API can be used to add and remove users, add and remove user +addresses, and change their preferred address, passord, or name. Users are +different than members; the latter represents an email address subscribed to a +specific mailing list. Users are just people that Mailman knows about. + +There are no users yet. + + >>> dump_json('http://localhost:9001/3.0/users') + http_etag: "..." + start: 0 + total_size: 0 + diff --git a/src/mailman/rest/root.py b/src/mailman/rest/root.py index 9d8c92428..35bd8e12d 100644 --- a/src/mailman/rest/root.py +++ b/src/mailman/rest/root.py @@ -34,6 +34,7 @@ from mailman.rest.domains import ADomain, AllDomains from mailman.rest.helpers import etag, path_to from mailman.rest.lists import AList, AllLists from mailman.rest.members import AllMembers +from mailman.rest.users import AllUsers @@ -108,3 +109,10 @@ class TopLevel(resource.Resource): if len(segments) == 0: return AllMembers() return http.bad_request() + + @resource.child() + def users(self, request, segments): + """/<api>/users""" + if len(segments) == 0: + return AllUsers() + return http.bad_request() diff --git a/src/mailman/rest/users.py b/src/mailman/rest/users.py new file mode 100644 index 000000000..308291507 --- /dev/null +++ b/src/mailman/rest/users.py @@ -0,0 +1,38 @@ +# Copyright (C) 2011 by the Free Software Foundation, Inc. +# +# This file is part of GNU Mailman. +# +# GNU Mailman is free software: you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) +# any later version. +# +# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# GNU Mailman. If not, see <http://www.gnu.org/licenses/>. + +"""REST for users.""" + +from __future__ import absolute_import, unicode_literals + +__metaclass__ = type +__all__ = [ + 'AUser', + 'AllUsers', + ] + + + +class _UserBase(resource.Resource, CollectionMixin): + """Shared base class for user representations.""" + + def _resource_as_dict(self, user): + """See `CollectionMixin`.""" + # The canonical URL for a user is their preferred email address, + # although we can always look up a user based on any registered and + # validated email address associated with their account. + return dict( |
