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

(feat/samples): Add AMD token generation sample #27

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

radu-matei
Copy link
Member

This commit adds a sample that showcases token generation for Adaptive Media Delivery.

This commit adds a sample that showcases token generation for Adaptive
Media Delivery.

Signed-off-by: Radu Matei <[email protected]>
version = "0.1.0"

[variables]
encryption_key = { required = true }
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be a secret?

Copy link

@lann lann Mar 3, 2025

Choose a reason for hiding this comment

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

Note that secret = true doesn't actually do anything today. It was meant to allow partial debug logging of variable values but instead we just never log any. 🤷

Copy link

Choose a reason for hiding this comment

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

I suppose optimistically some external tooling could take it into account 😅

const encoder = new TextEncoder();
const data = encoder.encode(message);

// Use crypto.subtle.sign instead of crypto.hmac
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it'd be good to expand on the comment here a bit, and explain why this is a valid thing to do

Copy link
Contributor

@tschneidereit tschneidereit left a comment

Choose a reason for hiding this comment

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

LGTM!

}

// Handle token generation
if path == "/rustapi/token" {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would tend to invert this check and return early with the 404, so the rest of the code can be unindented a level—but certainly not blocking at all.

@itowlson
Copy link
Contributor

itowlson commented Mar 6, 2025

@radu-matei can this merge or are you still working on it?

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.

4 participants