Page MenuHomePhabricator

[identity] check that incoming requests contain valid auth token
ClosedPublic

Authored by varun on Feb 21 2023, 3:39 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Apr 17, 3:59 AM
Unknown Object (File)
Wed, Apr 17, 3:59 AM
Unknown Object (File)
Wed, Apr 17, 3:59 AM
Unknown Object (File)
Wed, Apr 17, 3:59 AM
Unknown Object (File)
Wed, Apr 17, 3:59 AM
Unknown Object (File)
Wed, Apr 17, 3:59 AM
Unknown Object (File)
Wed, Apr 17, 3:58 AM
Unknown Object (File)
Wed, Apr 17, 3:53 AM
Subscribers

Details

Summary
  • statically initialize config so that we can access it from request interceptor
  • write interceptor function that compares authorization key from request metadata with the config token value
  • remove config param from other functions now that the config is static
Test Plan
  • first, ran the server and verified that the process exits if the AUTH_TOKEN variable is not present
  • then, set the env var and attempted to send requests to the server without any metadata; they were rejected as expected
  • lastly, sent a request with authorization key set in the metadata and received a successful response

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

services/identity/src/interceptor.rs
6 ↗(On Diff #22898)

in the future, this function should compare the request metadata's auth token with the token value we have in DynamoDB for the user

Harbormaster returned this revision to the author for changes because remote builds failed.Feb 21 2023, 3:43 PM
Harbormaster failed remote builds in B16740: Diff 22897!
Harbormaster failed remote builds in B16741: Diff 22898!
Harbormaster returned this revision to the author for changes because remote builds failed.Feb 21 2023, 5:21 PM
Harbormaster failed remote builds in B16744: Diff 22904!

add default config for auth token

Harbormaster returned this revision to the author for changes because remote builds failed.Feb 21 2023, 6:23 PM
Harbormaster failed remote builds in B16745: Diff 22905!

only load config if we're running the server

varun requested review of this revision.Feb 21 2023, 6:55 PM

We also need to do the other half of this on the client side

example intercepter https://github.com/hyperium/tonic/blob/4e578b5046804eb7abb2da80680366769b2a08fd/examples/src/interceptor/client.rs#L57

services/identity/src/constants.rs
40 ↗(On Diff #22906)

Can we name it something more distinct, like COMM_IDENTITY_AUTH_TOKEN. AUTH_TOKEN is likely to collide with something else.

jon requested changes to this revision.Feb 22 2023, 2:09 PM
This revision now requires changes to proceed.Feb 22 2023, 2:09 PM
services/identity/src/constants.rs
40 ↗(On Diff #22906)

D6825 uses COMM_IDENTITY_SERVICE_AUTH_TOKEN which I think is also good for me.

In D6824#203292, @jon wrote:

We also need to do the other half of this on the client side

example intercepter https://github.com/hyperium/tonic/blob/4e578b5046804eb7abb2da80680366769b2a08fd/examples/src/interceptor/client.rs#L57

next diff

services/identity/src/constants.rs
40 ↗(On Diff #22906)

yeah i'll change the actual env var name; gonna keep the variable name the same though since it's temporary and i doubt we'll have collisions in our code

This revision is now accepted and ready to land.Feb 25 2023, 1:05 PM