CoreID/app/classes/saml/FlitterProfileMapper.js

62 lines
2.1 KiB
JavaScript
Raw Permalink Normal View History

2020-05-04 01:16:54 +00:00
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
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 }
}
}
module.exports = exports = FlitterProfileMapper