NetBurner 3.5.0
PDF Version
 
UserAuthManager Class Reference

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>

Public Member Functions

 UserAuthManager ()
 Default constructor.
 
 ~UserAuthManager ()
 Default destructor.
 
bool Init (SaveAuthRecordsFn svRcFn, LoadAuthRecordsFn ldRcFn)
 Initialization function. Must be called before use.
 
bool UserExists (const NBString &userName)
 Determines if a user record exists.
 
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.
 
AuthResponse CheckUserAuth (const NBString &userName, const NBString &auth, AuthType authType)
 Checks the for a user and compares the authorization value to what is stored.
 
AuthResponse CheckUserAuth (const NBString &userName, byte *auth, AuthType authType)
 Checks the for a user and compares the authorization value to what is stored.
 
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.
 
AuthResponse RemoveUserAuth (const NBString &userName)
 Remove a user authorization record. This function will automatically save all user records if the removal is successful.
 
AuthResponse CheckUserAuthLevel (const NBString &userName, uint32_t authLevel, bool hasAll=true)
 Checks the user against the specific authLevel.
 
AuthResponse SetUserAuthLevel (const NBString &userName, uint32_t authLevel)
 This adds the authorization levels passed in to the user's current authorization level.
 
AuthResponse ClrUserAuthLevel (const NBString &userName, uint32_t authLevel)
 Clears the authorization for the specified user.
 
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.
 

Detailed Description

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.

Member Function Documentation

◆ AddUserAuth()

AuthResponse UserAuthManager::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.

Parameters
userNameThe username to add.
authThe authorization value to hash and store.
authTypeThe authorization type of the authorization value.
Return values
eAuthSuccessIf the user was successfully added.
!eAuthSuccessIf the user was not added successfully. The AuthResponse error code returned will indicate why.

◆ CheckUserAuth() [1/2]

AuthResponse UserAuthManager::CheckUserAuth ( const NBString & userName,
byte * auth,
AuthType authType )

Checks the for a user and compares the authorization value to what is stored.

Parameters
userNameThe username to check against.
authThe authorization value to compare as hashed value. This will be compared directly to what is stored in the record.
authTypeThe authorization type of the authorization value.
Return values
eAuthSuccessIf the user exists and the authorization value matches what was stored
!eAuthSuccessIf the user does not exist or the authorization comparison fails. The AuthResponse error code returned will indicate why.

◆ CheckUserAuth() [2/2]

AuthResponse UserAuthManager::CheckUserAuth ( const NBString & userName,
const NBString & auth,
AuthType authType )

Checks the for a user and compares the authorization value to what is stored.

Parameters
userNameThe username to check against.
authThe authorization value to compare as a plain string. This value will be hashed before getting compared.
authTypeThe authorization type of the authorization value.
Return values
eAuthSuccessIf the user exists and the authorization value matches what was stored
!eAuthSuccessIf 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
userNameThe username to check.
authLevelThe authorization level to check against. This check compares the bits passed in against the bits set on the user's authLevel.
hasAllUsed 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
eAuthSuccessIf the check passed and the user has the proper authorization level.
!eAuthSuccessIf the user does not have the proper authorization level.

◆ ClrUserAuthLevel()

AuthResponse UserAuthManager::ClrUserAuthLevel ( const NBString & userName,
uint32_t authLevel )

Clears the authorization for the specified user.

Parameters
userNameThe username to check.
authLevelThe authorization level to clear.
Return values
eAuthSuccessIf the specified authorization level was successfully cleared and saved.
!eAuthSuccessIf the authorization level could not be cleared and saved. The AuthResponse error code returned will indicate why.

◆ Init()

bool UserAuthManager::Init ( SaveAuthRecordsFn svRcFn,
LoadAuthRecordsFn ldRcFn )

Initialization function. Must be called before use.

Parameters
svRcFnThe user defined function that will save authorization records.
ldRcFnThe user defined function that will load the authorization records from storage. Called inside init().
Return values
trueIf successfully initialzed, and the users are properly loaded.
!0If there was an error initializing the object, or the users were not successfully loaded. Error code will

◆ RemoveUserAuth()

AuthResponse UserAuthManager::RemoveUserAuth ( const NBString & userName)

Remove a user authorization record. This function will automatically save all user records if the removal is successful.

Parameters
userNameThe username to remove.
Return values
eAuthSuccessIf the user record was successfully removed.
!eAuthSuccessIf the user record could not be removed. The AuthResponse error code returned will indicate why.

◆ SetUserAuthLevel()

AuthResponse UserAuthManager::SetUserAuthLevel ( const NBString & userName,
uint32_t authLevel )

This adds the authorization levels passed in to the user's current authorization level.

Parameters
userNameThe username to check.
authLevelThe authorization level to check against. This check compares the bits passed in against the bits set on the user's authLevel.
Return values
eAuthSuccessIf the the user authorization level was properly set and saved.
!eAuthSuccessIf the user's authorization level could not be set and saved. The AuthResponse error code returned will indicate why.

◆ UpdateUserAuth()

AuthResponse UserAuthManager::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.

Parameters
userNameThe username to check against.
newAuthThe new authorization value to assign to the user.
authTypeThe authorization type of the authorization value.
Return values
eAuthSuccessIf the user record was successfully updated.
!eAuthSuccessIf 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
userNameThe username to check.
Return values
trueIf the user exists.
falseIf the user does not exist.

The documentation for this class was generated from the following file: