Page MenuHomePhabricator

[Tunnelbroker] implement OAuth 2.0 JWT token encoding
ClosedPublic

Authored by kamil on Jul 15 2024, 9:35 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Sep 25, 7:05 PM
Unknown Object (File)
Wed, Sep 25, 7:05 PM
Unknown Object (File)
Sat, Sep 21, 10:46 PM
Unknown Object (File)
Sat, Sep 21, 10:30 AM
Unknown Object (File)
Fri, Sep 20, 11:40 PM
Unknown Object (File)
Fri, Sep 20, 6:47 PM
Unknown Object (File)
Sep 16 2024, 3:16 AM
Unknown Object (File)
Sep 15 2024, 10:07 AM
Subscribers

Details

Summary

Implementing what is described in Google's OAuth 2.0 for Server to Server Applications, Forming the JWT claim set.

get_auth_bearer is only public method, will handle generating and refreshing token.

Depends on D12753

Test Plan

Call get_jwt_token and test if returns the correct JWT token in the format

{Base64url encoded header}.{Base64url encoded claim set}

Later in the stack this token is used to make an HTTP call to get an access token for the FCM push service.

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

kamil held this revision as a draft.
kamil published this revision for review.Jul 16 2024, 2:36 AM
kamil added inline comments.
services/tunnelbroker/src/notifs/fcm/mod.rs
20

Docs say: Token must be a short-lived token (60 minutes) and in a reasonable timeframe. so I set this to 55 minutes to leave a buffer to refresh but keep it as long as possible to avoid refreshing this too often.

services/tunnelbroker/src/notifs/fcm/token.rs
21

This is optional to allow creating instances of this without calling OAuth, I want to create FCMToken and FCMClient regardless of minting access token

36–40

generating this when is None in next diff

57
62–65

See Computing the signature here

bartek added inline comments.
services/tunnelbroker/src/notifs/fcm/mod.rs
20

Good to add this as an in-code comment

services/tunnelbroker/src/notifs/fcm/token.rs
36–40

Looked at D12765 and D12766 and generally it can be done better when it comes to code quality, but the logic is just fine so it can stay

This revision is now accepted and ready to land.Jul 18 2024, 7:15 AM