majewsky / portunus

Self-contained user/group management and authentication service
GNU General Public License v3.0
75 stars 5 forks source link

What is the best way to programmatically add/modify users? #15

Open Silver-Golden opened 1 year ago

Silver-Golden commented 1 year ago

Hi there,

Is there any way to programatically add/modify users?
I tried using ldapmodify -x -H ldap://sso.example.com -D "uid=portunus,dc=example,dc=com" -w adminPass -f record_to_be_added.ldif but that didnt work out (found out afterwards by looking at teh code that the /var/lib/portunus/database.json is basiclaly the source of truth).

While I was looking I also didnt see anything like a rest api or anything.

I also took a look at seeding, however that has the drawback of everything having to be eitehr public or somethign to generate it.

The system I am planning this for is about 100-200 accounts, some of which will have to be enabled and disabled on a regular enough basis (a socirty with annual membership).

So as the title says any recommendations for automation?
Is it possible?

SuperSandro2000 commented 1 year ago

There are seeds https://github.com/majewsky/portunus#seeding-users-and-groups-from-static-configuration and you could use the undocumented API (https://github.com/majewsky/portunus/blob/master/internal/frontend/core.go#L40-L64) which has no stability guarantees.

Silver-Golden commented 1 year ago

I checked out seeds, dosent scale well though,
AS for the undocumented api, if it were a personal project then I would consioder it, howeevr I would like something far more stable :-/

majewsky commented 9 months ago

the undocumented API [...] which has no stability guarantees

As proven by today's near-complete rewrite of the core to get test coverage going.

The stable API that exists is the database file. Portunus will pick up external changes to that file, so if you build something that updates the database file directly, that will work reliably (as demonstrated by the newly added test suite).

A more conventional API could be added in the future, but I don't have immediate plans for it. I'll leave this issue open in case I work on this eventually, or someone comes along who is interested in adding that.