|
@@ -110,10 +110,35 @@ typedef struct shellmatta_cmd
|
|
char *cmdAlias; /**< command alias */
|
|
char *cmdAlias; /**< command alias */
|
|
char *helpText; /**< help text to print in "help" command */
|
|
char *helpText; /**< help text to print in "help" command */
|
|
char *usageText; /**< usage text - printed on "help cmd" */
|
|
char *usageText; /**< usage text - printed on "help cmd" */
|
|
|
|
+#ifdef SHELLMATTA_AUTHENTICATION
|
|
|
|
+ uint32_t minRoleId; /**< minimum user role id for this command */
|
|
|
|
+#endif
|
|
shellmatta_cmdFct_t cmdFct; /**< pointer to the cmd callack function */
|
|
shellmatta_cmdFct_t cmdFct; /**< pointer to the cmd callack function */
|
|
struct shellmatta_cmd *next; /**< pointer to next command or NULL */
|
|
struct shellmatta_cmd *next; /**< pointer to next command or NULL */
|
|
} shellmatta_cmd_t;
|
|
} shellmatta_cmd_t;
|
|
|
|
|
|
|
|
+
|
|
|
|
+#ifdef SHELLMATTA_AUTHENTICATION
|
|
|
|
+/**
|
|
|
|
+ * @brief user role matrix
|
|
|
|
+ */
|
|
|
|
+typedef struct
|
|
|
|
+{
|
|
|
|
+ uint32_t roleId; /**< id of the user role (!= 0) */
|
|
|
|
+ const char *username; /**< name of the user role */
|
|
|
|
+ const char *password; /**< password of the user role or NULL (custom auth) */
|
|
|
|
+} user_role_t;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * @brief custom shellmatta authentication method
|
|
|
|
+ * @param[in] username username to log in (name of the user role)
|
|
|
|
+ * @param[in] password password for the login
|
|
|
|
+ * @return #SHELLMATTA_OK if the username and password is correct
|
|
|
|
+ */
|
|
|
|
+typedef shellmatta_retCode_t (*shellmatta_auth_check_t)(const char* username, const char* password);
|
|
|
|
+
|
|
|
|
+#endif
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @brief structure of one shellmatta instance
|
|
* @brief structure of one shellmatta instance
|
|
*/
|
|
*/
|
|
@@ -153,6 +178,10 @@ typedef struct
|
|
bool cmdListIsConst; /**< true if the #cmdList was passed during
|
|
bool cmdListIsConst; /**< true if the #cmdList was passed during
|
|
initialization */
|
|
initialization */
|
|
shellmatta_opt_t optionParser; /**< option parser sructure */
|
|
shellmatta_opt_t optionParser; /**< option parser sructure */
|
|
|
|
+#ifdef SHELLMATTA_AUTHENTICATION
|
|
|
|
+ uint32_t roleId; /**< role ID of the current session */
|
|
|
|
+ user_role_t *userRoleMatrix /**< user role matrix structure */
|
|
|
|
+#endif
|
|
} shellmatta_instance_t;
|
|
} shellmatta_instance_t;
|
|
|
|
|
|
|
|
|
|
@@ -210,6 +239,23 @@ shellmatta_retCode_t shellmatta_printf( shellmatta_handle_t handle,
|
|
...);
|
|
...);
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
+#ifdef SHELLMATTA_AUTHENTICATION
|
|
|
|
+
|
|
|
|
+shellmatta_retCode_t shellmatta_auth_init( shellmatta_handle_t handle,
|
|
|
|
+ user_role_t *userRoleMatrix,
|
|
|
|
+ uint32_t length,
|
|
|
|
+ bool customLogin,
|
|
|
|
+ shellmatta_auth_check_t checkFct);
|
|
|
|
+shellmatta_retCode_t shellmatta_auth_login( shellmatta_handle_t handle,
|
|
|
|
+ uint32_t roleId);
|
|
|
|
+shellmatta_retCode_t shellmatta_auth_logout( shellmatta_handle_t handle);
|
|
|
|
+uint32_t shellmatta_auth_getLoggedInRole( shellmatta_handle_t handle);
|
|
|
|
+shellmatta_retCode_t shellmatta_auth_getLoggedInUserName( shellmatta_handle_t handle,
|
|
|
|
+ char **data,
|
|
|
|
+ uint32_t *length);
|
|
|
|
+
|
|
|
|
+#endif
|
|
|
|
+
|
|
#endif
|
|
#endif
|
|
|
|
|
|
/** @} */
|
|
/** @} */
|