AuthenticationKit.MutableUser
This interface aggregates AuthenticationKit.User, meaning all methods required by AuthenticationKit.User will also be required by AuthenticationKit.MutableUser.
This interfaces should be implemented by a user class that can be modified. It is perfectly acceptable to use a single editable user class, as opposed to a mutable and immutable pair of classes.
Interface Methods
Sub LoginKey (Assigns Value As Text)
Allows the login key to be changed for the user. If a user class does not allow editable login keys (not recommended) then simply leave this method empty.
Sub SetSecurityDetails (Iterations As UInteger, Algorithm As Xojo.Crypto.HashAlgorithms, ValidationHash As Xojo.Core.MemoryBlock, PasswordSalt As Xojo.Core.MemoryBlock, SecondFactorSalt As Xojo.Core.MemoryBlock)
When changing the password for a user, new security details will be generated by the framework and passed to the user class via this method.
SecondFactorSalt
will be nil if two factor authentication is to be disabled. All other parameters are required and will be set.
Extension Methods
These methods are supplied by the AuthenticationKit
module automatically to all implementors of the interface.
Function SetPassword (Extends User As AuthenticationKit.MutableUser, Password As Text, Iterations As UInteger, Algorithm As Xojo.Crypto.HashAlgorithms) As AuthenticationKit.Token()
Change the user's password with two factor authentication disabled.
Password
is the user's password.Iterations
is the number of PBKDF2 iterations used to hash the password. The same password hashed with different iteration counts will produce different hashes. More iterations requires more cpu time, making the hash harder to break. Every server is different, so best practice is to experiment with iteration counts to produce a desired execution time.Algorithm
is the hashing algorithm to use. The algorithm will dictate the length of the hashes produced, so if possible, use SHA-512.
Function SetPassword (Extends User As AuthenticationKit.MutableUser, Password As Text, Iterations As UInteger, Algorithm As Xojo.Crypto.HashAlgorithms, ByRef Generator As AuthenticationKit.TwoFactorProfile) As AuthenticationKit.Token()
Change the user's password with two factor authentication enabled.
Password
,Iterations
, andAlgorithm
are the same as the other method signature.Generator
is the AuthenticationKit.TwoFactorProfile to be used. IfNil
, a new generator will be created and used.