如何处理 ASP.NET 中的身份记录 node.js?
How to handle ASP.NET Identity records in node.js?
我想从 ASP.NET MVC 身份转移到 node.js。我的数据库中有以下字段:
PasswordHash:
AOCB5TrZGusq9ZUdYd/w/u7GUZTPOMG7JhFd4JgS0gLOulL8QjZRbl4T6sPXwD3lfQ==
密码是asdfgak。
我不知道如何使用此 PasswordHash 以及如何从中获取哈希和盐以从 node.js.
登录用户
我看到了 this 的回答,但它根本没有帮助,输出如下:
A+w9Dyfupc+dMkViA0eYF4ol7HhdIfVPct6o47a+n5M=
这是我的 MVC 项目中的代码,如果有帮助的话:
public class ApplicationUser : IdentityUser
{
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
{
var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
// Add custom user claims here
return userIdentity;
}
// my custom fields like username, gender...
}
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext()
: base("Personal", throwIfV1Schema: false)
{
}
public static ApplicationDbContext Create()
{
return new ApplicationDbContext();
}
}
好的,我发现这个模块你甚至可以在同步和异步之间进行选择,太棒了:
老问题,但是对于任何想在这里结束的人来说只是想用现代 js 从现有的 aspnet 身份散列密码验证密码,可以这样做:
import crypto from 'crypto'
const hashed = Buffer.from('AOCB5TrZGusq9ZUdYd/w/u7GUZTPOMG7JhFd4JgS0gLOulL8QjZRbl4T6sPXwD3lfQ==', 'base64')
const salt = hashed.slice(1, 17)
const bytes = hashed.slice(17, 49)
const key = crypto.pbkdf2Sync('asdfgak', salt, 1000, 32, 'sha1')
const match = key.equals(bytes)
我想从 ASP.NET MVC 身份转移到 node.js。我的数据库中有以下字段:
PasswordHash: AOCB5TrZGusq9ZUdYd/w/u7GUZTPOMG7JhFd4JgS0gLOulL8QjZRbl4T6sPXwD3lfQ==
密码是asdfgak。 我不知道如何使用此 PasswordHash 以及如何从中获取哈希和盐以从 node.js.
登录用户我看到了 this 的回答,但它根本没有帮助,输出如下:
A+w9Dyfupc+dMkViA0eYF4ol7HhdIfVPct6o47a+n5M=
这是我的 MVC 项目中的代码,如果有帮助的话:
public class ApplicationUser : IdentityUser
{
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
{
var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
// Add custom user claims here
return userIdentity;
}
// my custom fields like username, gender...
}
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext()
: base("Personal", throwIfV1Schema: false)
{
}
public static ApplicationDbContext Create()
{
return new ApplicationDbContext();
}
}
好的,我发现这个模块你甚至可以在同步和异步之间进行选择,太棒了:
老问题,但是对于任何想在这里结束的人来说只是想用现代 js 从现有的 aspnet 身份散列密码验证密码,可以这样做:
import crypto from 'crypto'
const hashed = Buffer.from('AOCB5TrZGusq9ZUdYd/w/u7GUZTPOMG7JhFd4JgS0gLOulL8QjZRbl4T6sPXwD3lfQ==', 'base64')
const salt = hashed.slice(1, 17)
const bytes = hashed.slice(17, 49)
const key = crypto.pbkdf2Sync('asdfgak', salt, 1000, 32, 'sha1')
const match = key.equals(bytes)