Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

user: disallow temp email & better gate logs #1956

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/api/package.json
Expand Up @@ -78,6 +78,7 @@
"express-async-errors": "^3.1.1",
"express-mung": "^0.5.1",
"express-prom-bundle": "^6.4.1",
"fakefilter": "^0.1.663",
"fast-stable-stringify": "^1.0.0",
"fs-extra": "^7.0.1",
"google-auth-library": "^5.2.2",
Expand Down
7 changes: 7 additions & 0 deletions packages/api/src/controllers/access-control.ts
Expand Up @@ -126,11 +126,18 @@ app.post(
throw new NotFoundError("Content not found");
}

console.log(
`access-control: gate: checking access for contentId=${content.id} playbackId=${playbackId} user=${user.id}`
);

const playbackPolicyType = content.playbackPolicy?.type ?? "public";

if (user.createdAt < HACKER_DISABLE_CUTOFF_DATE) {
let limitReached = await freeTierLimitReached(content, user, req);
if (limitReached) {
console.log(`
access-control: gate: disallowing playback for contentId=${content.id} with playbackId=${playbackId} user=${user.id} reached viewership limit
`);
throw new ForbiddenError("Free tier user reached viewership limit");
}
}
Expand Down
7 changes: 7 additions & 0 deletions packages/api/src/controllers/user.ts
Expand Up @@ -10,6 +10,7 @@ import { products } from "../config";
import hash from "../hash";
import logger from "../logger";
import { authorizer, validatePost } from "../middleware";
import { isFakeEmail } from "fakefilter";
import {
CreateCustomer,
CreateSubscription,
Expand Down Expand Up @@ -317,6 +318,12 @@ app.post("/", validatePost("user"), async (req, res) => {
return;
}

if (isFakeEmail(email)) {
res.status(422);
res.json({ errors: ["invalid email"] });
return;
}
Comment on lines +321 to +325
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actuallyyyy we already have an even fancier email validation done with the Sendgrid API here: https://github.com/livepeer/livepeer-com/blob/142c9e588e964f014c80248ba004db153387d6da/packages/api/src/controllers/user.ts#L402

WDYT of making that non-background instead (or as well)? Meaning we return this error when Sendgrid says the email is fake as well. You can check the logs from that validation function to see some data on previous validations. The times I checked it seemed pretty good but we didn't go forward with enabling it.


const isEmailRegisteredAlready = await isEmailRegistered(email);
if (isEmailRegisteredAlready) {
res.status(409);
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Expand Up @@ -13158,6 +13158,11 @@ eyes@^0.1.8:
resolved "https://registry.npmjs.org/eyes/-/eyes-0.1.8.tgz"
integrity sha512-GipyPsXO1anza0AOZdy69Im7hGFCNB7Y/NGjDlZGJ3GJJLtwNSb2vrzYrTYJRrRloVx7pl+bhUaTB8yiccPvFQ==

fakefilter@^0.1.663:
version "0.1.663"
resolved "https://registry.yarnpkg.com/fakefilter/-/fakefilter-0.1.663.tgz#68903a8a45d2ec0b6d18a6ed408eea515927f22d"
integrity sha512-0cLVuCX0y1LR9NBT+aOhPJFkYqA9VIooDwLtrlkV2QgWXjyj93E7Nh7sDON+oDyd51HvdBDKnDdO5kZflHFxvQ==

falafel@^2.1.0:
version "2.2.5"
resolved "https://registry.npmjs.org/falafel/-/falafel-2.2.5.tgz"
Expand Down