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, Nov 20, 2:16 PM
Unknown Object (File)
Wed, Nov 20, 2:16 PM
Unknown Object (File)
Sun, Nov 10, 2:08 PM
Unknown Object (File)
Fri, Nov 8, 11:05 PM
Unknown Object (File)
Fri, Nov 8, 12:25 PM
Unknown Object (File)
Thu, Nov 7, 12:40 AM
Unknown Object (File)
Wed, Nov 6, 7:58 PM
Unknown Object (File)
Wed, Nov 6, 4:44 PM
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