更新时间:2023-12-01 14:21:16
本着共享的精神,我设法绕过了Windows身份验证上下文而避免使用登录屏幕.
in the spirit of sharing here is how i managed to circumvent the use of the login screen for a Window Authenticated context.
立即运行登录操作(无用户交互)
in the js file run the login action immediately (no user interaction)
abp.ajax({
contentType: 'application/x-www-form-urlencoded',
url: $loginForm.attr('action'),
data: $loginForm.serialize()
});
在AccountController中:
In the AccountController:
var windowsIdentity = WindowsIdentity.GetCurrent();
loginModel.UsernameOrEmailAddress = windowsIdentity.Name;
var count = (from x in windowsIdentity.Claims where x.Value == "myclaim" select x).Count();
if (count == 0)
{
throw _abpLoginResultTypeHelper.CreateExceptionForFailedLoginAttempt(AbpLoginResultType.InvalidUserNameOrEmailAddress, loginModel.UsernameOrEmailAddress, null);
}
true
.
public override Task<bool> TryAuthenticateAsync(string userNameOrEmailAddress, string plainPassword, Tenant tenant)
{
return Task.FromResult(true);
}
它的另一个优点是,通过ABP框架自动创建了经过身份验证的用户.为新用户分配的角色取决于Default
的角色-请参见表AbpUserRoles
.
It has the added advantage that the authenticated user is created by the ABP Framework automatically. The Role the new user is assigned depends on the which role is the Default
- see Table AbpUserRoles
.
希望这可以帮助尝试在Windows身份验证的上下文中使用该框架的人.
Hopefully this helps somebody trying to use the framework in a Windows-Authenticated context.