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

Signing API client versioning #8685

Closed
wagnerand opened this issue Feb 9, 2022 · 23 comments · Fixed by mozilla/addons-server#19845
Closed

Signing API client versioning #8685

wagnerand opened this issue Feb 9, 2022 · 23 comments · Fixed by mozilla/addons-server#19845
Assignees
Labels
repository:addons-server Issue relating to addons-server
Milestone

Comments

@wagnerand
Copy link
Member

In order to support and align compatibility between the signing API and clients like web-ext, this API should take a parameter with each call indicating the client application and version. When our own supported clients like web-ext make requests to the API, we can parse that information and make sure the client is compatible with it. Additionally, we can ensure that clients use a minimum version of web-ext for a particular signing API version or feature. Doing so will help ensure users are on recent versions and that requirements, recommendations or best practices for submission and signing can be shown to the user via web-ext.

@diox
Copy link
Member

diox commented Feb 9, 2022

I think this should be done through the User-Agent, and perhaps sign-addon and web-ext versions should be present if applicable.

So, a request from sign-addon from an unknown 3rd party would look like:
User-Agent: sign-addon/x.y

A request from web-ext would look like:
User-Agent: web-ext/w.y, sign-addon/x.y

@eviljeff
Copy link
Member

@wagnerand can you give an example (assuming this is a current, rather than future problem)? Like, a version id (or range) of webext that is incompatible with a current AMO api feature?

@wagnerand
Copy link
Member Author

The concrete idea here is that this would allow us to require certain information to be passed by a developer. One of the biggest challenges we identified through metrics is missing source code submissions. Now that the API allows to provide that, one approach would be to add a new argument to web-ext that specifies either holds the source code package or states that sources are not needed. Obviously, only newer/future versions of web-ext would have this feature, so we need to be able to nudge users towards keeping web-ext up to date (also for other things like linting rules etc). The compatibility alignment is an abstraction of the problem that allows for more and future use cases.

And in any case, it would be good to have insights on what versions of our client libraries developers are on so we can understand and assess support cycles.

@eviljeff
Copy link
Member

eviljeff commented Mar 9, 2022

If we're going with User-Agent are there any changes we need to make right now in addons-server? It seems like a feature we'd need to implement if in the future there is an incompatible change?

