Skip to content

emCOMP/restuser

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RESTUser

A minimal REST API on HTTP + Unix sockets for creating users.

POST http+unix:[/path/to/restuser.sock]/username

to create a new user. Reply is a JSON dict of the pwd struct:

{
 "dir": "/home/foo",
 "gid": 1000,
 "name": "foo",
 "shell": "/bin/bash",
 "uid": 1000
}

Run with:

sudo mkdir /var/run/restuser
sudo python restuser.py --socket=restuser.sock

Mount the socket in a docker container with:

docker run -v restuser.sock:/var/run/restuser.sock -t yourimage

This will mount the host's restuser.sock as /var/run/restuser.sock on the container, giving the container permission to create users on the host machine.

Test

You can test both the server and a client in docker containers.

Build the images:

docker build -t restuser .
docker build -t restuser-test test

Run the server:

docker run --name users -d -t restuser

Run the test client:

docker run --volumes-from=users -it restuser-test

Verify the new users:

docker exec -it users tail -n 5 /etc/passwd

Finally, violently destroy the server:

docker rm -f users

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%