voryx / ThruwayBundle

Bundle for building Real-time Apps in Symfony
98 stars 47 forks source link

Problem configuring ThruwayBundle with FosUser #88

Open Webonaute opened 6 years ago

Webonaute commented 6 years ago

I need a little help. It make 2 night I try to figure out what am I doing wrong.

For the the purpose of the test, I open 2 commands line. Than I runbin/console thruway:router:start -vvv to start the server. Than when I try to run the worker, with bin/console thruway:worker:start -vvv "default" I got error message wamp.error.not_authorized.

Look like internal client is running anonymous user.

So here is my config: php7.2 symfony 4.0 ThruwayBundle dev-master

config/packages/security.yaml

security:

    encoders:
        FOS\UserBundle\Model\UserInterface:
            algorithm:            pbkdf2
            hash_algorithm:       sha256
            encode_as_base64:     true
            iterations:           1000
            key_length:           32

    role_hierarchy:
        ROLE_ADMIN:       ROLE_USER
        ROLE_SUPER_ADMIN: ROLE_ADMIN

    providers:
        fos_userbundle:
            id: fos_user.user_provider.username_email

    firewalls:
        thruway:
            security: false

        dev:
            pattern: ^/(_(profiler|wdt|error)|css|images|js)/
            security: false

        main:
            pattern: ^/
            form_login:
                provider: fos_userbundle
                csrf_token_generator: security.csrf.token_manager
            logout:       true
            anonymous:    true

config/packages/voryx_thruway.yaml

voryx_thruway:
    realm: 'realm1'
    url: '%env(VORYX_THRUWAY_URL)%' #The url that the clients will use to connect to the router
    router:
        ip: '%env(VORYX_THRUWAY_ROUTER_IP)%'  # the ip that the router should start on
        port: '%env(VORYX_THRUWAY_ROUTER_PORT)%'  # public facing port.  If authentication is enabled, this port will be protected
        trusted_port: '%env(VORYX_THRUWAY_ROUTER_TRUSTED_PORT)%' # Bypasses all authentication.  Use this for trusted clients.
        authentication: true
    user_provider: 'fos_user.user_provider.username_email'
    enable_logging: true

config/packages/fos_user.yaml

fos_user:
    db_driver: orm
    firewall_name: main
    user_class: App\Entity\User
    from_email:
        address: "%env(APP_EMAIL_FROM)%"
        sender_name: "%env(APP_EMAIL_NAME)%"

config/services.yaml

    wamp_cra_auth:
        class: Thruway\Authentication\WampCraAuthProvider
        parent: voryx.thruway.wamp.cra.auth.client
        autowire: false
        autoconfigure: false
        public: true
        tags:
            - { name: thruway.internal_client }
Webonaute commented 6 years ago

I finally find my problem. thank to this article: http://voryx.net/integrating-symfony-authentication-for-thruwaybundle/

Webonaute commented 6 years ago

hum nvm external connection can connect using jwt token but but internal still get connection refused.