The user authorization manager class allows application developers the ability to manage user authorization records. The can be loaded and saved to any storage space, including the config system or UserParams. Authorization values are hashed before being saved. Validation compares both the hash as well as the authorization type. Adding, updating, and removing records will automatically call the user devined save functions. For usage, please see the example found in examples/SSH/sshServerUserAuth
.
More...
#include <UserAuthManager.h>
|
| UserAuthManager () |
| Default constructor.
|
|
| ~UserAuthManager () |
| Default destructor.
|
|
bool | Init (SaveAuthRecordsFn svRcFn, LoadAuthRecordsFn ldRcFn) |
| Initialization function. Must be called before use. More...
|
|
bool | UserExists (const NBString &userName) |
| Determines if a user record exists. More...
|
|
AuthResponse | AddUserAuth (const NBString &userName, const NBString &auth, AuthType authType) |
| Attempts to add a user authorization record. This will automatically call the save record function if the user is added. More...
|
|
AuthResponse | CheckUserAuth (const NBString &userName, const NBString &auth, AuthType authType) |
| Checks the for a user and compares the authorization value to what is stored. More...
|
|
AuthResponse | CheckUserAuth (const NBString &userName, byte *auth, AuthType authType) |
| Checks the for a user and compares the authorization value to what is stored. More...
|
|
AuthResponse | UpdateUserAuth (const NBString &userName, const NBString &newAuth, AuthType authType) |
| Updates a user authorization record with the information provided. This function will automatically save all user records if the changes are successful. More...
|
|
AuthResponse | RemoveUserAuth (const NBString &userName) |
| Remove a user authorization record. This function will automatically save all user records if the removal is successful. More...
|
|
AuthResponse | CheckUserAuthLevel (const NBString &userName, uint32_t authLevel, bool hasAll=true) |
| Checks the user against the specific authLevel. More...
|
|
AuthResponse | SetUserAuthLevel (const NBString &userName, uint32_t authLevel) |
| This adds the authorization levels passed in to the user's current authorization level. More...
|
|
AuthResponse | ClrUserAuthLevel (const NBString &userName, uint32_t authLevel) |
| Clears the authorization for the specified user. More...
|
|
void | ListUsers () |
| Lists the users currently in the User Authorization Record system, along with their saved authorization type and level.
|
|
int | GetMaxAuthRecords () |
| Gets the maximum number of authorization records available to the system. This can be changed with the macro MAX_AUTH_RECORDS.
|
|
The user authorization manager class allows application developers the ability to manage user authorization records. The can be loaded and saved to any storage space, including the config system or UserParams. Authorization values are hashed before being saved. Validation compares both the hash as well as the authorization type. Adding, updating, and removing records will automatically call the user devined save functions. For usage, please see the example found in examples/SSH/sshServerUserAuth
.
◆ AddUserAuth()
Attempts to add a user authorization record. This will automatically call the save record function if the user is added.
- Parameters
-
userName | The username to add. |
auth | The authorization value to hash and store. |
authType | The authorization type of the authorization value. |
- Return values
-
eAuthSuccess | If the user was successfully added. |
!eAuthSuccess | If the user was not added successfully. The AuthResponse error code returned will indicate why. |
◆ CheckUserAuth() [1/2]
Checks the for a user and compares the authorization value to what is stored.
- Parameters
-
userName | The username to check against. |
auth | The authorization value to compare as hashed value. This will be compared directly to what is stored in the record. |
authType | The authorization type of the authorization value. |
- Return values
-
eAuthSuccess | If the user exists and the authorization value matches what was stored |
!eAuthSuccess | If the user does not exist or the authorization comparison fails. The AuthResponse error code returned will indicate why. |
◆ CheckUserAuth() [2/2]
Checks the for a user and compares the authorization value to what is stored.
- Parameters
-
userName | The username to check against. |
auth | The authorization value to compare as a plain string. This value will be hashed before getting compared. |
authType | The authorization type of the authorization value. |
- Return values
-
eAuthSuccess | If the user exists and the authorization value matches what was stored |
!eAuthSuccess | If the user does not exist or the authorization comparison fails. The AuthResponse error code returned will indicate why. |
◆ CheckUserAuthLevel()
AuthResponse UserAuthManager::CheckUserAuthLevel |
( |
const NBString & |
userName, |
|
|
uint32_t |
authLevel, |
|
|
bool |
hasAll = true |
|
) |
| |
Checks the user against the specific authLevel.
- Parameters
-
userName | The username to check. |
authLevel | The authorization level to check against. This check compares the bits passed in against the bits set on the user's authLevel. |
hasAll | Used to establish the conditions for the check to pass. If hasAll is true, then every bit passed in must be set on the user's authLevel for the check to pass. If hasAll is false, then only one bit needs to match for the check to pass. |
- Return values
-
eAuthSuccess | If the check passed and the user has the proper authorization level. |
!eAuthSuccess | If the user does not have the proper authorization level. |
◆ ClrUserAuthLevel()
Clears the authorization for the specified user.
- Parameters
-
userName | The username to check. |
authLevel | The authorization level to clear. |
- Return values
-
eAuthSuccess | If the specified authorization level was successfully cleared and saved. |
!eAuthSuccess | If the authorization level could not be cleared and saved. The AuthResponse error code returned will indicate why. |
◆ Init()
Initialization function. Must be called before use.
- Parameters
-
svRcFn | The user defined function that will save authorization records. |
ldRcFn | The user defined function that will load the authorization records from storage. Called inside init(). |
- Return values
-
true | If successfully initialzed, and the users are properly loaded. |
!0 | If there was an error initializing the object, or the users were not successfully loaded. Error code will |
◆ RemoveUserAuth()
Remove a user authorization record. This function will automatically save all user records if the removal is successful.
- Parameters
-
userName | The username to remove. |
- Return values
-
eAuthSuccess | If the user record was successfully removed. |
!eAuthSuccess | If the user record could not be removed. The AuthResponse error code returned will indicate why. |
◆ SetUserAuthLevel()
This adds the authorization levels passed in to the user's current authorization level.
- Parameters
-
userName | The username to check. |
authLevel | The authorization level to check against. This check compares the bits passed in against the bits set on the user's authLevel. |
- Return values
-
eAuthSuccess | If the the user authorization level was properly set and saved. |
!eAuthSuccess | If the user's authorization level could not be set and saved. The AuthResponse error code returned will indicate why. |
◆ UpdateUserAuth()
Updates a user authorization record with the information provided. This function will automatically save all user records if the changes are successful.
- Parameters
-
userName | The username to check against. |
newAuth | The new authorization value to assign to the user. |
authType | The authorization type of the authorization value. |
- Return values
-
eAuthSuccess | If the user record was successfully updated. |
!eAuthSuccess | If the user record could not be updated. The AuthResponse error code returned will indicate why. |
◆ UserExists()
bool UserAuthManager::UserExists |
( |
const NBString & |
userName | ) |
|
Determines if a user record exists.
- Parameters
-
userName | The username to check. |
- Return values
-
true | If the user exists. |
false | If the user does not exist. |
The documentation for this class was generated from the following file: