Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Authenticate users before websocket connection establishes #558

Open
HASSANDL opened this issue Jan 13, 2021 · 2 comments
Open

Authenticate users before websocket connection establishes #558

HASSANDL opened this issue Jan 13, 2021 · 2 comments

Comments

@HASSANDL
Copy link

HASSANDL commented Jan 13, 2021

How only allow authenticated users to establish a successful websocket connection?
in client side use laravel-echo

{
  "authHost": "http://localhost",
  "authEndpoint": "/broadcasting/auth",
  "clients": [
    {
      "appId": "620bafdba22974a2",
      "key": "e860c5fc92f4a20e7175754eb030e737"
    }
  ],
  "database": "redis",
  "databaseConfig": {
    "redis": {
      "host": "localhost",
      "port": 6379
    },
    "sqlite": {
      "databasePath": "/database/laravel-echo-server.sqlite"
    }
  },
  "devMode": true,
  "host": null,
  "port": 7000,
  "protocol": "http",
  "socketio": {
    "pingTimeout": 5000,
    "pingInterval": 2000000
  },
  "secureOptions": 67108864,
  "sslCertPath": "",
  "sslKeyPath": "",
  "sslCertChainPath": "",
  "sslPassphrase": "",
  "subscribers": {
    "http": false,
    "redis": true
  },
  "apiOriginAllow": {
    "allowCors": false,
    "allowOrigin": "",
    "allowMethods": "",
    "allowHeaders": ""
  }
}

@HASSANDL HASSANDL changed the title How disallow client without app id & client id Authenticate users before websocket connection establishes Jan 13, 2021
@iooe
Copy link

iooe commented Feb 20, 2021

<meta name="user" content="{{Auth::user()}}">
`

    const user = document.querySelector('meta[name="user"]').getAttribute('content')

    if (user !== null) {

        this.echoInstance = new Echo({
          ...
        });

    }`

@N3XT0R
Copy link

N3XT0R commented Apr 20, 2021

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants