metadata-processor.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. 'use strict'
  2. /**
  3. * Run with: node metadata-processor /path/ukamf.xml http://idp/entity/id
  4. *
  5. * The ukamf metadata xml file can be downloaded from:
  6. * http://metadata.ukfederation.org.uk/
  7. *
  8. * The entity id should be provided by the university.
  9. */
  10. const UKAMFDB = require('./ukamf-db')
  11. main().catch(err => {
  12. console.error(err.stack)
  13. })
  14. async function main() {
  15. const [, , file, entityId] = process.argv
  16. console.log(`loading file ${file}`)
  17. const ukamfDB = new UKAMFDB(file)
  18. await ukamfDB.init()
  19. const entity = ukamfDB.findByEntityID(entityId)
  20. if (!entity) {
  21. throw new Error(`could not find entity for ${entityId}`)
  22. }
  23. const samlConfig = entity.getSamlConfig()
  24. console.log(`UPDATE universities SET
  25. sso_entity_id = '${samlConfig.entityId}',
  26. sso_entry_point = '${samlConfig.entryPoint}',
  27. sso_cert = '${samlConfig.cert}',
  28. sso_user_id_attribute = 'eduPersonPrincipalName',
  29. sso_user_email_attribute = 'mail',
  30. sso_license_entitlement_attribute = 'eduPersonPrincipalName',
  31. sso_license_entitlement_matcher = '.'
  32. WHERE id =
  33. `)
  34. }