Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confused about diff between Authenticator and authenticate functions. #2

Open
CodisRedding opened this issue Nov 9, 2017 · 1 comment

Comments

@CodisRedding
Copy link

Can you help me understand why I need to pass creds to both Authenticator's constructor and the authenticate functions?

const authenticator = new Authenticator({
    url: 'ldap://127.0.0.1:1389',
    baseDN: 'dc=domain,dc=com',
    // ******************************
    // HERE
    // ******************************
    username: 'auth@domain.com',
    password: 'password',
    logging: {
        name: 'ActiveDirectory',
        streams: [
            {
                level: 'error',
                stream: process.stdout
            }
        ]
    }
});

// ******************************
// AND HERE
// ******************************
authenticator.authenticate('user@domain.com', 'password')
.then(({auth, user, groups}) => {
    if (auth) {
        const token: string = authenticator.sign({user, groups}, 'no-so-secret-key', {
            expiresIn: '1 day'
        });

        // your script ...
    }
})
.catch((err) => {
    console.log(err);
});
@CodisRedding CodisRedding changed the title Confused about diff between Authenticator authenticate. Confused about diff between Authenticator and authenticate functions. Nov 9, 2017
@oscaroceguera
Copy link

@CodisRedding me too :(

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

No branches or pull requests

2 participants