UI User Authentication

Ok. While I work through the Odoo implementation, I would like to try a the more simple approach provided by using Metadata. I have a working OpenEMS Edge installation on a Pi server, a working OpenEMS Backend installation on another Pi, and OpenEMS UI running on the same Backend server. When I use the UI login, it defaults to the demo admin/admin user and displays no Edge devices upon login.

So, I have created a file called devices.json which lives on the Backend server that is being read by the Controller Api Backend from OpenEMS Edge. On the Backend server, I have enabled a Metadata.File bundle that points to the devices.json file. The API key in that Edge websocket configuration is confirmed to be reading from the Backend devices.json file that contains this:

    {
        "edges": {
            "edge0": {
                "comment": "Edge #0",
                "apikey": "edge0",
                "setuppassword": "abcdefgh"
            },
            "edge1": {
                "comment": "Edge #1",
                "apikey": "edge1",
                "setuppassword": "1234567"
            }
        }
    }

I have sifted through a lot of code so I am only coming to the community for help after exhausting every angle.

Here is an example of the kind of file I layout I would like to use for the user management:

{"username": "admin", "password": "admin", "role": "ADMIN", "device": "edge0"},
{"username": "testadmin", "password": "testadmin", "role": "ADMIN", "device": "edge0"},
{"username": "testowner", "password": "testowner", "role": "OWNER", "device": "edge1"},
{"username": "testguest", "password": "testguest", "role": "GUEST", "device": "edge2"},

Now, what I am having trouble understanding is how/where do you then define a Metadata file that can be used for user authentication from the UI? On the Backend, it looks like you can only create/enable one Metadata.File instance which I am already using for the devices. Also, how do you associate users with devices, or does it matter? Do I create another Controller Api Backend in the Edge server configuration?

The entire OpenEMS framework is brilliant but sometimes I feel like I need to get with Russell Crowe in A Beautiful Mind to get to the next level. :laughing:

1 Like

I may not even be asking the right question here so if I need to provide better or more thorough background information or ask a different question, please let me know.

Thanks in advance for any guidance.

HI @acabrera,

unfortunately there is currently no implementation for a “users.json” file in “Metadata.File”.

Your given example for a devices.json file is correc - as documented in the readme → openems/io.openems.backend.metadata.file at develop · OpenEMS/openems · GitHub.

The actual implementation contains a comment:

 * This implementation does not require any login. It always serves the same
 * user, which has 'ADMIN'-permissions on all given Edges.

→ openems/io.openems.backend.metadata.file/src/io/openems/backend/metadata/file/MetadataFile.java at develop · OpenEMS/openems · GitHub

I have to admit this entire Metadata interface is built around our connection to Odoo. This is why devices and users metadata is mixed into one service. If you wanted to implement a users.json file inside Metadata.File, you would have to adjust the code linked above - and then activate only one instance of it.

Regards,
Stefan

So, in your implementation of Odoo, Stefan, do you both Metadata.Odoo (for user auth) and Metadata.File (for the list of Edge devices) or do you use Metadata.Odoo for all of it?

This is indeed correct

Ok. Thanks, everyone.

2 Likes