perfood / couch-auth

Powerful authentication for APIs and apps using CouchDB (or Cloudant) with Node >= 14
MIT License
66 stars 19 forks source link

Make username validation configurable or less restrictive #74

Open klues opened 1 year ago

klues commented 1 year ago

I've just migrated from superlogin to couch-auth, so first thanks for your work creating an up-to-date version of this framework!

Since the way usernames are stored and database names are chosen is differently in couch-auth (key value in user doc and <prefix><user-id> for database name), I think the validation of the username could be less restrictive:

So my proposal would be to just use a regex like /^[A-Za-z0-9_-]{2,50}$/ or to make it configurable.

fynnlyte commented 11 months ago

Glad if you're using it!

Yeah, the 16 char limitation most likely comes from an early version of CouchDB and superlogin where the username was identical to the database name. Making it configurable via config.ts + providing the current regex as default sounds reasonable to me.

I think I'll implemented that myself + clean up something else in the key - logic.