The "MinimalAuthentication" extension is the simplest possible authentication extension. It uses the "AuthListener" interface to handle authentication of a single hard-coded user account:
Username: "admin"
Password: "123"
Also, it uses the "RequestListener" interface to implement the "ListUsers" function symbol that all authentication extensions must implement.
Authentication extensions only handle authentication, whereas the HMI server handles account settings, permissions, auto-logout, and group memberships. This sample also showcases how extensions can register user accounts in the HMI server's configuration ("TcHmiSrv.Config").
First steps:
-
Login request for the user account provided by the "MinimalAuthentication" extension.
Request:
{ "requestType": "ReadWrite", "commands": [ { "symbol": "Login", "writeValue": { "userName": "MinimalAuthentication::admin", "password": "123" }, "commandOptions": [ "SendErrorMessage", "SendWriteValue" ] } ] }
-
List the names of all usernames provided by the "MinimalAuthentication" extension.
Request:
{ "requestType": "ReadWrite", "commands": [ { "symbol": "MinimalAuthentication.ListUsers", "commandOptions": [ "SendErrorMessage" ] } ] }
Response:
{ "requestType": "ReadWrite", "commands": [ { "symbol": "MinimalAuthentication.ListUsers", "readValue": [ "admin" ] } ] }
-
Show the account settings of the "MinimalAuthentication" accounts registered in the HMI server's configuration.
Request:
{ "requestType": "ReadWrite", "commands": [ { "symbol": "TcHmiSrv.Config::USERGROUPUSERS::MinimalAuthentication", "commandOptions": [ "SendErrorMessage" ] } ] }
Response:
{ "requestType": "ReadWrite", "commands": [ { "symbol": "TcHmiSrv.Config::USERGROUPUSERS::MinimalAuthentication", "readValue": { "admin": { "USERGROUPUSERS_AUTO_LOGOFF": "P30D", "USERGROUPUSERS_GROUPS": [ "__SystemAdministrators" ], "USERGROUPUSERS_LOCALE": "client" } } } ] }
-
Get the name of the current default authentication extension.
Request:
{ "requestType": "ReadWrite", "commands": [ { "symbol": "TcHmiSrv.Config::DEFAULTAUTHEXTENSION", "commandOptions": [ "SendErrorMessage" ] } ] }
Response:
{ "requestType": "ReadWrite", "commands": [ { "symbol": "TcHmiSrv.Config::DEFAULTAUTHEXTENSION", "readValue": "TcHmiUserManagement", } ] }
-
Make "MinimalAuthentication" the default authentication extension.
Request:
{ "requestType": "ReadWrite", "commands": [ { "symbol": "TcHmiSrv.Config::DEFAULTAUTHEXTENSION", "writeValue": "MinimalAuthentication", "commandOptions": [ "SendErrorMessage", "SendWriteValue" ] } ] }
Response:
{ "requestType": "ReadWrite", "commands": [ { "symbol": "TcHmiSrv.Config::DEFAULTAUTHEXTENSION", "readValue": "MinimalAuthentication" } ] }