Skip to content

Add JWT authentication to a LB4 Socket App #4437

Closed

Description

@baltameme

I have built a simple chat based on the example shared in the following repo:
https://github.com/raymondfeng/loopback4-example-websocket/

What i am trying to do now is closing the connection over this App so it can be allowed through specific authenticated users. I want to enquire how can i integrate the JWT authentication as part of the socket app life cycle.

Activity

  1. dougal83 commented on Jan 15, 2020

    @dougal83
    Contributor

    Hey @baltameme

    You might want to pose your question on https://stackoverflow.com/ with tags loopback and websocket.

  2. raymondfeng commented on Jan 15, 2020

    @raymondfeng
    Contributor
  3. baltameme commented on Jan 16, 2020

    @baltameme
    Author

    Hey @raymondfeng, yeah i've noticed that you're using websocket.controller.ts for exposing the socket connections. However, i want to enquire if its possible to following coding strategy in the following reference, where i can just append the (authenticate) decorator as the following:

    @ws.connect()
    @authenticate('jwt')
    connect(socket: Socket) {
    console.log('Client connected: %s', this.socket.id);
    socket.join('room 1');
    }

  4. stale commented on Dec 25, 2020

    @stale

    This issue has been marked stale because it has not seen activity within six months. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS file at the top-level of this repository. This issue will be closed within 30 days of being stale.

  5. locked and limited conversation to collaborators on Mar 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions