Page MenuHomePhabricator

[keyserver] Get WNS authorization tokens
ClosedPublic

Authored by michal on Mar 31 2023, 5:19 AM.
Tags
None
Referenced Files
F3520636: D7267.id24561.diff
Mon, Dec 23, 12:58 AM
F3520368: D7267.id24666.diff
Mon, Dec 23, 12:11 AM
F3520057: D7267.id24939.diff
Sun, Dec 22, 11:21 PM
Unknown Object (File)
Sat, Dec 7, 8:30 PM
Unknown Object (File)
Sat, Dec 7, 8:30 PM
Unknown Object (File)
Fri, Dec 6, 9:54 PM
Unknown Object (File)
Thu, Dec 5, 8:38 PM
Unknown Object (File)
Nov 10 2024, 8:37 PM
Subscribers

Details

Summary

We need to get WNS (windows notification service) access token from our WNS secrets. This access token is required to send the notifications. This is just a simple POST request taken from the quickstart tutorial.

Test Plan

Run the new function and check if the acces token is properly returned. Modify the returned 'expires_in' value to a smaller one and check if the token is requested again.

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

I can't plan changes before the CI passes but I forgot to switch to node-fetch so I'm removing the reviewers for now.

michal added inline comments.
keyserver/src/push/providers.js
130 ↗(On Diff #24561)

This is to handle an edge case when the token is near expiring and we preemptively refresh it in case of longer network latency etc. Inspired by the readme in this library (I didn't add it as a dependency because it didn't seem worth just to handle this one case of oauth).

tomek added inline comments.
keyserver/src/push/providers.js
130 ↗(On Diff #24561)

For how long a new token lives? Should we make this duration as long as a request timeout?

135 ↗(On Diff #24561)

When are we going to extend this token lifetime? I guess if we return a token that has just 301ms left we don't have too much time to act.

138–141 ↗(On Diff #24561)

Should we include a note about this in our docs? Do we store this file in 1Password?

160 ↗(On Diff #24561)

Can we add a little more explanation to this error?

This revision is now accepted and ready to land.Apr 4 2023, 3:37 AM
keyserver/src/push/providers.js
154–157 ↗(On Diff #24561)

In the guide Content-Type header is set - is there a reason to not do that?

Extended the duration of the token to 10s so we have more time to act. All of the tokens I had gotten from WNS previously, had 1h expiry time so it's still a small portion of the expiry time. Added better error explanation.

keyserver/src/push/providers.js
138–141 ↗(On Diff #24561)

I didn't add any new docs when adding web notifs, but if we have any official place for these I can definitely added them. There's a bit more info in the ENG-3562. The values themselves are stored in the 1Password.

154–157 ↗(On Diff #24561)

It should be set automatically because we are using URLSearchParams docs