Skip to content

Rename operation ID to token #16

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

Merged
merged 2 commits into from
Feb 4, 2025
Merged

Conversation

bergundy
Copy link
Contributor

@bergundy bergundy commented Feb 4, 2025

Rename operation ID to token to clarify that it is meant to be opaque. Tokens may be encrypted, signed, and used as OTPs.

Also removed the operation ID from the request paths and accept the token as either a query param or a header.

@@ -229,10 +242,15 @@ Retrieve operation result.

Retrieve operation details.

**Path**: `/{service}/{operation}/{operation_id}`
Copy link

@cretz cretz Feb 4, 2025

Choose a reason for hiding this comment

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

I do not think we should remove the token from the URL path on these. At the very least it should be a query parameter, though in the URL path makes more sense IMO. Using headers as required parameters to specific HTTP calls is strange (as opposed to general metadata like auth). Referencing different operations in a call should be different URLs IMO.

Is the only reason to remove from the URL because after discussion we expect this string to be bigger or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is similar to the callback token where we decided to not put it in the URL since URLs are typically logged in access logs and we don't want potentially sensitive information leaking there.

Choose a reason for hiding this comment

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

If it is sensitive shouldn't it be encrypted?

Copy link

@cretz cretz Feb 4, 2025

Choose a reason for hiding this comment

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

Is token meant to be more sensitive than ID for this use case? Calling a string to reference the operation an "id" or "token" doesn't really change the purpose. Using headers as required parameters for these calls to work is rough devexp I wouldn't expect from normal HTTP APIs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If it is sensitive shouldn't it be encrypted?

Yes, but it still doesn't stop someone from potentially stealing your token.

Copy link

Choose a reason for hiding this comment

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

My concern is this is a significant usability regression of the Nexus HTTP API. Is it possible to not go backwards in dev experience? For instance, maybe this header approach can be an alternative instead of the required way to give this parameter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was just thinking the same thing. We could have two approaches, so users that are concerned with tokens leaking could send it as a header. That's essentially what the related Go SDK PR allows.

Let's keep it path based for now and rename, we can add the header approach later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Working on this now and feeling a bit on the fence here. Let me think about this some more.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pushed a change, LMK what you think.

Copy link

Choose a reason for hiding this comment

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

LGTM. Could also understand if we wanted to reserve some paths for an eventual no-token future, or I could also understand if you wanted token to be a query parameter instead of path piece so it can be more easily made optional in lieu of a header later.

@bergundy bergundy force-pushed the operation-token branch 2 times, most recently from 2feefde to f75530b Compare February 4, 2025 21:43
@bergundy bergundy requested a review from cretz February 4, 2025 21:43
@bergundy bergundy changed the title Nexus-Operation-Token Rename operation ID to token Feb 4, 2025
@@ -229,10 +242,15 @@ Retrieve operation result.

Retrieve operation details.

**Path**: `/{service}/{operation}/{operation_id}`
Copy link

Choose a reason for hiding this comment

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

LGTM. Could also understand if we wanted to reserve some paths for an eventual no-token future, or I could also understand if you wanted token to be a query parameter instead of path piece so it can be more easily made optional in lieu of a header later.

@bergundy
Copy link
Contributor Author

bergundy commented Feb 4, 2025

Hmm.. maybe a query param is a better fit here, then the same paths could be used with either headers or queries.

Yeah, let me go with that.

@bergundy bergundy requested a review from cretz February 4, 2025 22:53
@bergundy bergundy merged commit 7f86303 into nexus-rpc:main Feb 4, 2025
1 check passed
@bergundy bergundy deleted the operation-token branch February 4, 2025 23:02
bergundy added a commit to nexus-rpc/sdk-go that referenced this pull request Feb 4, 2025
- Also fix docstring for handler error types
- Also mark all exported functions and structs in completion.go as
experimental - those need to be redone to properly rehydrate errors

See also nexus-rpc/api#16
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