rediseen icon indicating copy to clipboard operation
rediseen copied to clipboard

not getting any keys while using a compose file

Open artynet opened this issue 3 years ago • 6 comments

when running the whole bundle :

version: '3.7'
services:
  rediseen:
    container_name: rediseen-test
    restart: always
    image: xddeng/rediseen:latest
    environment:
      - REDISEEN_REDIS_URI=redis://:@redis-volatile:6379
      - REDISEEN_DB_EXPOSED=0-5
      - REDISEEN_KEY_PATTERN_EXPOSED="^key:([0-9a-z]+)"
      - REDISEEN_HOST=0.0.0.0
    ports:
      - '8000:8000'
    networks:
      - 'default'

  redis-volatile:
    container_name: redis-volatile
    restart: always
    image: redis:6.2.1-buster
    environment:
      - REDIS_REPLICATION_MODE=master
    ports:
      - '6379:6379'
    networks:
      - 'default'

networks:
  default:
    name: rediseen-network

I am not able to get any key from the redisDB..any thoughts about that ?

$ curl -s http://localhost:8000/0 | jq 
{
  "count": 0,
  "total": 1,
  "keys": null
}
$ curl -s http://localhost:8000/0/0 | jq
{
  "error": "Key pattern is forbidden from access"
}

thanks in advance...

artynet avatar Mar 31 '21 16:03 artynet

Hi @artynet , thanks for giving Rediseen a try, and thanks for sharing your question :)

If I'm not wrong, the issue arose from the configuration REDISEEN_KEY_PATTERN_EXPOSED. The value you are using is the value I have put in the sample code, "^key:([0-9a-z]+)". It literally means only keys like key:1, key:a (keys with a prefix key:), etc., will be exposed and accessible. This is why the error you encountered was "Key pattern is forbidden from access".

This is a design for security purpose, so you have better control on what you want to expose and what you want to hide from the public.

What you can do:

  • If you are very sure you want to expose everything, you can add configuration REDISEEN_KEY_PATTERN_EXPOSE_ALL=true, and remove config REDISEEN_KEY_PATTERN_EXPOSED.
  • If you have a good idea about what are the keys you want to expose, try to summarise a regex for them and apply to REDISEEN_KEY_PATTERN_EXPOSED.

Full information about configuration can be found at https://github.com/XD-DENG/rediseen/blob/master/docs/documentation.md#configuration.

Pls give a try and let me know if it works. It will also be appreciated if you can share more feedbacks, and share Rediseen to your network if you find it useful :)

XD-DENG avatar Mar 31 '21 20:03 XD-DENG

Hello @XD-DENG , first of all thank you for your quick reply !

After you useful explanation I was able to figure out the actual issue. As a matter of fact, when using docker-compose, the double quotes prevent the rediseen container to detect the actual KEY_PATTERN. I forgot to mention that I also tried to repeat step after step your basic example launching (after the compose) :

docker exec -i redis-server redis-cli set key:0 100

then the curl request is denied as reported in my original post. I think that when writing a compose file the REDISEEN_KEY_PATTERN_EXPOSE has to be set without double quotes :

REDISEEN_KEY_PATTERN_EXPOSED=^key:([0-9a-z]+)

this way I can get my database entries as it should. Would you mind double check that ?

artynet avatar Apr 01 '21 08:04 artynet

Many thanks @artynet . Grande that you helped find out the root cause!

  • I confirm I can reproduce what you mentioned. Having double quotes for value of REDISEEN_KEY_PATTERN_EXPOSED causes issue in docker-compose context. Removing the double quotes fixes the issue.
  • This inspired me to check if we can remove double quotes for all other cases as well. However, for docker run case, we need to keep double quotes, otherwise I get error zsh: bad math expression: operator expected at `a-z' on Mac (zsh also raises other exceptions for the other special characters in regex in this case).

So to avoid confusion, I would like to keep the existing sample code as they are now.

Meanwhile, may I invite you to help add a docker-compose sample into the project? It can help avoid confusion for people who start with docker-compose. If you are interested, you can commit the docker-compose.yml you have + add a sub-section Quick Start with Docker Compose under https://github.com/XD-DENG/rediseen#quick-start , in which we can simply refer the yaml file added. It would be appreciated.

Thanks again!

XD-DENG avatar Apr 01 '21 09:04 XD-DENG

Hi @artynet , a gentle ping: would you be open to contribute a docker-compose example into the repo? :) Thx.

XD-DENG avatar Apr 06 '21 18:04 XD-DENG

Hello @XD-DENG, sorry for being late ! Of course I'd love to give my contribution to the project....my intention is to fork the project and add the compose file and the documentaion entries. I was really busy in my usual job tasks but I could reserve some time in the weekend to accomplish the commit ? Does it work for you ?

Please let me know at your convenience ;)

Kind Regards

artynet avatar Apr 15 '21 13:04 artynet

Many thanks @artynet . It would be great to have your contribution!

Please do take your time. I fully understand you are busy and may have limited time. Please help make the necessary change when it's convenient for you. Look forward to that :)

Thanks again!

XD-DENG avatar Apr 15 '21 18:04 XD-DENG