Search code examples
ignitegridgain

GridGain Web Console user creation automated


Is there a way to automate user creation on GridGain Web Console's docker container deployment?

Our test stand deployment is fully automated, and we'd like to deploy Web Agent automatically as well, copying token and starting Agent's container manually every time is not very convenient in our case.


Solution

  • There are several options:

    1. Create a Web Console user with HTTP REST API, grab their token and pass it to the Agent.
    2. Generate your own token (a UUID), pass it to Agent, create a Web Console user with API calls and set their token.

    Please keep in mind that the Web Console HTTP API is considered private. It has been stable for a while, especially the user-related parts, so I wouldn't expect any changes soon. Use it at your own discretion.

    Before sending any requests, make sure you use a cookie jar. Send a "/api/v1/user" GET to initialize a session. The host is the same as WC, but you can also send requests to backend directly. CORS might be an issue.

    In general, you can open browser network inspector, perform actions manually, note what requests are made and perform same requests with a tool of your choice, like curl. Some communications are handled by a Web Socket connection, but not for user management.

    Endpoints you are interested in:

    1. POST "/api/v1/user". Creates a user. Example payload:
    {
        "email": "user@example",
        "password": "1",
        "firstName": "User",
        "lastName": "Name",
        "phone": "+790000000",
        "country": "Russia",
        "company": "GridGain",
        "industry": "Software"
    }
    
    1. POST "/api/v1/profile/save". Edits user. Example payload:
    {
        "firstName": "User",
        "lastName": "Name",
        "email": "test@example",
        "phone": null,
        "country": "Russia",
        "company": "GridGain",
        "industry": "Other",
        "permitEmailContact": false,
        "permitPhoneContact": false,
        "token": "fcf99d68-5a4c-4a43-8abc-1f93e19af26a"
    }
    
    1. GET "/api/v1/user". Gets a user. Example payload:
    {
        "email": "test@example",
        "firstName": "User",
        "lastName": "name",
        "phone": null,
        "company": "GridGain",
        "country": "Russia",
        "admin": false,
        "becomeUsed": false,
        "industry": "Other",
        "permitEmailContact": false,
        "permitPhoneContact": false,
        "token": "fcf99d68-5a4c-4a43-8abc-1f93e19af26a",
        "lastEvent": 0
    }