3333#include "wolfhsm/wh_common.h"
3434#include "wolfhsm/wh_auth.h"
3535
36-
36+ /**
37+ * @brief Initialize the auth base backend.
38+ *
39+ * @param[in] context Pointer to the auth base context.
40+ * @param[in] config Pointer to the configuration data.
41+ * @return int Returns 0 on success, or a negative error code on failure.
42+ */
3743int wh_AuthBase_Init (void * context , const void * config );
3844
45+ /**
46+ * @brief Cleanup the auth base backend.
47+ *
48+ * @param[in] context Pointer to the auth base context.
49+ * @return int Returns 0 on success, or a negative error code on failure.
50+ */
3951int wh_AuthBase_Cleanup (void * context );
4052
53+ /**
54+ * @brief Authenticate a user using the specified method.
55+ *
56+ * @param[in] context Pointer to the auth base context.
57+ * @param[in] client_id The client ID making the request.
58+ * @param[in] method The authentication method to use.
59+ * @param[in] username The username to authenticate.
60+ * @param[in] auth_data Pointer to the authentication data.
61+ * @param[in] auth_data_len Length of the authentication data.
62+ * @param[out] out_user_id Pointer to store the authenticated user ID.
63+ * @param[out] out_permissions Pointer to store the user permissions.
64+ * @param[out] loggedIn Pointer to store the login status.
65+ * @return int Returns 0 on success, or a negative error code on failure.
66+ */
4167int wh_AuthBase_Login (void * context , uint8_t client_id , whAuthMethod method ,
4268 const char * username , const void * auth_data ,
4369 uint16_t auth_data_len , uint16_t * out_user_id ,
4470 whAuthPermissions * out_permissions , int * loggedIn );
4571
72+ /**
73+ * @brief Logout a user.
74+ *
75+ * @param[in] context Pointer to the auth base context.
76+ * @param[in] current_user_id The user ID of the current user performing the logout.
77+ * @param[in] user_id The user ID to logout.
78+ * @return int Returns 0 on success, or a negative error code on failure.
79+ */
4680int wh_AuthBase_Logout (void * context , uint16_t current_user_id ,
4781 uint16_t user_id );
4882
49-
83+ /**
84+ * @brief Check if an action is authorized for a session.
85+ *
86+ * @param[in] context Pointer to the auth base context.
87+ * @param[in] user_id The user ID to check authorization for.
88+ * @param[in] group The group to check authorization for.
89+ * @param[in] action The action to check authorization for.
90+ * @return int Returns 0 if authorized, or a negative error code on failure.
91+ */
5092int wh_AuthBase_CheckRequestAuthorization (void * context , uint16_t user_id ,
5193 uint16_t group , uint16_t action );
5294
@@ -55,22 +97,72 @@ int wh_AuthBase_CheckRequestAuthorization(void* context, uint16_t user_id,
5597int wh_AuthBase_CheckKeyAuthorization (void * context , uint16_t user_id ,
5698 uint32_t key_id , uint16_t action );
5799
100+ /**
101+ * @brief Add a new user.
102+ *
103+ * @param[in] context Pointer to the auth base context.
104+ * @param[in] username The username for the new user.
105+ * @param[out] out_user_id Pointer to store the new user ID.
106+ * @param[in] permissions The permissions for the new user.
107+ * @param[in] method The authentication method for the new user.
108+ * @param[in] credentials Pointer to the credentials data.
109+ * @param[in] credentials_len Length of the credentials data.
110+ * @return int Returns 0 on success, or a negative error code on failure.
111+ */
58112int wh_AuthBase_UserAdd (void * context , const char * username ,
59113 uint16_t * out_user_id , whAuthPermissions permissions ,
60114 whAuthMethod method , const void * credentials ,
61115 uint16_t credentials_len );
62116
117+ /**
118+ * @brief Delete a user.
119+ *
120+ * @param[in] context Pointer to the auth base context.
121+ * @param[in] current_user_id The user ID of the current user performing the deletion.
122+ * @param[in] user_id The user ID to delete.
123+ * @return int Returns 0 on success, or a negative error code on failure.
124+ */
63125int wh_AuthBase_UserDelete (void * context , uint16_t current_user_id ,
64126 uint16_t user_id );
65127
128+ /**
129+ * @brief Set user permissions.
130+ *
131+ * @param[in] context Pointer to the auth base context.
132+ * @param[in] current_user_id The user ID of the current user performing the operation.
133+ * @param[in] user_id The user ID to set permissions for.
134+ * @param[in] permissions The new permissions to set.
135+ * @return int Returns 0 on success, or a negative error code on failure.
136+ */
66137int wh_AuthBase_UserSetPermissions (void * context , uint16_t current_user_id ,
67138 uint16_t user_id ,
68139 whAuthPermissions permissions );
69140
141+ /**
142+ * @brief Get user information by username.
143+ *
144+ * @param[in] context Pointer to the auth base context.
145+ * @param[in] username The username to look up.
146+ * @param[out] out_user_id Pointer to store the user ID.
147+ * @param[out] out_permissions Pointer to store the user permissions.
148+ * @return int Returns 0 on success, or a negative error code on failure.
149+ */
70150int wh_AuthBase_UserGet (void * context , const char * username ,
71151 uint16_t * out_user_id ,
72152 whAuthPermissions * out_permissions );
73153
154+ /**
155+ * @brief Set user credentials (PIN, etc.).
156+ *
157+ * @param[in] context Pointer to the auth base context.
158+ * @param[in] user_id The user ID to set credentials for.
159+ * @param[in] method The authentication method.
160+ * @param[in] current_credentials Pointer to the current credentials data.
161+ * @param[in] current_credentials_len Length of the current credentials data.
162+ * @param[in] new_credentials Pointer to the new credentials data.
163+ * @param[in] new_credentials_len Length of the new credentials data.
164+ * @return int Returns 0 on success, or a negative error code on failure.
165+ */
74166int wh_AuthBase_UserSetCredentials (void * context , uint16_t user_id ,
75167 whAuthMethod method ,
76168 const void * current_credentials ,
0 commit comments