using Connected.Security.Identity; namespace Connected.Security.Authentication; /// /// Defines the reason decided /// to allow or refuse the authentication . /// public enum AuthenticationResultReason { /// /// The authentication was successfully. This is the only reason /// that is used when authentication is successful. /// OK = 0, /// /// The provided identity was not found. /// NotFound = 1, /// /// The provided identity did not have a valid password. /// InvalidPassword = 2, /// /// The provided identity is not active in the environment. /// Inactive = 3, /// /// The provided identity is locked or blocked by the environment. /// Locked = 4, /// /// The provided identity does not have a password set but an /// requires one. /// NoPassword = 5, /// /// The provided identity's password has expired. /// PasswordExpired = 6, /// /// The token provided by the identity is invalid. /// InvalidToken = 7, /// /// The credentials provided by identity are not valid or are not supported by the environment. /// InvalidCredentials = 8, /// /// There is other issue regarding identity which cannot be resolved. /// Other = 99 } /// /// Represents the result of the authentication process. should never /// throw an exception during authentication process. It must always return regardless /// wether it was successful or not. /// public interface IAuthenticationResult { /// /// The token which can be used to uniquely identify the identity. This token is /// generated by the when the authentication is /// successful and no previous token was created. /// /// /// Each identity should have only one active token at the time and the new token can be invalidated /// by the environment. Token is also valid only for a limited time. Once expired, user will need to /// authenticate again. The primary use of this token is in the SSO systems. /// string? Token { get; } /// /// Returns true if authentication was successful, false otherwise. /// bool Success { get; } /// /// The reason authentication was successful or not. /// AuthenticationResultReason Reason { get; } /// /// The identity which can be used in the process pipeline. /// /// /// For example, this value will be used by HttpRequests as a User property. IUser? User { get; } }