issue: ENG-6633
Replacing ashoatKeyserverID with calls to fetchIdentityInfo - because this is async I had to make a couple of functions that need it be async as well.
Details
Tested that state sync still works by logging infosHash in checkState and compoaring with values returned by the previous code, on a client in with the same state.
Tested that the id is fetched correctly in getInitialReduxStateResponder and validateOutput (by checking that ids are prefixed correctly)
Diff Detail
- Repository
- rCOMM Comm
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
Some devs already have identity info in their dbs, this code will result in the id from the db being used instead of ashoatKeyserverID. This is not good, because the clients have ids prefixed with 256, so input validation will fail, and data sent by the server would be prefixed incorrectly, until the clients configure theis authoritativeKeyserverID. I need to handle this case
Check if the keyserver can use its id when communicating with clients
I decided to use a config file and fetch it with getCommConfig. If it is not present, then we use 256. otherwise, if present and contains "usingIdentityCredentials:: true, then we use value returned by identity.
This way, my script that:
- sets keyserver/secrets/user_credentials.json
- logs in with identity using data from keyserver/secrets/user_credentials.json, and obtains user id
- sets this user id as authoritativeKeyserverID for clients
Can also create this config, allowing the keyserver to use its id when communicating with clients
In the keyserver we:
- need a file with admins id (ENG-6614)
- need a file with admins username and password - user_credentials.json
- wanted to add a flag to user_credentials.json that would tell the keyserver if it should use its id, or 256
I think we can merge these and add id to user_credentials.json, and if present, use it.
The username, password and id will be written to user_credentials.json by my script after registering / logging in the user. In the intermediate solution, the dev will have to type the id in manually along with the username and password.
keyserver/src/user/login.js | ||
---|---|---|
111–113 ↗ | (On Diff #37070) | If we were able to log in to Identity, and the returned ID is inconsistent, we probably won't be able to successfully run the app - there should be some issues. So I guess it's better to kill the keyserver and inform the dev that a config should be fixed. |
keyserver/src/shared/state-sync/current-user-state-sync-spec.js | ||
---|---|---|
25 ↗ | (On Diff #37319) | We don't need this await - if a promise is returned from an async function its result gets automatically unwrapped. |
keyserver/src/shared/state-sync/threads-state-sync-spec.js | ||
45 ↗ | (On Diff #37319) | getServerInfoHash calls fetchIdentityInfo which means that for each thread we're fetching a value from the DB. Can we avoid this? Can we modify getServerInfoHash function to accept a keyserverID? |
keyserver/src/shared/state-sync/current-user-state-sync-spec.js | ||
---|---|---|
25 ↗ | (On Diff #37319) | Is there an upside to skipping it? |
keyserver/src/shared/state-sync/current-user-state-sync-spec.js | ||
---|---|---|
25 ↗ | (On Diff #37319) | I guess there might be an insignificant performance difference. But up to you - I don't think it matters too much. |