mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-25 16:11:24 +08:00
Add types for passport-windowsauth (#29630)
* Add types for passport-windowsauth * Use class instead of interface for strategy-windowsauth
This commit is contained in:
committed by
Andy
parent
66d218c459
commit
52d1975b92
49
types/passport-windowsauth/index.d.ts
vendored
Normal file
49
types/passport-windowsauth/index.d.ts
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
// Type definitions for passport-windowsauth 3.0
|
||||
// Project: https://github.com/auth0/passport-windowsauth#readme
|
||||
// Definitions by: Emily Marigold Klassen <https://github.com/forivall>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import * as express from 'express';
|
||||
import * as passport from 'passport';
|
||||
import * as ldapjs from 'ldapjs';
|
||||
import { TlsOptions } from 'tls';
|
||||
|
||||
declare namespace windowsauth {
|
||||
interface Options {
|
||||
ldap?: {
|
||||
url?: string
|
||||
maxConnections?: number
|
||||
base?: string
|
||||
bindDN?: string
|
||||
bindCredentials?: string
|
||||
tlsOptions?: TlsOptions;
|
||||
reconnect?: boolean | {
|
||||
initialDelay?: number,
|
||||
maxDelay?: number,
|
||||
failAfter?: number
|
||||
};
|
||||
timeout?: number;
|
||||
connectTimeout?: number;
|
||||
idleTimeout?: number;
|
||||
binder?: ldapjs.Client
|
||||
client?: ldapjs.Client
|
||||
};
|
||||
integrated?: boolean;
|
||||
getUserNameFromHeader?(req: express.Request): string;
|
||||
passReqToCallback?: boolean;
|
||||
usernameField?: string;
|
||||
passwordField?: string;
|
||||
}
|
||||
type Verified = (err: Error | undefined | null, user?: object, info?: object) => void;
|
||||
type Verify = (profile: passport.Profile, done: Verified) => void;
|
||||
type VerifyWithReq = (req: express.Request, profile: passport.Profile, done: Verified) => void;
|
||||
}
|
||||
|
||||
declare class windowsauth extends passport.Strategy {
|
||||
constructor(options: windowsauth.Options & {passReqToCallback: true}, verify: windowsauth.VerifyWithReq);
|
||||
constructor(options: windowsauth.Options, verify: windowsauth.Verify);
|
||||
constructor(verify: windowsauth.Verify);
|
||||
}
|
||||
|
||||
export = windowsauth;
|
||||
28
types/passport-windowsauth/passport-windowsauth-tests.ts
Normal file
28
types/passport-windowsauth/passport-windowsauth-tests.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import * as passport from 'passport';
|
||||
import * as WindowsStrategy from 'passport-windowsauth';
|
||||
|
||||
const auth = new passport.Authenticator();
|
||||
auth.use(new WindowsStrategy({integrated: true}, (profile, done) => {
|
||||
console.log(profile);
|
||||
done(null, profile);
|
||||
}));
|
||||
|
||||
passport.use(new WindowsStrategy({
|
||||
ldap: {
|
||||
url: 'ldap://wellscordoba.wellscordobabank.com/DC=wellscordobabank,DC=com',
|
||||
base: 'DC=wellscordobabank,DC=com',
|
||||
bindDN: 'someAccount',
|
||||
bindCredentials: 'andItsPass'
|
||||
}
|
||||
}, (profile, done) => {
|
||||
console.log('logged in', profile.id);
|
||||
done(null, profile);
|
||||
}));
|
||||
|
||||
passport.use(new WindowsStrategy({
|
||||
integrated: true,
|
||||
passReqToCallback: true
|
||||
}, (req, profile, done) => {
|
||||
console.log('logged in', req, profile.id);
|
||||
done(null, profile);
|
||||
}));
|
||||
23
types/passport-windowsauth/tsconfig.json
Normal file
23
types/passport-windowsauth/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"passport-windowsauth-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/passport-windowsauth/tslint.json
Normal file
1
types/passport-windowsauth/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user