Edgewall Software

Ticket #2456 (new enhancement)

Opened 3 years ago

Last modified 3 months ago

Implement API for user management

Reported by: eblot Owned by: jonas
Priority: normal Milestone: 0.13
Component: general Version: 0.9.2
Severity: major Keywords: user
Cc: wkornewald, ilias@…, danny.adair@…, r.sokoll@…, crippledcanary@…, gt4329b@…, silk@…, xgravity@…, lafeuil@…, catalin.balan@…, ThurnerRupert, mladen@…, d.grellscheid@…, tolsen@…

Description

I'm adding this ticket to keep track of the on-going discussion about creating a new 'user detail' interface to Trac.

The new interface would be something like:

class IUserProvider(Interface):

  def get_known_users(attrs=('name', 'email'), limit=None):
      pass

  def get_user_attribute(user, attr):
      pass

  def get_supported_attributes():
      pass

Related ML thread:

Attachments

userdir-for-r2637.diff (9.4 KB) - added by brad <brad@…> 3 years ago.
patch 1 for UserDirectory? plugin
userdir-for-r2659.diff (9.8 KB) - added by brad <brad@…> 3 years ago.
patch 2 for UserDirectory? plugin
userdir-for-r3271.diff (10.0 KB) - added by brad <brad@…> 3 years ago.
patch 3 for UserDirectory? plugin
user.py (6.5 KB) - added by wkornewald 2 years ago.
first suggestion
user.2.py (8.6 KB) - added by wkornewald 2 years ago.
now with User object, still completely untested
user.3.py (8.9 KB) - added by wkornewald 2 years ago.
now with User object, still completely untested
user_API.diff (21.2 KB) - added by wkornewald 2 years ago.
patch against trunk (0.11)
user_API.2.diff (27.0 KB) - added by Waldemar Kornewald <wkornewald> 2 years ago.
don't expose email address (users want privacy!), optimizations for huge numbers of users (no more email_map)
user_API_r4501.diff (23.4 KB) - added by Waldemar Kornewald <wkornewald> 2 years ago.
updated patch for show_email_addresses option. added a generic attribute mapper.
userdir-for-r4673-0.10-stable.diff (5.4 KB) - added by Brad Anderson <brad@…> 22 months ago.
updated patch for 0.10 branch, untested
userdir-for-r4673-0.10-stable2.diff (10.6 KB) - added by Peter Dimov <peter.dimov@…> 22 months ago.
The previous patch does not create trac/userdir.py and does not patch trac/notification.py this one does…
user_API_r4938.diff (22.8 KB) - added by Waldemar Kornewald <wkornewald> 21 months ago.
resolved conflicts with most recent refactorings. also, we now use get_users_with_permission() which simplifies the code
user_API_r5898.diff (22.5 KB) - added by Morris 16 months ago.
patch for r5898 -- I have lots of other mods, so here's hoping that I filtered them all out of this patch…
user_API_r5898.1.diff (22.4 KB) - added by Morris 15 months ago.
deprecates user_API_r5898.diff (which removed 2 lines from trac/notification.py in error)
user_API_r6033.diff (22.0 KB) - added by Morris 14 months ago.
User API patch for trunk (0.11dev) r6033

Change History

  Changed 3 years ago by brad <brad@…>

I have attached a preliminary patch that is at least working for my needs. There is some hard-coding around user attributes, and my Python skills are not that strong, so another set of eyes would be great. Hopefully it's a good start based on the discussion in the mailing list. Feedback is welcome.

Also, there are development notes and questions here: http://trac.dsource.org/projects/test/wiki/UserDirectory - should we use that wiki or this bug?

Changed 3 years ago by brad <brad@…>

patch 1 for UserDirectory? plugin

Changed 3 years ago by brad <brad@…>

patch 2 for UserDirectory? plugin

Changed 3 years ago by brad <brad@…>

patch 3 for UserDirectory? plugin

  Changed 2 years ago by brad <brad@…>

  • milestone set to 0.12

  Changed 2 years ago by wkornew

Why don't you want to add this as an officially supported feature? I doesn't disturb anyone.

  Changed 2 years ago by eblot

