它以前总是起作用,但现在已经不起作用了。
我有一个速率限制逻辑,但是即使我清除了所有的速率限制数据,它仍然会发生。只对特定的用户。
为了测试目的,我在FaunaDB上创建了另一个帐户和一个新的数据库。如果我将旧的数据库数据还原到那个新的数据库中,一切都会正常工作的!
因此,我在旧的FaunaDB帐户上重新创建了整个数据库,问题依然存在。
有人也经历过类似的事情吗?缓存中有任何信息吗?
Login(Match(Index("accounts_by_email"), "email@email.com"), {
password: "secret",
})
/* returns
Error: [
{
"position": [],
"code": "authentication failed",
"description": "The document was not found or provided password was incorrect."
}
]
*/密码没有不正确。它可以在恢复数据的另一个FaunaDB帐户上工作。
./fdm -source path=backup -dest key={admin_key}发布于 2020-08-19 15:19:01
是的,那只是暂时的问题。在我自己的Fwitter例子中,我在某一时刻很好地体验了它。我们的唯一性检测不能很好地处理在一个复杂的FQL流中创建/更新/删除事物的代码,代码正在这样做:)。我开了票,应该在这段时间内修好。
很高兴知道那里的速率限制有点小,我尝试了一些事件。它也可以写得简单得多,我想我有点太深了,而且公平。我那时刚加入FaunaDB。我正在开发一个框架应用程序,它将包含更简单的版本。同时,下面是代码:
简化速率限制
import { rateLimiting } from '../../fauna-queries/helpers/errors'
import faunadb from 'faunadb'
/*
* Ideally we limit the amount of calls that come to Login.
*/
const q = faunadb.query
const {
If,
Epoch,
Match,
Index,
Collection,
Let,
Var,
Paginate,
Select,
TimeDiff,
Or,
GTE,
Abort,
Create,
IsEmpty,
Count,
LT,
Do,
Now,
Subtract
} = q
function AddRateLimiting(action, FqlQueryToExecute, Identifier, calls, perMilliseconds) {
const ExecuteAndCreateLog = Do(
Create(Collection('logs'), {
data: {
action: action,
identity: Identifier
}
}),
FqlQueryToExecute
)
return Let(
{
logsPage: Paginate(Match(Index('logs_by_action_and_identity_ordered_by_ts'), action, Identifier), {
size: calls
})
},
If(
Or(IsEmpty(Var('logsPage')), LT(Count(Select(['data'], Var('logsPage'))), calls)),
// If no logs exist yet, create one.
ExecuteAndCreateLog,
Let(
{
// the page looks like { data: [timestamp1, timestamp2,...]},
// we will retrieve the last timestamp of that page. If the pagesize would be 3, it would be the oldest of these 3 events.
// since the index is ordered from new to old.
timestamp: Select(['data', Subtract(calls, 1)], Var('logsPage')),
// transform the Fauna timestamp to a Time object
time: Epoch(Var('timestamp'), 'microseconds'),
// How long ago was that event in ms
ageInMs: TimeDiff(Var('time'), Now(), 'milliseconds')
},
If(
GTE(Var('ageInMs'), perMilliseconds),
// Then great we execute
ExecuteAndCreateLog,
// Else.. Abort! Rate-limiting in action
Abort(rateLimiting)
)
)
)
)
}阻塞一个又一个错误登录,我也分离了三个错误登录,因为我有点滥用的速率限制系统。当然,在这段代码中有一些未定义,它只是想让您了解它是如何查找更多信息的,请密切关注骨架+博客的出现。
// Let's wrap some other functionality around the login.
const BlockThreeFaultyLogins = Do(
If(
GTE(Count(Match(Index('logs_by_action_and_identity'), 'faulty_login', email)), MAX_LOGIN_ATTEMPTS),
// Abort if exceeded
Abort(tooManyFaultyLogins),
// Else, just continue as usual!
Let(
{
login: LoginFQL
},
Do(
If(
Equals(false, Var('login')),
// if the login is faulty, we'll add a log entry
Create(Collection('logs'), {
data: {
action: 'faulty_login',
identity: email
}
}),
// Else, we will clean up the faulty_login logs
q.Map(
Paginate(Match(Index('logs_by_action_and_identity'), 'faulty_login', email)),
Lambda(['logRef'], Delete(Var('logRef')))
)
),
Var('login')
)
)
)
)https://stackoverflow.com/questions/62906149
复制相似问题