mirror of
https://github.com/overleaf/overleaf.git
synced 2025-02-05 03:44:47 +00:00
df6d0625f1
ukamf metadata processor cli GitOrigin-RevId: f823a1dca231546f3ab67c47f6443e56b50e30d1
45 lines
901 B
JavaScript
45 lines
901 B
JavaScript
'use strict'
|
|
|
|
const _ = require('lodash')
|
|
|
|
class UKAMFEntity {
|
|
constructor(data) {
|
|
this.data = data
|
|
}
|
|
|
|
getSamlConfig() {
|
|
const idp = this.data.IDPSSODescriptor[0]
|
|
const keys = idp.KeyDescriptor
|
|
const signingKey = keys.find(key => _.get(key, ['$', 'use']) === 'signing')
|
|
|
|
let cert = _.get(signingKey, [
|
|
'ds:KeyInfo',
|
|
0,
|
|
'ds:X509Data',
|
|
0,
|
|
'ds:X509Certificate',
|
|
0
|
|
])
|
|
if (!cert) {
|
|
throw new Error('no cert')
|
|
}
|
|
cert = cert.replace(/\s/g, '')
|
|
|
|
let entryPoint = idp.SingleSignOnService.find(
|
|
sso =>
|
|
_.get(sso, ['$', 'Binding']) ===
|
|
'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect'
|
|
)
|
|
entryPoint = _.get(entryPoint, ['$', 'Location'])
|
|
if (!entryPoint) {
|
|
throw new Error('no entryPoint')
|
|
}
|
|
|
|
return {
|
|
cert,
|
|
entryPoint
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = UKAMFEntity
|