wkornew: I'm not sure to understand your point: if we introduce the IUserDirectory interface, Trac engine needs to be modified so that it retrieves the user properties from a IUserDirectory implementation, rather than from a current direct access to the user session data.
Can you elaborate?

  Changed 2 years ago by anonymous

The user session data is independent of the user's login when using the DbAuth? plugin, for example. It would be very nice to have email notifications use the email address stored in the user's database. Also, the real name could be retrieved from the DB, too. We need a unified single interface for this. Session data is not a good solution when requiring registration+authentication. Unfortunately, you are using a very open model, by default, so you probably don't see a need for it, but big projects must have this.

  Changed 2 years ago by wkornew

  • cc wkornew added

  Changed 2 years ago by anonymous

  • cc gunnar@… added

Is there any timeline when 0.12 will be eventually out of the door?

I'm planning a migration from StarTeam? to Subversion for our company by the end of this year. We also need a new tracking system. But this is one of the big issues that makes it really hard for me to keep Trac on the list.

I need to be able to read full names and email addresses from LDAP/Active Directory automatically at logon. The users shouldn't even be able to change it.

  Changed 2 years ago by anonymous

  • cc gunnar@… removed

  Changed 2 years ago by wkornewald

  • cc wkornewald added; wkornew removed

What is needed to get this working? I might want to hack on this a little bit next month.

Is anything missing? Does more Trac code need to be changed? For example, I could imagine that the session UI should be removable.

Do you not like the interface? What should the interface look like?

Changed 2 years ago by wkornewald

first suggestion

  Changed 2 years ago by wkornewald

Guys, is the API in attachment:user.py good enough? Please take a look. IUserStore is similar to AccountManager?'s IPasswordStore. I don't want to waste time on this and then be told that you won't accept anything.

  Changed 2 years ago by Manuzhai

