Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3295684
D11282.id37945.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D11282.id37945.diff
View Options
diff --git a/keyserver/src/keyserver.js b/keyserver/src/keyserver.js
--- a/keyserver/src/keyserver.js
+++ b/keyserver/src/keyserver.js
@@ -41,6 +41,7 @@
multimediaUploadResponder,
uploadDownloadResponder,
} from './uploads/uploads.js';
+import { createConfigFiles } from './user/create-configs.js';
import { verifyUserLoggedIn } from './user/login.js';
import { initENSCache } from './utils/ens-cache.js';
import { getContentSigningKey } from './utils/olm-utils.js';
@@ -106,6 +107,8 @@
ignorePromiseRejections(
createAndMaintainTunnelbrokerWebsocket(identityInfo),
);
+
+ await createConfigFiles(identityInfo.userId);
} catch (e) {
console.warn(
'Failed identity login. Login optional until staging environment is available',
diff --git a/keyserver/src/user/create-configs.js b/keyserver/src/user/create-configs.js
new file mode 100644
--- /dev/null
+++ b/keyserver/src/user/create-configs.js
@@ -0,0 +1,63 @@
+// @flow
+
+import fs from 'fs';
+
+import { getCommConfig } from 'lib/utils/comm-config.js';
+
+import type { UserCredentials } from './checks.js';
+
+async function createConfigFiles(userID: string) {
+ const userInfo = await getCommConfig<UserCredentials>({
+ folder: 'secrets',
+ name: 'user_credentials',
+ });
+
+ if (!userInfo?.usingIdentityCredentials) {
+ // If the keyserver is not set up to use its identity id,
+ // we will also not set up the clients to use the keyservers real id
+ return;
+ }
+
+ try {
+ const authoritativeKeyserver = {
+ authoritativeKeyserverID: userID,
+ };
+ const authoritativeKeyserverJSON = JSON.stringify(
+ authoritativeKeyserver,
+ null,
+ 2,
+ );
+ const authoritativeKeyserverFile = 'authoritative_keyserver.json';
+
+ const nativeFactsFolder = '../native/facts';
+ if (!fs.existsSync(nativeFactsFolder)) {
+ fs.mkdirSync(nativeFactsFolder);
+ }
+ const nativeAuthoritativeKeyserverFile = `${nativeFactsFolder}/${authoritativeKeyserverFile}`;
+ fs.writeFileSync(
+ nativeAuthoritativeKeyserverFile,
+ authoritativeKeyserverJSON,
+ );
+
+ const keyserverFactsFolder = 'facts';
+ if (!fs.existsSync(keyserverFactsFolder)) {
+ fs.mkdirSync(keyserverFactsFolder);
+ }
+ const keyserverAuthoritativeKeyserverFile = `${keyserverFactsFolder}/${authoritativeKeyserverFile}`;
+ fs.writeFileSync(
+ keyserverAuthoritativeKeyserverFile,
+ authoritativeKeyserverJSON,
+ );
+ } catch (e) {
+ // This means that the clients will not be configured to use
+ // the real keyserver id, and will use the default 256.
+ // Try restarting the keyserver or create the files manually
+ console.error(
+ 'Failure creating configuration files: ' +
+ 'admin data could not be correctly written',
+ e,
+ );
+ }
+}
+
+export { createConfigFiles };
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 17, 10:45 PM (21 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2532153
Default Alt Text
D11282.id37945.diff (2 KB)
Attached To
Mode
D11282: [keyserver] Create json files with authoritative keyserver id
Attached
Detach File
Event Timeline
Log In to Comment