Or if we want to start warning users about keeping up to date with webext and/or specify a user agent for non-webext uses, as soon as webext supports sending the custom User-Agent (i.e. we'd warn on generic user agents). In either case I presume we're blocked on a change in webext (is there an issue filed for the changes there?)

@stale
Copy link

stale bot commented Sep 21, 2022

This issue has been automatically marked as stale because it has not had recent activity. If you think this bug should stay open, please comment on the issue with further details. Thank you for your contributions.

@stale stale bot added the state:stale Issues marked as stale. These can be re-opened should there be plans to fix them. label Sep 21, 2022
@wagnerand wagnerand removed the state:stale Issues marked as stale. These can be re-opened should there be plans to fix them. label Sep 21, 2022
@eviljeff
Copy link
Member

@wagnerand after mozilla/web-ext#2538 lands and the release version of web-ext starts sending web-ext/1.23 as the user agent, what should addons-server do, exactly? (if anything, right now)

@wagnerand
Copy link
Member Author

A good start would be to graph the stats on version numbers internally. Obviously we're only starting now to have that info, so many requests won't have it, but over time, that should change.

We could also look into the use case I described above about source code submission. Specifically for the new submission API, we could require a newer web-ext version to make sure it supports the requirement for the developer to state that sources are either attached or not needed.

@eviljeff
Copy link
Member

eviljeff commented Oct 27, 2022

A good start would be to graph the stats on version numbers internally. Obviously we're only starting now to have that info, so many requests won't have it, but over time, that should change.

We can fire a statsd pings so a grafana dashboard can be created, sure.

we could require a newer web-ext version to make sure it supports the requirement for the developer to state that sources are either attached or not needed.

Can you link to the web-ext issue for that feature? This seems like a later issue we'd work on once web-ext already required it (and the stats showed was widely used)

@wagnerand
Copy link
Member Author

wagnerand commented Oct 27, 2022

Can you link to the web-ext issue for that feature? This seems like a later issue we'd work on once web-ext already required it (and the stats showed was widely used)

I believe that's mozilla/web-ext#2497

@eviljeff
Copy link
Member

Can you link to the web-ext issue for that feature? This seems like a later issue we'd work on once web-ext already required it (and the stats showed was widely used)

I believe that's mozilla/web-ext#2497

Ah. That would be a blocker to it - to actually allow sources to be uploaded - but it isn't going to enforce sources, or require the developer somehow confirm that sources aren't needed. Can you file an issue that details how you suggest that parameter would work so the web-ext maintainers can weigh in. Another blocker would be the --use-submission-api becoming a non-experimental option, imo.

@eviljeff eviljeff self-assigned this Oct 27, 2022
@wagnerand
Copy link
Member Author

Can you link to the web-ext issue for that feature? This seems like a later issue we'd work on once web-ext already required it (and the stats showed was widely used)

I believe that's mozilla/web-ext#2497

Ah. That would be a blocker to it - to actually allow sources to be uploaded - but it isn't going to enforce sources, or require the developer somehow confirm that sources aren't needed. Can you file an issue that details how you suggest that parameter would work so the web-ext maintainers can weigh in. Another blocker would be the --use-submission-api becoming a non-experimental option, imo.

mozilla/web-ext#2543

@ioanarusiczki
Copy link

@eviljeff
I tried a Postman request for a version upload using the signing API -> was successful , this is the version

but I don't know what to do from here. Can you add some str ?

@eviljeff
Copy link
Member

eviljeff commented Nov 4, 2022

@eviljeff I tried a Postman request for a version upload using the signing API -> was successful , this is the version

but I don't know what to do from here. Can you add some str ?

If an add-on or version is successfully created via the signing or addon submission APIs then the user agent header is processed and we count web-ext versions. Only web-ext user agents though. (And the release version of `web-ext doesn't send the header yet)

So STR would be something like:

  • use Postman (or some other tool that can set the HTTP_USER_AGENT header) to simulate what future web-ext will do, to submit an add-on via /api/v4/signing/
  • make sure the header "HTTP_USER_AGENT": "web-ext/9999.1234" is sent with the request (anything web-ext/<combination of digits and .> should be matched)
  • repeat with one of the addon submission api endpoints (it's the final create that's captured, not the xpi upload)
  • ask someone with access to grafana to check the user agent has been counted (e.g. me)

@ioanarusiczki
Copy link

@eviljeff

I sent https://addons-dev.allizom.org/api/v4/addons/{a42af60a-fd42-43d5-bf1b-f34302917b2a}/versions/4.0.5.4/ with "HTTP_USER_AGENT: web-ext/9999.1234"

Another one with https://addons-dev.allizom.org/api/v5/addons/ and "HTTP_USER_AGENT:web-ext/123.456"

Also https://addons-dev.allizom.org/api/v5/addons/upload/ with "HTTP_USER_AGENT:web-ext/1.2"

@eviljeff
Copy link
Member

eviljeff commented Nov 7, 2022

@eviljeff

I sent https://addons-dev.allizom.org/api/v4/addons/{a42af60a-fd42-43d5-bf1b-f34302917b2a}/versions/4.0.5.4/ with "HTTP_USER_AGENT: web-ext/9999.1234"

Another one with https://addons-dev.allizom.org/api/v5/addons/ and "HTTP_USER_AGENT:web-ext/123.456"

Sorry, I gave the django name for the header - if postman doesn't support some generic way of specifying the user agent string, then the raw header is actually named User-Agent

Also https://addons-dev.allizom.org/api/v5/addons/upload/ with "HTTP_USER_AGENT:web-ext/1.2"

This is the xpi upload endpoint, so it's not captured. Only the endpoints that create new add-ons or versions.

@eviljeff eviljeff reopened this Nov 7, 2022
@eviljeff
Copy link
Member

eviljeff commented Nov 7, 2022

The debugging log statements indicated that the real User-Agent header value is being removed by Cloudfront (even though these requests wouldn't be cached by Cloudfront because they're authenticated). We will need to change something to forward the user agent header values if we are going to continue to use this strategy to log web-ext versions.

@eviljeff
Copy link
Member

eviljeff commented Nov 7, 2022

logged https://mozilla-hub.atlassian.net/browse/SVCSE-888 for SRE to make the appropriate change

@eviljeff
Copy link
Member

eviljeff commented Nov 9, 2022

https://github.com/mozilla-services/cloudops-deployment/pull/4729 adds this to the appropriate SRE config files. I've confirmed it works on addons-dev.

@ioanarusiczki can you test on stage with the User-Agent of 123.456? I can see if it shows up on https://earthangel-b40313e5.influxcloud.net/d/PisVfMBnz/amo-add-on-submissions

@eviljeff
Copy link
Member

eviljeff commented Nov 9, 2022

(I'll close this issue once SRE have confirmed it's been deployed to prod too)

@ioanarusiczki
Copy link

@eviljeff I sent 2 requests with the new submission API - User-Agent: webext/123.456

@ioanarusiczki
Copy link

@eviljeff I tried with the old signing API for https://addons.allizom.org/api/v5/addons/{5e840ca1-bbc8-4048-ab6b-ef5b082d16d7}/versions/5.0.0.6/ -> webext/123.456

@eviljeff
Copy link
Member

@eviljeff I tried with the old signing API for https://addons.allizom.org/api/v5/addons/{5e840ca1-bbc8-4048-ab6b-ef5b082d16d7}/versions/5.0.0.6/ -> webext/123.456

From the logs, only one of these three requests seems to have been sent with web-ext/123.456 - the other two are webext/123.456 (note the missing -). It needs to be an exact match for web-ext/<numbers and .s> for it to be captured and sent along.

@KevinMind KevinMind added migration:no-jira repository:addons-server Issue relating to addons-server labels May 4, 2024
@KevinMind KevinMind transferred this issue from mozilla/addons-server May 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
repository:addons-server Issue relating to addons-server
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants