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

JWT condition #604

Draft
wants to merge 6 commits into
base: epic-v0.6.x
Choose a base branch
from
Draft

JWT condition #604

wants to merge 6 commits into from

Conversation

vzotova
Copy link
Member

@vzotova vzotova commented Dec 13, 2024

Type of PR:

  • Bugfix
  • Feature
  • Documentation
  • Other

Required reviews:

  • 1
  • 2
  • 3

What this does:

Implements JWT condition

Issues fixed/closed:

See #3567

Why it's needed:

Explain how this PR fits in the greater context of the NuCypher Network. E.g.,
if this PR address a nucypher/productdev issue, let reviewers know!

Notes for reviewers:

What should reviewers focus on? Is there a particular commit/function/section
of your PR that requires more attention from reviewers?

@vzotova vzotova self-assigned this Dec 13, 2024
@vzotova vzotova marked this pull request as ready for review December 13, 2024 19:37
@codecov-commenter
Copy link

codecov-commenter commented Dec 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (epic-v0.6.x@b795b3c). Learn more about missing BASE report.

Additional details and impacted files
@@              Coverage Diff               @@
##             epic-v0.6.x     #604   +/-   ##
==============================================
  Coverage               ?   89.30%           
==============================================
  Files                  ?       77           
  Lines                  ?     6676           
  Branches               ?      363           
==============================================
  Hits                   ?     5962           
  Misses                 ?      679           
  Partials               ?       35           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


export const jwtConditionSchema = baseConditionSchema.extend({
conditionType: z.literal(JWTConditionType).default(JWTConditionType),
public_key: z.string().optional(),
Copy link
Contributor

Choose a reason for hiding this comment

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

are these parameters really optional?

Copy link
Member Author

Choose a reason for hiding this comment

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

I need @cygnusv help with that

subject: contextParamSchema.optional(),
expiration_window: z.number().int().nonnegative().optional(),
issued_window: z.number().int().nonnegative().optional(),
jwtToken: contextParamSchema.default(JWT_PARAM_DEFAULT),
Copy link
Contributor

Choose a reason for hiding this comment

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

isn't the jwtToken what the user will provide at decryption time? rather than being defined in the condition

Copy link
Member Author

Choose a reason for hiding this comment

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

yep, you are correct, here is defined that some user param must be provided or used default :jwtToken

Copy link
Member

Choose a reason for hiding this comment

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

@derekpierre derekpierre marked this pull request as draft December 16, 2024 15:50
@derekpierre
Copy link
Member

Converted to draft since this work shouldn't be merged before nucypher/nucypher#3570 (currently in draft) is merged

packages/taco/src/conditions/context/context.ts Outdated Show resolved Hide resolved
packages/taco/src/conditions/schemas/json-api.ts Outdated Show resolved Hide resolved
packages/taco/src/conditions/schemas/jwt.ts Show resolved Hide resolved
@@ -19,3 +19,8 @@ export const TEST_SIWE_PARAMS = {
domain: 'localhost',
uri: 'http://localhost:3000',
};

export const TEST_ECDSA_PUBLIC_KEY =
Copy link
Member

@derekpierre derekpierre Dec 16, 2024

Choose a reason for hiding this comment

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

Is it possible to provide the public key without the PEM header and footer i.e. just use the base64, or hex if that is more familiar/acceptable (although less efficient in terms of space)? On the server-side we can do some adjustment if needed: convert it to PEM, OR not bother if the library allows base64/hex format, or ...

(cc @cygnusv )

vzotova added a commit to vzotova/taco-web that referenced this pull request Dec 16, 2024
@derekpierre derekpierre mentioned this pull request Dec 17, 2024
20 tasks
vzotova added a commit to vzotova/taco-web that referenced this pull request Dec 19, 2024
Comment on lines 14 to 16
subject: contextParamSchema.optional(),
expirationWindow: z.number().int().nonnegative().optional(),
issuedWindow: z.number().int().nonnegative().optional(),
Copy link
Member

Choose a reason for hiding this comment

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

@vzotova let's comment/drop these lines for the moment. The corresponding PR on the nucypher side will only validate the expected issuer and public key. We can easily add more restrictions like these once we have more clarity on what's actually needed.

Copy link
Member Author

Choose a reason for hiding this comment

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

✔️

Copy link
Member

@derekpierre derekpierre left a comment

Choose a reason for hiding this comment

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

Needs a rebase now that #606 is merged.


export const jwtConditionSchema = baseConditionSchema.extend({
conditionType: z.literal(JWTConditionType).default(JWTConditionType),
publicKey: z.string().optional(),
Copy link
Member

Choose a reason for hiding this comment

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

Based on nucypher/nucypher#3570, publicKey is a required property.

Copy link
Member Author

Choose a reason for hiding this comment

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

✔️

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.

5 participants