While I agree that it would be nice to have this functionality (but then I'm not a Trac developer), I don't particularly like your patch. Seems to me that it allows too many variations. A Trac-like approach would be more convention, less configuration, I think: supporting a small fixed set of operations on users. Also the get_attribute, set_attribute and del_attribute are smelly, since Python just has getattr, setattr and delattr (as well as property()s, by the way).

  Changed 2 years ago by wkornewald

I based the API on the AccountManager? plugin. The has_user operation could be removed. The rest of the operations are necessary because I want the API to not only provide existing user information, but also allow for real user management. It should be the backend for all user modules (DbAuth?, LDAP, .htaccess, etc.). The current IAuthenticator interface is too complicated and duplicates code for cookie handling and the login dialog.

Trac must finally get real user registration and management support.

What exactly did you want to have? I'm thinking about moving most of the UserManager? code into a User class, so UserManager? only has get_usernames() => string array, create_user(username, password) => User, and get_user(username) => User. The user object then has all the other methods (attributes, password, deletion). Would that be better?

Changed 2 years ago by wkornewald

now with User object, still completely untested

Changed 2 years ago by wkornewald

now with User object, still completely untested

Changed 2 years ago by wkornewald

patch against trunk (0.11)

  Changed 2 years ago by wkornewald

Please try this patch. I've tested it on my local machine in authenticated and unauthenticated state. It seems to work without any bugs, now.

The only issue I have is that every component must implement the supports_xxx methods. Since it's a two-liner, by default, it's probably not such a big problem. Any suggestion for an elegant fix?

  Changed 2 years ago by ilias@…

  • cc ilias@… added

Changed 2 years ago by Waldemar Kornewald <wkornewald>

don't expose email address (users want privacy!), optimizations for huge numbers of users (no more email_map)

Changed 2 years ago by Waldemar Kornewald <wkornewald>

updated patch for show_email_addresses option. added a generic attribute mapper.

follow-up: ↓ 16   Changed 2 years ago by Waldemar Kornewald <wkornewald>

While it would be nice to have an admin interface, I think this is a task for 0.12. It would be very useful to have the user API for 0.11, though. This way, people could update their plugins before 0.12 is out. This is already important functionality. The rest can come with 0.12. Could you please commit the patch?

I wish you a Happy Christmas!

in reply to: ↑ 15 ; follow-up: ↓ 17   Changed 23 months ago by cboos

Replying to Waldemar Kornewald <wkornewald>:

Could you please commit the patch?

Well, not directly in that form, but we agreed to create a sandbox branch for fine tuning the patch, please get in contact with jonas for svn commit access.

in reply to: ↑ 16   Changed 22 months ago by Waldemar Kornewald <wkornewald>

Replying to cboos:

Replying to Waldemar Kornewald <wkornewald>:

Could you please commit the patch?

Well, not directly in that form, but we agreed to create a sandbox branch for fine tuning the patch, please get in contact with jonas for svn commit access.

I'm a much too busy right now, but maybe in the holidays (around mid-February) I could do some more work. What exactly did you want to have changed?

  Changed 22 months ago by Waldemar Kornewald <wkornewald>

BTW, I'm on the dev list, so you can also contact me there.

Changed 22 months ago by Brad Anderson <brad@…>

updated patch for 0.10 branch, untested

Changed 22 months ago by Peter Dimov <peter.dimov@…>

The previous patch does not create trac/userdir.py and does not patch trac/notification.py this one does...

  Changed 22 months ago by danny.adair@…

  • cc danny.adair@… added

  Changed 21 months ago by r.sokoll@…

  • cc r.sokoll@… added

Changed 21 months ago by Waldemar Kornewald <wkornewald>

resolved conflicts with most recent refactorings. also, we now use get_users_with_permission() which simplifies the code

  Changed 21 months ago by Waldemar Kornewald <wkornewald>

  • summary changed from Define IUserDirectory interface to Implement API for user management

The code is untested, but it should work since I didn't do any big changes. *crossing fingers* :)

  Changed 20 months ago by anonymous

  • cc crippledcanary@… added

  Changed 16 months ago by Morris

  • cc gt4329b@… added

Anyone working on this?

I'm in dire need of the ability to go grab an email address from an LDAP/AD server, querying by Trac username (as sAMAccountName, in my case). I've posted to the ML ...and was referred back to this ticket -- which I had already discovered and actually had open in the next tab while writing my ML post :D

If I can get past my (hopefully) last hurdle, I'd be more than happy to package up my hack -- which is much humbler in scope than the IUserProvider concept -- and stick it on Trac-Hacks, as a temporary gap-filler until the fuller IUserProvider functionality is up. Jump in the thread on the users ML (Getting email address from LDAP/AD) if you'd like to monitor/contribute to this gap-filler effort...

follow-up: ↓ 25   Changed 16 months ago by Morris

Welp, since no one seems to be active on this at the moment - and I need it - I suppose I'll start fumbling around with it. I've got a patch/diff that brings it up to r5898; if anyone wants it, lemme know.

in reply to: ↑ 24   Changed 16 months ago by r.sokoll@…

Replying to Morris:

Welp, since no one seems to be active on this at the moment - and I need it - I suppose I'll start fumbling around with it. I've got a patch/diff that brings it up to r5898; if anyone wants it, lemme know.

I'm very interestet in your patch - can you post it here? Also, it would be great if someone with write permissions to t.e.o could apply your patch to sandbox/testing.

  Changed 16 months ago by ThurnerRupert

is there a relationship to #3737, or is it even the same?

Changed 16 months ago by Morris

patch for r5898 -- I have lots of other mods, so here's hoping that I filtered them all out of this patch...

  Changed 15 months ago by Morris

This is a replacement for the patch user_API_r5898.diff -- the original version of that patch erroneously removes two lines from trac/notification.py that leads to the [notification] ignore_domains being ignored. This updated patch shouldn't remove those lines.

If you've already applied the original user_API_r5898.diff patch, you can by-hand add the following lines back in to trac/notification.py:182 (the very end of the NotifyEmail.__init__ method):

        domains = self.env.config.get('notification', 'ignore_domains', '')
        self._ignore_domains = [x.strip() for x in domains.lower().split(',')]

Sorry for the inconvenience.

Changed 15 months ago by Morris

deprecates user_API_r5898.diff (which removed 2 lines from trac/notification.py in error)

  Changed 15 months ago by anonymous

  • cc silk@… added

  Changed 15 months ago by anonymous

  • cc xgravity@… added

  Changed 15 months ago by cboos

  • keywords user added

  Changed 15 months ago by anonymous

  • cc lafeuil@… added

Changed 14 months ago by Morris

User API patch for trunk (0.11dev) r6033

  Changed 14 months ago by Morris

OK -- I've revisited this concept. Development on IUserDirectory is currently slated for 0.12, but I needed more flexibility now.

What I needed was a way to allow specification of the users available in the "Assign To" dropdown, customizable on a per workflow-state basis -- so I've created a plugin that enables just that. The general idea is that after installing this plugin, which I'm calling FlexibleAssignTo, you write your own plugin that implements a getUsers() method that is itself called by FlexibleAssignTo (FlexibleAssignTo implements a new extension point, IValidOwnerProvider). Your own getUsers() method can get a user list from wherever it needs to -- in my case, that's LDAP/AD, but you could write your getUsers() to return users from wherever.

As luck would have it, trac-hacks is down -- so until it's back up and I've got a proper plugin page in place, check out the FlexibleAssignTo thread on the trac-users list for a full overview of the plugin's functionality.

  Changed 13 months ago by catalin.balan@…

  • cc catalin.balan@… added

Hi,

I've just posted on Trac-Hacks.org a new plugin named TeamRosterPlugin. This plugin tries to solve some 'requirements' mentioned here(user details), but it's more focused on user's "meta data" and less on authentification/permissions/etc, because I'm using it in combination with Account Manager plugin, combination which proved to be a very bad one because workspace admins need to use at least +3 "screens" in order to setup one user(very very confusing for them).

I'm sorry that I didn't know about this ticket until now(which is strange since it's is 2 years old), but, since we're trying to solve the same problem, the apis are somewhat similar(or ... "great minds think alike" :) ).

Since we are trying to do the same thing, I would like to 'synchronize', somehow, my api with this one(r6033) and hopefully, at some point, solve the +3 "screens" problem, but also I would like to point out some features that my plugin has, like:

  • Multiple User Providers(~UserAttributesProviders?) one UserStore?, which basically means that workspace admins can select a user from various "data sources"(ldap, another workdpace(s).... ) and add to UserStore? by a single click.(and customize that profile for the current workspace).
  • Why delete users, why not just disable them since they already interacted with the environment.

Waiting for your feedback.

Best regards,
Catalin BALAN

follow-up: ↓ 35   Changed 13 months ago by ThurnerRupert

  • cc ThurnerRupert added

would your plugin also allow to solve #3737, i.e. providing a login-id used for authentication, and a nick for entering in cc, assign, reassign, ...? or would this require a "login-plugin"?

in reply to: ↑ 34   Changed 13 months ago by anonymous

Replying to ThurnerRupert:

would your plugin also allow to solve #3737, i.e. providing a login-id used for authentication, and a nick for entering in cc, assign, reassign, ...? or would this require a "login-plugin"?

Well, my plan is to have one think that can solve "everything" related to user management. And yes, I think that #3737 can also be solved with my plugin.

  Changed 11 months ago by anonymous

  • cc mladen@… added

You Akismet is way too strict. I had to add this comment after it would allow me to just add myself in the cc column.

  Changed 10 months ago by catalin.balan@…

Hi

Just wanted to let you know that I've posted a new plugin on Track-Hacks named UserManagerPlugin. (I'll add screenshoots soon)

Waiting for your feedback.

-- Catalin Balan

  Changed 5 months ago by d.grellscheid@…

  • cc d.grellscheid@… added

  Changed 5 months ago by cboos

  • type changed from task to enhancement
  • severity changed from normal to major

  Changed 4 months ago by anonymous

  • priority changed from normal to highest
  • severity changed from major to critical
  • milestone changed from 0.13 to 0.12

Wow! 3 years to implement such a simple feature.

This truly sucks!

  Changed 3 months ago by ebray

  • priority changed from highest to normal
  • severity changed from critical to major
  • milestone changed from 0.12 to 0.13

  Changed 3 months ago by tolsen@…

  • cc tolsen@… added

Add/Change #2456 (Implement API for user management)

Author



Change Properties
<Author field>
Action
as new
as The resolution will be set. Next status will be 'closed'
to The owner will change from jonas. Next status will be 'new'
The owner will change from jonas to anonymous. Next status will be 'assigned'
 
Note: See TracTickets for help on using tickets.