New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quesiton: How to create a user with fauxapi #26

Closed
Jgerardopine opened this Issue Jul 12, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@Jgerardopine

Jgerardopine commented Jul 12, 2018

HI,

I was trying to create a user with fauxapi. From dev shell you can create a new user by running the following command:

$config['system']['user'][] = <name>

The only .inc file that makes sense of creatin a user is auth.inc line 480.
I have tried with several functions with the method function_call() from fauxapi, but it doesn't create the user.
Have you been able to generate a user via fauxapi? I have been trying all day, eventhough the function is passing the arguments properly, and in the debugging is showing but the 200 ok, the user is not being created. Fo you have any clue on how to do this?

Best regards,

Jose Gerardo Pineda

@ndejong

This comment has been minimized.

Owner

ndejong commented Aug 16, 2018

This sounded like a common enough use-case that I created some example code that implements the following:-

  • get_users - returns a dict of users on the system
  • add_user - adds a new user to the system
  • manage_user - manages users attributes such as password, sshkey, description and privileges
  • remove_user - removes a user by username
  • get_groups - returns a dict of groups on the system
  • add_group - creates a new local user group
  • manage_group - manages the description, privileges and users in a group
  • remove_group - removes a group by group name

You can review the code here:-
https://github.com/ndejong/pfsense_fauxapi/blob/master/extras/examples/usergroup-management.py

The thing to remember is that FauxAPI is a tool for interacting with the pfSense configuration file and as such you sometimes need to do a bit of extra work here and there - in this case we need to increment the nextuid and nextguid fields after adding users and groups - works just fine though

@ndejong ndejong closed this Aug 16, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment