You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
CoreID/app/classes/saml/FlitterProfileMapper.js

62 lines
2.2 KiB

class FlitterProfileMapper {
map = {
nameIdentifier: 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier',
email: 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress',
name: 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name',
givenname: 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname',
surname: 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname',
upn: 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn',
groups: 'http://schemas.xmlsoap.org/claims/Group'
}
metadata = [ {
id: "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress",
optional: true,
displayName: 'E-Mail Address',
description: 'The e-mail address of the user'
}, {
id: "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname",
optional: true,
displayName: 'Given Name',
description: 'The given name of the user'
}, {
id: "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name",
optional: true,
displayName: 'Name',
description: 'The unique name of the user'
}, {
id: "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname",
optional: true,
displayName: 'Surname',
description: 'The surname of the user'
}, {
id: "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier",
optional: true,
displayName: 'Name ID',
description: 'The SAML name identifier of the user'
}]
constructor(user) {
this.user = user
}
getClaims() {
const claims = {}
claims[this.map.nameIdentifier] = this.user.uid.toLowerCase()
claims[this.map.email] = this.user.email
claims[this.map.name] = `${this.user.first_name} ${this.user.last_name}`
claims[this.map.givenname] = this.user.first_name
claims[this.map.surname] = this.user.last_name
// TODO groups
return claims
}
getNameIdentifier() {
return { nameIdentifier: this.user.uid.toLowerCase() }
}
}
module.exports = exports = FlitterProfileMapper