parameters:
    oro_sync.security.ticket_authentication_provider.key: 'oro_sync_ticket'
    oro_sync.security.ticket_authentication_provider.ticket_ttl: 300

services:
    oro_sync.security.ticket_authentication_provider:
        class: Oro\Bundle\SyncBundle\Security\TicketAuthenticationProvider
        arguments:
            - '@oro_sync.authentication.ticket_digest_generator'
            - '@oro_user.security.provider'
            - '%oro_sync.security.ticket_authentication_provider.key%'
            - '%kernel.secret%'
            - '%oro_sync.security.ticket_authentication_provider.ticket_ttl%'

    oro_sync.authentication.websocket_authentication_by_ticket_provider:
        class: Oro\Bundle\SyncBundle\Authentication\Provider\WebsocketAuthenticationByTicketProvider
        arguments:
            - '@oro_sync.security.ticket_authentication_provider'
            - '%oro_sync.security.ticket_authentication_provider.key%'

    oro_sync.event_listener.client:
        class: Oro\Bundle\SyncBundle\EventListener\ClientEventListener
        arguments:
            - '@oro_sync.authentication.websocket_authentication_by_ticket_provider'
            - '@gos_web_socket.client.storage'
        calls:
            - [ setLogger, [ '@logger' ] ]
        tags:
            - { name: monolog.logger, channel: oro_websocket }
            # Must be called before gos_web_socket.event_listener.client::onClientConnect
            - { name: kernel.event_listener, event: 'gos_web_socket.client_connected', method: onClientConnect, priority: 100 }
            # Must be called before gos_web_socket.event_listener.client::onClientError
            - { name: kernel.event_listener, event: 'gos_web_socket.client_error', method: onClientError, priority: 100 }

    oro_sync.authentication.encoder:
        class: Symfony\Component\Security\Core\Encoder\MessageDigestPasswordEncoder
        arguments:
            - 'sha512'
            - true
            - 5000

    oro_sync.authentication.ticket_digest_generator:
        class: Oro\Bundle\SyncBundle\Authentication\Ticket\TicketDigestGenerator\TicketDigestGenerator
        arguments:
            - '@oro_sync.authentication.encoder'
            - '%kernel.secret%'

    oro_sync.authentication.ticket_provider:
        class: Oro\Bundle\SyncBundle\Authentication\Ticket\TicketProvider
        arguments:
            - '@oro_sync.authentication.ticket_digest_generator'
            - '%kernel.secret%'

    Oro\Bundle\SyncBundle\Authentication\Ticket\TicketProvider:
        alias: oro_sync.authentication.ticket_provider
