vesper-framework / vesper

Vesper is a NodeJS framework that helps you to create scalable, maintainable, extensible, declarative and fast GraphQL-based server applications.
http://vesper-framework.com
600 stars 35 forks source link

Any Example for Basic Authentication #48

Open Erickud opened 6 years ago

Erickud commented 6 years ago

Hello,

I search a Example how we can setup the request authorization. I think that is in authorizationChecker, but if I thow HttpQueryError that generate a error in output that doesn't send the error code and header. I have extend the class HttpQueryError to setup default value.

class AuthenticationError extends HttpQueryError {

   constructor(
      statusCode?: number,
      message?: string,
      isGraphQLError: boolean = false,
      headers?: { [key: string]: string }
   ) {
      super(statusCode||401, message||"Access denied", isGraphQLError, headers || {
         'WWW-Authenticate': 'Basic realm="Test Eri"'
      });
   }
}

Regards.