azure-cosmos-db-emulator-docker icon indicating copy to clipboard operation
azure-cosmos-db-emulator-docker copied to clipboard

Linux emulator does not validate key

Open jgbradley1 opened this issue 11 months ago • 3 comments

Describe the bug The linux emulator does not error out when the wrong key is used. Is this the expected behavior?

To Reproduce Steps to reproduce the behavior:

  1. Start the emulator
docker run -d -p 8081:8081 -p 1234:1234 mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:vnext-preview
  1. Run the following python sample code
from azure.cosmos import CosmosClient

endpoint = "http://localhost:8081"
key = "testpassword"
client = CosmosClient(endpoint, key)
for db in client.list_databases():
    print(db)

I expected the code to not work but it connects successfully and I can perform operations like creating new databases.

Desktop (please complete the following information):

  • OS: MacOS
  • Browser: Edge
  • SDK version: vnext-preview
  • SDK language: Python

jgbradley1 avatar Dec 15 '24 01:12 jgbradley1

@jgbradley1 Yes, we don't validate the key and allow access to the data - so it works as expected.

That said we are exploring adding authentication to the emulator but will need some more information on the use cases, e.g. should we just do optional key-based (e.g. you specify the key in some environment variable), or would we need to do some EntraId simulation. or something else?

xgerman avatar Dec 16 '24 19:12 xgerman

For emulator purposes only, is it a heavy lift to compare the provided key against the hardcoded key that the emulator expects? As an external user, the main use case I'm thinking about is users who want to perform some follow-on actions when an invalid key has been used. Currently, there's no way for someone to test these type of actions since the emulator will accept all keys.

jgbradley1 avatar Dec 19 '24 20:12 jgbradley1

Thanks for sharing. We will schedule work on this in the new year.

xgerman avatar Dec 19 '24 22:12 xgerman