nestjs / nest

A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript 🚀
https://nestjs.com
MIT License
67.69k stars 7.63k forks source link

WebSocket authentication #924

Closed krivochenko closed 6 years ago

krivochenko commented 6 years ago

I'm submitting a...


[ ] Regression 
[ ] Bug report
[ ] Feature request
[x] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

I try to send auth-token as a get param of url of gateway. I write a guard:

import { Injectable, CanActivate, ExecutionContext } from '@nestjs/common';

@Injectable()
export class EventsGuard implements CanActivate {
  canActivate(context: ExecutionContext): boolean  {
    const request = context.switchToHttp().getRequest();
    console.log(request);
    return false;
  }
}

but I have not idea how I can get url params inside canActivate method.

Expected behavior

Documentation required.

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Environment


Nest version: 5.1.0 
For Tooling issues:
- Node version: 10.1.0 
- Platform:  Windows

Others:

Thanks for advance!

kamilmysliwiec commented 6 years ago

Please, report this issue in the documentation repository.

lock[bot] commented 5 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.