Merge pull request #6509 from overleaf/jel-migrate-sso-id
[v1 and web] Migrate institution SSO external user ID GitOrigin-RevId: f31cd50fbada9a2704df1c837d695f2ff547420d
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
const SAMLUserIdAttributeBatchHandler = require('../modules/overleaf-integration/app/src/SAML/SAMLUserIdAttributeBatchHandler')
|
||||
|
||||
const COMMIT = process.argv.includes('--commit')
|
||||
const startInstitutionId = parseInt(process.argv[2])
|
||||
const endInstitutionId = parseInt(process.argv[3])
|
||||
|
||||
process.env.LOG_LEVEL = 'info'
|
||||
|
||||
let method = 'check'
|
||||
if (COMMIT) {
|
||||
method = 'run'
|
||||
console.log('Setting attribute for linked users')
|
||||
} else {
|
||||
process.env.MONGO_CONNECTION_STRING =
|
||||
process.env.READ_ONLY_MONGO_CONNECTION_STRING
|
||||
console.log('Doing a dry run without --commit')
|
||||
console.log('Checking users at institutions')
|
||||
}
|
||||
|
||||
console.log(
|
||||
'Start institution ID:',
|
||||
startInstitutionId ||
|
||||
'none provided, will start at beginning of ordered list.'
|
||||
)
|
||||
console.log(
|
||||
'End institution ID:',
|
||||
endInstitutionId || 'none provided, will go to end of ordered list.'
|
||||
)
|
||||
|
||||
SAMLUserIdAttributeBatchHandler[method](startInstitutionId, endInstitutionId)
|
||||
.then(result => {
|
||||
console.log(result)
|
||||
process.exit(0)
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error)
|
||||
process.exit(1)
|
||||
})
|
||||
@@ -0,0 +1,36 @@
|
||||
process.env.MONGO_CONNECTION_STRING =
|
||||
process.env.READ_ONLY_MONGO_CONNECTION_STRING
|
||||
|
||||
const { waitForDb } = require('../app/src/infrastructure/mongodb')
|
||||
const SAMLUserIdMigrationHandler = require('../modules/overleaf-integration/app/src/SAML/SAMLUserIdMigrationHandler')
|
||||
|
||||
const institutionId = parseInt(process.argv[2])
|
||||
if (isNaN(institutionId)) throw new Error('No institution id')
|
||||
const emitUsers = process.argv.includes('--emit-users')
|
||||
|
||||
console.log('Checking SSO user ID migration for institution:', institutionId)
|
||||
|
||||
waitForDb()
|
||||
.then(main)
|
||||
.catch(error => {
|
||||
console.error(error)
|
||||
process.exit(1)
|
||||
})
|
||||
|
||||
async function main() {
|
||||
const result = await SAMLUserIdMigrationHandler.promises.checkMigration(
|
||||
institutionId
|
||||
)
|
||||
|
||||
if (emitUsers) {
|
||||
console.log(
|
||||
`\nMigrated: ${result.migrated}\nNot migrated: ${result.notMigrated}\nMultiple Identifers: ${result.multipleIdentifiers}`
|
||||
)
|
||||
}
|
||||
|
||||
console.log(
|
||||
`\nMigrated: ${result.migrated.length}\nNot migrated: ${result.notMigrated.length}\nMultiple Identifers: ${result.multipleIdentifiers.length}`
|
||||
)
|
||||
|
||||
process.exit()
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
const { waitForDb } = require('../app/src/infrastructure/mongodb')
|
||||
const SAMLUserIdMigrationHandler = require('../modules/overleaf-integration/app/src/SAML/SAMLUserIdMigrationHandler')
|
||||
|
||||
const institutionId = parseInt(process.argv[2])
|
||||
if (isNaN(institutionId)) throw new Error('No institution id')
|
||||
const emitUsers = process.argv.includes('--emit-users')
|
||||
|
||||
console.log(
|
||||
'Remove SSO linking for users not migrated at institution:',
|
||||
institutionId
|
||||
)
|
||||
|
||||
waitForDb()
|
||||
.then(main)
|
||||
.catch(error => {
|
||||
console.error(error)
|
||||
process.exit(1)
|
||||
})
|
||||
|
||||
async function main() {
|
||||
const result = await SAMLUserIdMigrationHandler.promises.removeNotMigrated(
|
||||
institutionId
|
||||
)
|
||||
|
||||
if (emitUsers) {
|
||||
console.log(
|
||||
`\nRemoved: ${result.success}\nFailed to remove: ${result.failed}`
|
||||
)
|
||||
}
|
||||
|
||||
console.log(
|
||||
`\nRemoved: ${result.success.length}\nFailed to remove: ${result.failed.length}`
|
||||
)
|
||||
|
||||
process.exit()
|
||||
}
|
||||
Reference in New Issue
Block a user