HomePhabricator
Diffusion Comm 562ef92502c2

[keyserver] change how we load config for the identity service client

Description

[keyserver] change how we load config for the identity service client

Summary:
in production, we load secrets/facts from files into environment variables. here, we read the environment variable that corresponds to the identity_service_config file, getting back stringified json. then we try to parse the string directly to an IdentityServiceConfig struct. This is all done inside a lazy_static so that we can access the config easily from the rust-node-addon.

If the env var isn't set or there's an error reading it, we'll fall back on the default value defined in the Default trait implementation of IdentityServiceConfig.

If we get back a JSON string that can't be parsed into an IdentityServiceConfig struct, we will panic, because that means our JSON file is malformed.

I wanted to just use the importJSON function in utils, but that meant either 1. calling js from Rust, which I couldn't figure out how to do, or 2. passing the relevant config to all the functions exposed by the RustAPI, which seemed like a bad practice.

Test Plan:
set the COMM_JSONCONFIG_secrets_identity_service_config env var with valid and then invalid json. then i unset the variable

with valid json, I was able to connect to a manually deployed test identity server.

with invalid json, the keyserver crashed, as expected

with no env var set, the keyserver connected to my local instance of the identity service

Reviewers: jon, bartek, ashoat

Reviewed By: jon

Subscribers: tomek, atul

Differential Revision: https://phab.comm.dev/D6955

Details

Provenance
varunAuthored on Mar 3 2023, 9:15 PM
Reviewer
jon
Differential Revision
D6955: [keyserver] change how we load config for the identity service client
Parents
rCOMM8bf9af343487: [Keyserver/identity] Call identity service update_user
Branches
Unknown
Tags
Unknown