Answer the question
In order to leave comments, you need to log in
How to properly mask the _id field when passing it to the UI?
If two documents are created in the same database with a time interval of less than a second, then the _id of the last one is an increment of the previous one, which differs only in the last character: ObjectId("585f695e45a2c61b5c7ca452")
ObjectId("585f695e45a2c61b5c7ca453")
i.e. knowing the _id of the last one, we can "almost exactly" know the _id of the document that was created before it.
Let's say the organization of links on my site is a call to a document through an explicit indication of _id (in the address bar), but I would not want a person, just by looking at the request, to be able to find out and access documents from this _id range (authorization is not taken into account).
The first thing that comes to mind is to assign your _id as a random one.
The second is to make a hash on _id, then the meaning of _id disappears, and I would like to leave it for connections, because, as far as I understand, service information is encrypted in it, which is needed when distributing the database (for the future).
Is there a built-in method in mongo that comes up with _id in a more interesting way, or can someone suggest a different approach algorithm in organizing _id, without unnecessary checks and requests?
Answer the question
In order to leave comments, you need to log in
Let's say the organization of links on my site is a call to a document through an explicit indication of _id (in the address bar), but I would not want a person, just by looking at the request, to be able to find out and access documents from this _id range (authorization is not taken into account).
"almost exactly" to know
> could recognize and access documents from this _id range (authorization is not taken into account)
That's where the problem is, not in IDs. Security by obscurity doesn't work. Set up a rights check and at least pass IDs with integrators.
The apogeios there is actually timestamp based, but that's just so the admins don't say they didn't answer the question.
On your question recently deleted about 20k, there are ideas, but such things are not publicly discussed.
If the intentions are serious, write to Skype FenixSumi, we will discuss it, if the theoretical reflection, then you yourself understand.
They suggested the answer in one of the chats in the Telegram.
In general, on the client side, apparently, it is not always possible to check for the fields being filled in, in other words, their browser spat on required and such emails with empty content periodically occur.
It is necessary to perform checks on the server side, in the context of my task, the following code came up to me:
$num = 0;
foreach ($_POST as $key => $value) {
if($value != '' && $value != ' '){
$num++;
}
}
if($num >= 4){ //если в массиве есть значения 4-х и более полей - производим отправку
mail($admin_email, adopt($form_subject), $message, $headers );
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question