SoftInstigate / restheart-website

restheart.org main website
https://restheart.org
5 stars 25 forks source link

Password auth/ Creating new database. #8

Closed MeerimMusa closed 5 years ago

MeerimMusa commented 5 years ago

Hello,

I have set up Docker and RESTheart is running, my local HAB browser works fine. When I create a new Database using this command with a different username and password it is not creating. http -a 'admin:changeit' PUT localhost:8080/db desc='this is my first db created with restheart'

I have configured security.yml file.

What I am missing? Can you help, please?

ujibang commented 5 years ago

This issue should be created in RESTHeart repository (this repo is for restheart website)

also please provide more information following the issue template.

MeerimMusa commented 5 years ago

HI @ujibang ,

Thanks for the responding back.

So I have created my RestHeart is running ok, I can logging to my http://localhost:8080/browser/ with default credentials admin: changeit

So how I can change the default credentials? I have already configured security.yml

Configuration for file based Identity Manager

users:

Am I right?

And now I am trying to access http://localhost:8080/browser/ with the credentials that I have put in the security.yml and access is still default.

And I can't create new database with this command http -a 'admin:secret' PUT localhost:8080/db desc='this is my first db created with restheart'

The error is HTTP/1.1 401 Unauthorized

How can I configure my browser to make accessible with my own secret password? And create the database there?

Thanks, Meerim

ujibang commented 5 years ago

Your user conf seems fine, so your restheart is not probably peeking the security.yml file where you defined it.

What is the path of your security.yml? Is it correctly set in restheart.yml?

Isn't it that you are running RH with docker without having mounted your local etc file?

MeerimMusa commented 5 years ago

I have created under roo /restheart/etc and security.yml is placed there as well as restheart.yml. resteart.yml I have changes only the URI part: mongo-uri: {{{ mongodb://username:password@mongodb }}}

Yes, I am running docker, and I think I did not mount yet. So do I need to mount my /restheart/etc ?

ujibang commented 5 years ago

Yes! If you run it with docker the conf files are inside the container and you need to override with your local ones. Uncomment in docker-compose.yml the following lines:

      ### Uncoment below if you want to mount a local configuration folder
      ### to overwrite default restheart.yml and/or security.yml
      #volumes:
      #   - ./etc:/opt/restheart/etc:ro
MeerimMusa commented 5 years ago

Yes, that part is done. But still the same 401 Unauthorized.

mkjsix commented 5 years ago

@MeerimMusa we presume here you are running RESTHeart with docker-compose.

Please don't confuse the content of the ./etc folder with the ./Docker/etc one, if you are running with docker-compose only the second matters. I suspect you were instead editing the first one.

If you want to overwrite the default configuration files, you need to tell docker-compose where your files actually are in your host's filesystem. In the following case we assume you are modifying the default security.yml file under ./Docker/etc folder, so edit the docker-compose.yml file this way:

      ### Uncoment below if you want to mount a local configuration folder
      ### to overwrite default restheart.yml and/or security.yml
      volumes:
         - ./Docker/etc:/opt/restheart/etc:ro

Note that you must restart the docker container after you edit any file.

$ docker-compose stop
$ docker-compose up -d

If you nee to run RESTHeart in a different folder, you need to copy docker-compose.yml and the content of Docker/etc folder somewhere else. For example, let's say you want to put RESTHeart's configuration files in folder /Users/user1/restheart then you just need to copy all the Docker/etc files and docker-compose.yml into /Users/user1/restheart, then edit the /Users/user1/restheart/security.yml then modify the copy of docker-compose.yml file this way:

      ### Uncoment below if you want to mount a local configuration folder
      ### to overwrite default restheart.yml and/or security.yml
      volumes:
         - /Users/user1/restheart:/opt/restheart/etc:ro

Note that in the first example we where providing a relative source path ./Docker/etc, while in the second case an absolute path /Users/user1/restheart.

Of course, if you need to edit only the security.yml file, you can mount only that single one as an external volume, so the first example would become:

      ### Uncoment below if you want to mount a local configuration folder
      ### to overwrite default restheart.yml and/or security.yml
      volumes:
         - ./Docker/etc/security.yml:/opt/restheart/etc/security.yml:ro
MeerimMusa commented 5 years ago

I have changed configuration file docker-compose.yml, then after running Note that you must restart the docker container after you edit any file.

$ docker-compose stop $ docker-compose up -d

The result is

Starting restheart-mongo ... done Recreating restheart ... done

It's recreating restheart not restarting. So my local HAB browser not working at all. can you please help?

mkjsix commented 5 years ago

You need to provide us with your docker logs and RESTHeart configuration files, otherwise we can't guess what's wrong.