Ask Your Question
0

How can one utilize an Auth0 JWT Token for authentication with CouchDB, even if the username contains a unique character?

asked 2023-02-15 11:00:00 +0000

qstack gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-08-19 10:00:00 +0000

scrum gravatar image

To utilize an Auth0 JWT Token for authentication with CouchDB, you can follow these steps:

  1. Create an Auth0 application with the required scopes, such as openid, profile, and email.

  2. Generate an access token from Auth0, which contains the required fields, such as sub (user ID), name, email, and exp (expiration time).

  3. Create a user account in CouchDB with the same sub field value as in the JWT token.

  4. Create a new security _doc in the _users database, with the following content:

{
  "_id": "org.couchdb.user:<username>",
  "name": "<username>",
  "type": "user",
  "roles": [],
  "password_scheme": "bcrypt",
  "password": "<bcrypt hash of your choosing>",
  "derived_key": "<derived key based on your choosing>",
  "salt": "<salt for your choosing>",
  "iterations": 10,
  "iterations": "<algorithm name>"
}

Note: Base64 encode the derived_key, salt and password before placing into the JSON.

  1. Add the role of the user to the roles field of the _users security _doc.

  2. Create a new database in CouchDB, which will be secured by the created user account.

  3. Set the security permission for the database, such as "member":["org.couchdb.user:<username>"].

  4. Use the Authorization header of the HTTP request to authenticate the user with CouchDB, using the Bearer token of the generated Auth0 access token.

If the username contains a unique character such as "@" or ".", you may need to encode it using the percent-encoding method before placing it into _doc. For example, john.doe@example.com should be encoded as john.doe%40example.com.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-02-15 11:00:00 +0000

Seen: 10 times

Last updated: Aug 19 '21