A Python-based server for managing Windows users and groups. This app is supposed to be used in a pair with Identity Provider Synchronization Service , but it's okay to use standalone.
Every endpoint requires an OAuth2 Bearer token retrieved from the Keycloak OAuth2 provider.
Endpoint: POST /users/create/
JSON request body explanation:
{
"username": "username",
"password": "plain-text-password" (optional)
}
Endpoint: GET /users/
Endpoint: GET /users/<username>/
Endpoint: PATCH /users/update-password/<username>/
JSON request body explanation:
{
"password": "plain-text-password"
}
Endpoint: PATCH /users/enable/<username>/
Endpoint: PATCH /users/disable/<username>/
Endpoint: PATCH /users/delete/<username>/
Endpoint: POST /groups/create/
JSON request body explanation:
{
"name": "usergroup-name",
"description": "description" (optional)
"users": ["username0", "username1"] (optional)
}
Endpoint: GET /groups/
Endpoint: GET /groups/<usergroup-name>/
Endpoint: GET /groups/<usergroup-name>/users/
Endpoint: GET /groups/<usergroup-name>/included-users/
This endpoint expects a request body like described below and returns users that are members of the user group.
JSON request body explanation:
{
"users": ["username0", "username1", "username2"]
}
Endpoint: PATCH /groups/rename/<usergroup-name>/
JSON request body explanation:
{
"name": "some-new-name"
}
Endpoint: PATCH /groups/add-user/<usergroup-name>/<username>/
Endpoint: DELETE /groups/delete/<usergroup-name>/
Endpoint: DELETE /groups/remove-user/<usergroup-name>/<username>/
A change monitor. Checks if groups and users match the database on the remote. If you're using this server without an intent to reach the remote, please, don't try to call following endpoints. Especially, if you've set corresponding environment variables to empty or dummy values.
Endpoint: POST /monitor/start_monitor/
URL parameters: interval
This will start the monitoring of users and groups once in interval
or 1 hour if the interval
is not specified.
Basically, this server will request groups and the client blacklist from the remote,
filter local entries according to the blacklist and check if the local entries array has the same length.
Warning: to avoid errors, ID of the client (which represents this server) registered on the remote
should match the value of the SERVER_NAME
environment variable.
Endpoint: POST /monitor/stop_monitor/
This section describes the environment variables used by the server.
SERVER_NAME
- the name of this server. BE AWARE:DJANGO_SECRET_KEY
- you can refer to this topic for instructionsEUREKA_URL
- the full URL of the Eureka server. This variable has a default value:http://localhost:8761/eureka
. But very likely will be required to be changed depending on your specific setup
PRINCIPAL_ROLE_NAME
- the role that the OAuth2 user should have to accesssecured
endpoints. Has a default value:administrator
. Note that the token used to access this app should contain the roleKC_HOST
- the host of the Keycloak serverKC_REALM
- theRealm
that the associated with this application client on the Keycloak server belongs toKC_CLIENT_ID
- theclient ID
associated with this application's client on the Keycloak serverKC_CLIENT_SECRET
- the clientclient secret
associated with this application's client on the Keycloak server
Remote's OAuth2
For standalone usage set following variables to empty or dummy values
REMOTE_SERVICE_OAUTH2_TOKEN_URL
- thetoken url
of the OAuth2 provider that the remote is registered inREMOTE_SERVICE_OAUTH2_CLIENT_ID
- theclient ID
of the client that represents the remote in the OAuth2 provider that it's registered inREMOTE_SERVICE_OAUTH2_CLIENT_SECRET
- theclient secret
of the client that represents the remote in the OAuth2 provider that it's registered inREMOTE_SERVICE_OAUTH2_USERNAME
- theusername
of the user that is authorized to access the client that represents the remote in the OAuth2 provider that it's registered inREMOTE_SERVICE_OAUTH2_PASSWORD
- thepassword
of the user that is authorized to access the client that represents the remote in the OAuth2 provider that it's registered in
- Clone the repository:
git clone https://github.com/ExtKernel/win-user-sync-local-server.git
- Navigate to the directory:
cd win-user-sync-local-server
- Create a virtual environment:
python -m venv venv
- Activate the environment:
source venv/bin/activate
- Install dependencies:
pip install -r requirements.txt
- Run the server:
For
python manage.py runserver <host:port> --settings=config.settings.<desired-settings-config>
<desired-settings-config>
you can choose either fromlocal
orproduction
-
Pull the image:
docker pull exkernel/win-user-sync-server:<VERSION>
-
Run the container:
docker run --name=win-user-sync-server -p 8000:8000 exkernel/win-user-sync-server:<VERSION>
- You can map any external port you want to the internal one
- You can give any name to the container
Remember to specify environment variables using the
-e
flag: -e SERVER_NAME
-e EUREKA_URL
-e PRINCIPAL_ROLE_NAME
You may also specify the optional ones if you want:
-e REMOTE_SERVICE_OAUTH2_TOKEN_URL
-e REMOTE_SERVICE_OAUTH2_CLIENT_ID
-e REMOTE_SERVICE_OAUTH2_CLIENT_SECRET
-e REMOTE_SERVICE_OAUTH2_USERNAME
-e REMOTE_SERVICE_OAUTH2_PASSWORD