I'm looking for a best way to add collections of attributes to Application
Users. Is it possible to add arbitrary attributes directly to a User entity?
For example, could I add a list of email aliases and a map of external
credentials as follows?
{
"uuid" : "5bf1047a-84b0-11e4-9e6d-db5a12633089",
"type" : "user",
"created" : 1418685371959,
"modified" : 1418685371959,
"username" : "First.User",
"email" : "[email protected] <mailto:[email protected]>",
"activated" : true,
"picture" :
"http://www.gravatar.com/avatar/b1d53d35ca78936063277655c1eafe47
<http://www.gravatar.com/avatar/b1d53d35ca78936063277655c1eafe47>",
"emailAliases" : [ "[email protected] <mailto:[email protected]>",
"[email protected] <mailto:[email protected]>" ],
"externalCredentials" : {
"username" : "joeuser",
"password" :
"$2a$10$zh0zBoA0rqm5OPcSbGPYP.gJ20K.d9W128hkmQBD4VfFlO5cNECdO",
"encrption" : "BCRYPT"
},
"metadata" : {
"path" : "/users/5bf1047a-84b0-11e4-9e6d-db5a12633089",
"sets" : {
"rolenames" : "/users/5bf1047a-84b0-11e4-9e6d-db5a12633089/roles",
"permissions" :
"/users/5bf1047a-84b0-11e4-9e6d-db5a12633089/permissions"
},
"collections" : {
"activities" :
"/users/5bf1047a-84b0-11e4-9e6d-db5a12633089/activities",
"devices" : "/users/5bf1047a-84b0-11e4-9e6d-db5a12633089/devices",
"feed" : "/users/5bf1047a-84b0-11e4-9e6d-db5a12633089/feed",
"groups" : "/users/5bf1047a-84b0-11e4-9e6d-db5a12633089/groups",
"roles" : "/users/5bf1047a-84b0-11e4-9e6d-db5a12633089/roles",
"following" :
"/users/5bf1047a-84b0-11e4-9e6d-db5a12633089/following",
"followers" :
"/users/5bf1047a-84b0-11e4-9e6d-db5a12633089/followers"
}
}
}
Would it then be possible to access the list of aliases directly for
retrieval/update without having to retrieve/update/replace the entire user
entity?
Would these new attributes be indexed, so I could search for a user with an
email alias matching "juser*"?
Of course, this all falls apart if I can't add the attributes directly to a
User. I'd then consider creating a new collection of "UserFacets" that would
be linked to the owning User by some combination of user ID and facet type
name, as follows:
/org/app/Facets
{
"name" : "5bf1047a-84b0-11e4-9e6d-db5a12633089:emailAliases",
"aliases" : [ "[email protected] <mailto:[email protected]>",
"[email protected] <mailto:[email protected]>" ]
}
{
"name" : "5bf1047a-84b0-11e4-9e6d-db5a12633089:externalCredentials"",
"credentials" : {
"username" : "joeuser",
"password" :
"$2a$10$zh0zBoA0rqm5OPcSbGPYP.gJ20K.d9W128hkmQBD4VfFlO5cNECdO",
"encrption" : "BCRYPT"
}
}
Would this actually be the preferred way of doing it?
Paul