greatbit / quack

Web Based Test Management System
Apache License 2.0
116 stars 34 forks source link

Quack creates db & users with localhost NOT using IP Address #240

Open bobbeck55 opened 1 year ago

bobbeck55 commented 1 year ago

Describe the bug When I point my browser to "locahost:80" I can login to quack and create db and users BUT if I point my browser to the ipaddr:80 I can't. Quack attempts to login but gets "kicked out" by something. This happens when my browser is internal to my VM and when it is run on my host machine.

Also - I would like to persist the db and users I create. How? I have attached the quack startup log, docker-compose.yml, and quack.properties files.

azee commented 1 year ago

@bobbeck55 , you don't need to add port 80 explicitly in the url - your browser (or CURL) will use 80 as a default value.

auth.domain property - https://github.com/greatbit/quack/blob/master/api/src/main/resources/quack.properties#L17 - in your local config file should match the domain exactly.

In your case it will be auth.domain= ipaddr

QuAck will work with one domain ONLY. It will be either your ip addres (or a DNS domain/CNAME), or Localhost. You can't use both at the same time.

When QuAck is trying to authenticate a user, it gets a session id cookie from the request. Cookies are tightly coupled with domains. QuAck searches for cookies related to domain specified in the "auth.domain" property. Which means there might be only one domain for the service.

azee commented 1 year ago

Could you please share your quack.properties (you can omit private data such as service paths and credentials), command you are using to run the app and docker-compose.yaml if you are using docker compose.

In that case I'll be able to identify what is not working faster.

azee commented 1 year ago

Please feel free to contact me directly via e-mail - info@greatbit.com.au I'll provide my whatsapp/telegram/skype/discord contacts to speed things up

bobbeck55 commented 1 year ago

cmd: docker-compose -f docker-compose.yml up

version: '2' services: quack: image: greatbit/quack ports:

volumes: quack: driver: local

Database

mongo.replicaSet=mongod:27017 mongo.dbname=test mongo.username= mongo.password= mongo.uri=

Authentication

whoru.auth.provider=ru.greatbit.whoru.auth.providers.StubAuthProvider whoru.session.provider=ru.greatbit.whoru.auth.providers.HazelcastSessionProvider stub.login=someuser stub.password=somepassword auth.domain=192.168.56.102 auth.session.ttl=6000000 auth.admin.login=root auth.admin.password=rootpass auth.admin.token=abc auth.admin.logins=azee,zyxel560k@mail.ru

Hazelcast

entity.lock.ttl.min=5 hazelcast.group.name=dev hazelcast.group.password=dev-pass hazelcast.ttl.sec=1209600 hazelcast.port=5903 hazelcast.port.rest=5904 hazelcast.port.auto.increment=true hazelcast.members=127.0.0.1 hazelcast.interface=127.0.0.1 hazelcast.backup.count=1 hazelcast.prefer.ipv4.stack=true hazelcast.aws.enabled=false hazelcast.tcpip.enabled=true storage.provider=com.testquack.storage.MongoStorage quack.tracker=com.testquack.tracker.DummyTracker aws.cognito.access.key=CHANGEME aws.cognito.secret.key=CHANGEME aws.cognito.region=us-east-1 aws.cognito.oauth.endpoint= aws.cognito.client.id=CHANGEME aws.cognito.redirect.url= cognito-auth-provider= cognito.login.url=

azee commented 1 year ago
  1. Try changing whoru.auth.provider=ru.greatbit.whoru.auth.providers.StubAuthProvider to whoru.auth.provider=com.testquack.api.security.DbAuthProvider

StubAuthProvider was created for testing and local development purposes and it just allows to authenticate an admin from config

  1. According to the config - you should be able to login when accessing quack using http://192.168.56.102 (no port needed)
  2. If that doesn't work - please check your volume mapping is correct if your local config is located here: /home/bob/quack_db/quack.properties then your volume mapping in docker compose should be like volumes:
    • ~/home/bob/quack_db:/etc/quack

It seems that you are using default config. Thats why you can only access it via localhost as it is a default auth domain. Correct volume mapping should fix it.

bobbeck55 commented 1 year ago

Azee, I can login as root and create user bob with your change. When I logout and attempt to login as user bob I get this error.

[image: image.png]

The log says "User session not found and will be prompt to authorize.

Bob

On Wed, Feb 22, 2023 at 8:54 AM Azee @.***> wrote:

  1. Try changing whoru.auth.provider=ru.greatbit.whoru.auth.providers.StubAuthProvider to

— Reply to this email directly, view it on GitHub https://github.com/greatbit/quack/issues/240#issuecomment-1440055383, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZWTTVROXUOGJLGHDLSVAO3WYYLDFANCNFSM6AAAAAAVDOSI64 . You are receiving this because you were mentioned.Message ID: @.***>

azee commented 1 year ago

@bobbeck55 Lats try narrowing down the problem Try setting whoru.session.provider=ru.greatbit.whoru.auth.providers.InmemSessionProvider instead of HazelcastProvider