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

access-control: added new playbackPolicy & webhook trigger #1665

Merged
merged 21 commits into from
Mar 31, 2023

Conversation

gioelecerati
Copy link
Member

What does this pull request do? Explain your changes. (required)

Specific updates (required)

How did you test each of these updates (required)

Does this pull request close any open issues?

Screenshots (optional)

Checklist

  • I have read the CONTRIBUTING document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.

@gioelecerati gioelecerati requested a review from a team as a code owner March 9, 2023 16:28
@vercel
Copy link

vercel bot commented Mar 9, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
livepeer-studio ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Mar 31, 2023 at 1:57PM (UTC)

@codecov
Copy link

codecov bot commented Mar 9, 2023

Codecov Report

Merging #1665 (920fa3f) into master (0fdf423) will decrease coverage by 0.49499%.
The diff coverage is 42.55319%.

❗ Current head 920fa3f differs from pull request most recent head 223cfe8. Consider uploading reports for the commit 223cfe8 to get more accurate results

Impacted file tree graph

@@                 Coverage Diff                 @@
##              master       #1665         +/-   ##
===================================================
- Coverage   53.49990%   53.00491%   -0.49499%     
===================================================
  Files             74          74                 
  Lines           4843        4892         +49     
  Branches         939         952         +13     
===================================================
+ Hits            2591        2593          +2     
- Misses          1923        1967         +44     
- Partials         329         332          +3     
Impacted Files Coverage Δ
packages/api/src/store/errors.ts 54.83871% <0.00000%> (-5.87558%) ⬇️
packages/api/src/controllers/asset.ts 57.73481% <18.18182%> (-1.07201%) ⬇️
packages/api/src/controllers/stream.ts 49.05956% <25.00000%> (-0.46576%) ⬇️
packages/api/src/controllers/access-control.ts 50.00000% <40.00000%> (-33.67347%) ⬇️
packages/api/src/webhooks/cannon.ts 50.00000% <100.00000%> (+0.81081%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0fdf423...223cfe8. Read the comment docs.

Impacted Files Coverage Δ
packages/api/src/store/errors.ts 54.83871% <0.00000%> (-5.87558%) ⬇️
packages/api/src/controllers/asset.ts 57.73481% <18.18182%> (-1.07201%) ⬇️
packages/api/src/controllers/stream.ts 49.05956% <25.00000%> (-0.46576%) ⬇️
packages/api/src/controllers/access-control.ts 50.00000% <40.00000%> (-33.67347%) ⬇️
packages/api/src/webhooks/cannon.ts 50.00000% <100.00000%> (+0.81081%) ⬆️

@gioelecerati gioelecerati marked this pull request as ready for review March 9, 2023 17:11
packages/api/src/controllers/access-control.ts Outdated Show resolved Hide resolved
packages/api/src/controllers/access-control.ts Outdated Show resolved Hide resolved
packages/api/src/controllers/access-control.ts Outdated Show resolved Hide resolved
packages/api/src/controllers/access-control.ts Outdated Show resolved Hide resolved
packages/api/src/controllers/access-control.ts Outdated Show resolved Hide resolved
packages/api/src/schema/schema.yaml Show resolved Hide resolved
packages/api/src/schema/schema.yaml Show resolved Hide resolved
packages/api/src/webhooks/cannon.ts Outdated Show resolved Hide resolved
packages/api/src/webhooks/cannon.ts Outdated Show resolved Hide resolved
packages/api/src/webhooks/cannon.ts Outdated Show resolved Hide resolved
);
}
const webhook = await db.webhook.get(content.playbackPolicy.webhookId);
if (!webhook) {
Copy link
Member

Choose a reason for hiding this comment

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

Also! We must check if the webhook can listen to the event playback.accessControl (or whatever). I know you haven't created it yet, but commenting here as a reminder.

Copy link
Member

Choose a reason for hiding this comment

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

This is still needed 👀

And thinking about it, maybe we should allow fetching an account webhook of the playback.accessControl type, WDYT? So it defaults to idk the oldest active webhook for that event type, if you don't specify it in the playbackPolicy 🤔

Copy link
Member

@victorges victorges left a comment

Choose a reason for hiding this comment

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

LGTM! Mostly nits

packages/api/src/controllers/access-control.ts Outdated Show resolved Hide resolved
);
}
const webhook = await db.webhook.get(content.playbackPolicy.webhookId);
if (!webhook) {
Copy link
Member

Choose a reason for hiding this comment

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

This is still needed 👀

And thinking about it, maybe we should allow fetching an account webhook of the playback.accessControl type, WDYT? So it defaults to idk the oldest active webhook for that event type, if you don't specify it in the playbackPolicy 🤔

packages/api/src/controllers/access-control.ts Outdated Show resolved Hide resolved
packages/api/src/controllers/access-control.ts Outdated Show resolved Hide resolved
packages/api/src/controllers/asset.ts Outdated Show resolved Hide resolved
Comment on lines +1034 to +1055
(playbackPolicy && asset.playbackPolicy?.type === "webhook") ||
playbackPolicy?.type === "webhook"
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps we actually need a helper like isPrivatePlaybackPolicy which does the !== public check, and use it here and in the other place where we choose the OS ID.

Here, the logic we should check is

Suggested change
(playbackPolicy && asset.playbackPolicy?.type === "webhook") ||
playbackPolicy?.type === "webhook"
isPrivatePlaybackPolicy(playbackPolicy) !== isPrivatePlaybackPolicy(asset.playbackPolicy)

WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense, I arrived late on this and now I don't want to touch too much, can open a separate PR

Copy link
Member

Choose a reason for hiding this comment

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

Yeah do it. This is not only a nit, the functionality is incomplete (its ignoring jwt policies for example)

packages/api/src/webhooks/cannon.ts Show resolved Hide resolved
@gioelecerati gioelecerati merged commit 8ca070d into master Mar 31, 2023
@gioelecerati gioelecerati deleted the gio/feat/access-control branch March 31, 2023 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants