make MI access token have string id

This commit is contained in:
Maidul Islam
2024-01-27 12:40:37 +05:30
committed by Akhil Mohan
parent 442c454932
commit f9e7d4ddd2
+27 -4
View File
@@ -1539,6 +1539,11 @@ const main = async () => {
postgresTableName: TableName.IdentityUniversalAuth, postgresTableName: TableName.IdentityUniversalAuth,
returnKeys: ["id"], returnKeys: ["id"],
preProcessing: async (doc) => { preProcessing: async (doc) => {
// dangling identity
if (!await identityKv.get(doc.identity.toString()).catch(() => null)){
return
}
const id = uuidV4(); const id = uuidV4();
const identityId = await identityKv.get(doc.identity.toString()); const identityId = await identityKv.get(doc.identity.toString());
await identityUaKv.put(doc._id.toString(), id); await identityUaKv.put(doc._id.toString(), id);
@@ -1570,6 +1575,11 @@ const main = async () => {
postgresTableName: TableName.IdentityUaClientSecret, postgresTableName: TableName.IdentityUaClientSecret,
returnKeys: ["id"], returnKeys: ["id"],
preProcessing: async (doc) => { preProcessing: async (doc) => {
// dangling identity
if (!await identityKv.get(doc.identity.toString()).catch(() => null)){
return
}
const identityUAId = await identityUaKv.get( const identityUAId = await identityUaKv.get(
doc.identityUniversalAuth.toString(), doc.identityUniversalAuth.toString(),
); );
@@ -1598,8 +1608,12 @@ const main = async () => {
postgresTableName: TableName.IdentityAccessToken, postgresTableName: TableName.IdentityAccessToken,
returnKeys: ["id"], returnKeys: ["id"],
preProcessing: async (doc) => { preProcessing: async (doc) => {
const id = uuidV4(); // dangling identity
await identityAccessTokenKv.put(doc._id.toString(), id); if (!await identityKv.get(doc.identity.toString()).catch(() => null)){
return
}
await identityAccessTokenKv.put(doc._id.toString(), doc._id.toString());
const identityUAClientSecretId = doc?.identityUniversalAuthClientSecret const identityUAClientSecretId = doc?.identityUniversalAuthClientSecret
? await identityUaClientSecKv.get( ? await identityUaClientSecKv.get(
doc.identityUniversalAuthClientSecret.toString(), doc.identityUniversalAuthClientSecret.toString(),
@@ -1607,7 +1621,7 @@ const main = async () => {
: null; : null;
const identityId = await identityKv.get(doc.identity.toString()); const identityId = await identityKv.get(doc.identity.toString());
return { return {
id, id: doc._id.toString(),
accessTokenNumUsesLimit: doc.accessTokenNumUsesLimit, accessTokenNumUsesLimit: doc.accessTokenNumUsesLimit,
accessTokenMaxTTL: doc.accessTokenMaxTTL, accessTokenMaxTTL: doc.accessTokenMaxTTL,
accessTokenTTL: doc.accessTokenTTL, accessTokenTTL: doc.accessTokenTTL,
@@ -1629,6 +1643,11 @@ const main = async () => {
postgresTableName: TableName.IdentityOrgMembership, postgresTableName: TableName.IdentityOrgMembership,
returnKeys: ["id"], returnKeys: ["id"],
preProcessing: async (doc) => { preProcessing: async (doc) => {
// dangling identity
if (!await identityKv.get(doc.identity.toString()).catch(() => null)){
return
}
const id = uuidV4(); const id = uuidV4();
const orgId = doc?.organization const orgId = doc?.organization
@@ -1659,6 +1678,11 @@ const main = async () => {
postgresTableName: TableName.IdentityProjectMembership, postgresTableName: TableName.IdentityProjectMembership,
returnKeys: ["id"], returnKeys: ["id"],
preProcessing: async (doc) => { preProcessing: async (doc) => {
// dangling identity
if (!await identityKv.get(doc.identity.toString()).catch(() => null)){
return
}
const id = uuidV4(); const id = uuidV4();
const projectKvRes = await projectKv const projectKvRes = await projectKv
@@ -2443,7 +2467,6 @@ const main = async () => {
if (!secret) return; if (!secret) return;
if (!secret?.secretBlindIndex) return; if (!secret?.secretBlindIndex) return;
return { return {
id, id,
op: CommitType.DELETE, op: CommitType.DELETE,