Prevent "403 Forbidden" with JWT auth #4009
-
Hello ! I am trying to secure my couchdb with a JWT Token. I succefully accessed the Database with the Token and it responds with:
The Problem is when I want to access a specific Database I am recieving
The problem is I want to get docs from my Database without user-password authentication. Is the JWT authentication missing the feature of accessing databases without basic auth or am I doing something wrong? |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 1 reply
-
Hi, do you have an example token for testing? |
Beta Was this translation helpful? Give feedback.
-
Yes, sorry for the late reply... The Full Token: eyJhbGciOiJSUzI1NiIsImtpZCI6IjVCMzVDOTA2RjFEODMwNUQ4QUNFN0E2NjVDNDFDMjE5IiwidHlwIjoiSldUIn0.eyJuYmYiOjE2NTIxMDk4NjQsImV4cCI6MTY1MjExMzQ2NCwiaXNzIjoiaHR0cHM6Ly9sb2NhbGhvc3Q6NTA1MC9zZXJpY3ktc2VjdXJpdHktYXBpIiwiY2xpZW50X2lkIjoiY2xpZW50LXRlc3QtdWkiLCJzdWIiOiI1MjEyNDA3NC0wNDkzLTQ1MzQtODc0MS0xZmQzMGVlNzU3OTQiLCJhdXRoX3RpbWUiOjE2NTIxMDk4NjIsImlkcCI6ImxvY2FsIiwiaHR0cDovL3NjaGVtYXMueG1sc29hcC5vcmcvd3MvMjAwNS8wNS9pZGVudGl0eS9jbGFpbXMvZW1haWxhZGRyZXNzIjoidGVzdHVzZXJAZ21haWwuY29tIiwiQXNwTmV0LklkZW50aXR5LlNlY3VyaXR5U3RhbXAiOiJSSFJZRkQzUUY0WldHNDdWUFg0VVA3UzdEVU41TE1FUiIsInJvbGUiOiJTeXN0ZW0gQWRtaW4iLCJwcmVmZXJyZWRfdXNlcm5hbWUiOiJ0ZXN0dXNlciIsIm5hbWUiOiJ0ZXN0dXNlciIsImVtYWlsIjoidGVzdHVzZXJAZ21haWwuY29tIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsImZ1bGxOYW1lIjoidGVzdHVzZXIiLCJmb3JjZVBhc3N3b3JkQ2hhbmdlIjoiRmFsc2UiLCJleHRlcm5hbFVzZXIiOiJmYWxzZSIsImRlcGFydG1lbnQiOiJ0ZXN0dXNlciIsImxvY2FsZSI6ImVuIiwic2lkIjoiOUZBMzUyN0M3NENFNkIxQUM3NDZGN0FCRjYyOTJEMzUiLCJpYXQiOjE2NTIxMDk4NjQsInNjb3BlIjpbIm9wZW5pZCIsInByb2ZpbGUiLCJvZmZsaW5lX2FjY2VzcyJdLCJhbXIiOlsicHdkIl19.ZQbgBJRwvI6gyGGHPtlKE16vaeeJ-vu0YKQIHxu5PI4px1-n_J_QfvWzUEPqV8xNlb87ciQFa_3GjRxHIQqp8S0mtrVvA_YfDNfZTNbng3xqdJEagS5Wcp3s4qr3xmdtqUpxY_vrmgsp2BbKdQyY814nGLG8p2Tbj8hi-omJQQ78PgS4NPpPIm3lSh54fQ6F6BQ163_n_n8gI-vCNKyOUNdUlRDVrcKnTW0C4b6DZh7vZLx6dHP2O8DglfRS0d0rcg9zHafXOEin8QQBH3z22iS3yqYMxsMoJCIVIpmgY9frkk6jtyzuxVyW3LWGCbBHwZ4a_besuW0nUJFgfFk1tA The public key in JWK Format: { |
Beta Was this translation helpful? Give feedback.
-
And your user ("52124074-0493-4534-8741-1fd30ee75794") has access to both dbs? Can you paste your permissions for your db (for which the token is working) and for your db (for which the token is failing)? |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Can you please paste your jwt_key in a code block here? |
Beta Was this translation helpful? Give feedback.
-
Okay, tried your key, works for me, but you need to add the user of the key or some roles to the db security objects to allow them to access! Test it with: Adding the user (52124074-0493-4534-8741-1fd30ee75794) as a member of that db (user or admin). Do this with your admin user.
Then you should query your db with your JWT Bearer Token:
|
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Hi, this was only an example. "_admin" (special server admin role) was the default for my db. You can also create your own role in the payload like: ...
"sub": "52124074-0493-4534-8741-1fd30ee75794",
"_couchdb.roles": ["my_new_role"],
... and add that role to the member list:
That's your decision if this user is an admin or a normal user for this db (same with roles)... |
Beta Was this translation helpful? Give feedback.
Okay, tried your key, works for me, but you need to add the user of the key or some roles to the db security objects to allow them to access!
Test it with:
Adding the user (52124074-0493-4534-8741-1fd30ee75794) as a member of that db (user or admin). Do this with your admin user.
Then you should query your db with your JWT Bearer Token: