dgraph icon indicating copy to clipboard operation
dgraph copied to clipboard

Data types in Dgraph: Add a password type

Open manishrjain opened this issue 9 years ago • 3 comments

So, any string corresponding to this type would be salted and stored encrypted (bcrypt library might be a good choice, but needs investigation). This would be useful to store passwords in Dgraph.

We'll also need corresponding functions to check if the password specified is correct or not; without retrieving the encrypted password. Also, we shouldn't allow retrieving of this predicate by query. It should only be done via backup.

manishrjain avatar Jan 08 '17 06:01 manishrjain

Is this improvement intended to be used by an application (customers) or by administrators and developers? If it's the latter, API keys would make more sense.

gpsamson avatar Jan 08 '17 07:01 gpsamson

This is just for storage; so one could potentially do user authentication via Dgraph. This isn't really about client authentication with Dgraph itself. Agreed that the latter could be handled via API keys.

manishrjain avatar Jan 12 '17 02:01 manishrjain

List some use cases:

  1. user set password
  • if not the first time then he should provide previous password as well: => left for user dev to deal with previous verify or, => Dgraph provide one api to do both verify-and-set ? Prefer: what if user indeed forgot his password, then no previous password could be provided. We should just provide 2 separate function: password-set() & password-verification(), left user to deal with previous verification

  • what syntax should it take ? => via the normal form like "user password i-m-password", then inner component take special treatment on predicate 'password' => via special form like "user password i-m-password password@label", then inner component take special treatment on label-password => no rdf syntax permitted, only by function password-set(), since this is a op belongs to 'Mutation', not feasible

  1. password verification
  • what syntax should it take ? => via filter-eq, user(allof(user-name, "admin")) @filter(eq("password", "i-m-password")) {} => special function, user(id:"admin") { password-verify("user", "i-m-password') }
  1. user query
  • how to stop him/her from querying password directly ? => create one additional tag, e.g. "hidden from user", attach it to password attribute
  1. other issue
  • many pairs possible, (userId, password), (user-email, password), (user-phone, password), how we relate one another ? => indexing, { userId: nickname, email, phone, password + salt }

squalfof avatar Feb 06 '17 07:02 squalfof