I am trying to authenticate against active directory using passport-ldapauth in a Nestjs app. I don't have a service account and want to bind to Active Directory using a username as DN. I am trying to use the Asynchronous configuration retrieval but running into a problem when calling super() in the strategy class's constructor.
I get the following error:
src/ldap.strategy.ts:12:9 - error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
12 super(this.getLdapConfig,
Any idea how I can make this work in a Nestjs app by extending the strategy interface/passing dynamic config method when calling super()?
my code:
import * as Strategy from 'passport-ldapauth';
import { PassportStrategy } from '@nestjs/passport';
import { Injectable, UnauthorizedException } from '@nestjs/common';
import { Request } from 'express';
import { readFileSync } from 'fs';
import { callbackify } from 'util';
}If you know how to fix the issue, make a pull request instead.
[x] I have a question that is inappropriate for StackOverflow. (Please ask any appropriate questions, such as how to use the library, there).
[x] I believe this is an issue in this library and not in the underlying libraries ldapjs or ldapauth-fork. (This library is a passport strategy and does not implement the LDAP communication)
Note: if the issue template is not used, the issue will be closed.
I am trying to authenticate against active directory using passport-ldapauth in a Nestjs app. I don't have a service account and want to bind to Active Directory using a username as DN. I am trying to use the Asynchronous configuration retrieval but running into a problem when calling super() in the strategy class's constructor.
I get the following error:
src/ldap.strategy.ts:12:9 - error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. 12 super(this.getLdapConfig,
Any idea how I can make this work in a Nestjs app by extending the strategy interface/passing dynamic config method when calling super()?
my code:
import * as Strategy from 'passport-ldapauth'; import { PassportStrategy } from '@nestjs/passport'; import { Injectable, UnauthorizedException } from '@nestjs/common'; import { Request } from 'express'; import { readFileSync } from 'fs'; import { callbackify } from 'util';
@Injectable() export class LdapStrategy extends PassportStrategy(Strategy, 'ldap') { constructor( ) {
super(this.getLdapConfig, async (req: Request, user: any, done) => { console.log(req); req.user = user; return done(null, user); }); }
}If you know how to fix the issue, make a pull request instead.
Note: if the issue template is not used, the issue will be closed.
Problem Description
Steps to Reproduce