gpt4 book ai didi

feathersjs - Feathers auth 登录无效

转载 作者:行者123 更新时间:2023-12-05 07:23:54 24 4
gpt4 key购买 nike

我尝试使用本地身份验证,但收到错误消息“无效登录”。

  1. 我从客户端发送“本地”授权。在服务器上接收数据
{ strategy: 'local',
email: 'email@gmail.com',
password: '123' },
{ query: {},
provider: 'socketio',
headers: {},
session: {},
cookies: {} }

在authentication.js中

module.exports = function (app) {
const config = app.get('authentication');

// Set up authentication with the secret
app.configure(authentication(config));
app.configure(jwt());
app.configure(local());

app.configure(oauth2(Object.assign({
name: 'auth0',
Strategy: Auth0Strategy
}, config.auth0)));

app.service('authentication').hooks({
before: {
create: [
(data)=>{console.log('auth',data.arguments)},
authentication.hooks.authenticate(config.strategies),
],
remove: [
authentication.hooks.authenticate('jwt')
]
}
});
};
  1. 服务器在数据库中查找记录并返回查询结果
{ id: 1,
email: 'email@gmail.com',
password:
'$2a$13$t2XZsqu/0t5jKSdbRUyZTOVOoZJVtiha3sN/Z8N0O190Z0DUJj70O',
auth0Id: null,
isVerified: null,
verifyToken: 'string',
verifyExpires: null,
resetToken: 'string',
resetExpires: null,
createdAt: 2019-04-14T22:04:52.000Z,
updatedAt: 2019-04-14T22:04:52.000Z }
  1. 之后它尝试比较密码的哈希值,但是收到的密码的哈希值不等于查询结果中的密码。收到的密码与当前时间结合在结果哈希中。

feathers中如何使用localauth?

更新

来自 default.json 的配置

"authentication": {
"secret": "my secret key here",
"strategies": [
"jwt",
"local"
],
"path": "/authentication",
"service": "users",
"jwt": {
"header": {
"typ": "access"
},
"audience": "https://yourdomain.com",
"subject": "anonymous",
"issuer": "feathers",
"algorithm": "HS256",
"expiresIn": "1d"
},
"local": {
"entity": "user",
"usernameField": "email",
"passwordField": "password"
},
"auth0": {
"clientID": "your auth0 client id",
"clientSecret": "your auth0 client secret",
"successRedirect": "/",
"domain": "mydomain.auth0.com",
"scopes": [
"profile"
]
}
}

最佳答案

实际上 bcrypt(feathers 内部用于散列)正在使用盐来散列我们的密码,这就是为什么你每次对同一个字符串都会得到不同的不同结果。

关于feathersjs - Feathers auth 登录无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55683416/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com