using System.Threading.Tasks; using IwbZero.MultiTenancy; namespace IwbZero.Authorization.Base.Users { /// /// 定义外部授权源 /// /// Tenant type /// User type public interface IExternalAuthenticationSource where TTenant : IwbTenant where TUser : UserBase { /// /// 唯一的认证源名称. /// This source name is set to /// 如果用户通过此认证源认证 /// string Name { get; } /// /// 用于尝试通过此源对用户进行身份验证 /// /// User name or email address /// 用户的普通密码 /// Tenant of the user or null (if user is a host user) /// True, indicates that this used has authenticated by this source Task TryAuthenticateAsync(string userNameOrEmailAddress, string plainPassword, TTenant tenant); /// /// 此方法是由该源验证的用户,但该源尚不存在,因此源应创建用户和填充属性。 /// /// User name or email address /// Tenant of the user or null (if user is a host user) /// Newly created user Task CreateUserAsync(string userNameOrEmailAddress, TTenant tenant); /// /// 此方法是在现有用户通过此源的身份验证后调用的,它可用于由源更新用户的某些属性。 /// /// The user that can be updated /// Tenant of the user or null (if user is a host user) Task UpdateUserAsync(TUser user, TTenant tenant); } }