{"id":22092421,"url":"https://github.com/bhoriuchi/passport-activedirectory","last_synced_at":"2025-07-24T20:32:15.688Z","repository":{"id":46568860,"uuid":"64508969","full_name":"bhoriuchi/passport-activedirectory","owner":"bhoriuchi","description":"Active Directory strategy for passport.js","archived":false,"fork":false,"pushed_at":"2023-04-19T21:50:40.000Z","size":59,"stargazers_count":28,"open_issues_count":4,"forks_count":14,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-13T23:57:04.535Z","etag":null,"topics":["active-directory","authentication","passport","strategy","verification"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bhoriuchi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-07-29T20:35:50.000Z","updated_at":"2024-06-18T18:21:20.119Z","dependencies_parsed_at":"2024-06-18T18:21:15.205Z","dependency_job_id":"17d2e063-ae1d-461e-b97d-dabf18aacc48","html_url":"https://github.com/bhoriuchi/passport-activedirectory","commit_stats":{"total_commits":21,"total_committers":7,"mean_commits":3.0,"dds":"0.38095238095238093","last_synced_commit":"2480793dab287b45b1d3c599f888c7917c54f817"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bhoriuchi%2Fpassport-activedirectory","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bhoriuchi%2Fpassport-activedirectory/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bhoriuchi%2Fpassport-activedirectory/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bhoriuchi%2Fpassport-activedirectory/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bhoriuchi","download_url":"https://codeload.github.com/bhoriuchi/passport-activedirectory/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227476144,"owners_count":17779417,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["active-directory","authentication","passport","strategy","verification"],"created_at":"2024-12-01T03:09:26.543Z","updated_at":"2024-12-01T03:09:27.151Z","avatar_url":"https://github.com/bhoriuchi.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# passport-activedirectory\n\nActive Directory strategy for [`passport.js`](https://github.com/jaredhanson/passport)\n\n---\n\nThis Strategy is a *\"fork\"* of [`passport-windowsauth`](https://github.com/auth0/passport-windowsauth) that uses the [`activedirectory`](https://github.com/gheeres/node-activedirectory) module instead of directly calling [`ldapjs`](https://github.com/mcavage/node-ldapjs).\n\nThe module works almost identically except that the `verify` function is passed the `ActiveDirectory` object as a parameter so that you can use the query functions included in [`activedirectory`](https://github.com/gheeres/node-activedirectory) during verification. This is useful when using nested AD groups where you want to identify if a user is a member of a root level group.\n\n### Example\n\n#### Setup\n```js\nvar passport = require('passport')\nvar ActiveDirectoryStrategy = require('passport-activedirectory')\n\npassport.use(new ActiveDirectoryStrategy({\n  integrated: false,\n  ldap: {\n    url: 'ldap://my.domain.com',\n    baseDN: 'DC=my,DC=domain,DC=com',\n    username: 'readuser@my.domain.com',\n    password: 'readuserspassword'\n  }\n}, function (profile, ad, done) {\n  ad.isUserMemberOf(profile._json.dn, 'AccessGroup', function (err, isMember) {\n    if (err) return done(err)\n    return done(null, profile)\n  })\n}))\n```\n#### Protecting a path\n\n```js\nvar opts = { failWithError: true }\napp.post('/login', passport.authenticate('ActiveDirectory', opts), function(req, res) {\n  res.json(req.user)\n}, function (err) {\n  res.status(401).send('Not Authenticated')\n})\n\n// example request\n// \u003e curl -H \"Content-Type: application/json\" -X POST -d '{\"username\":\"xyz\",\"password\":\"xyz\"}' http://localhost/login\n```\n\n#### Optionally reuse an existing instance of `activedirectory`\n\n```js\nvar passport = require('passport')\nvar ActiveDirectoryStrategy = require('passport-activedirectory')\nvar ActiveDirectory = require('activedirectory')\n\nvar ad = new ActiveDirectory({\n  url: 'ldap://my.domain.com',\n  baseDN: 'DC=my,DC=domain,DC=com',\n  username: 'readuser@my.domain.com',\n  password: 'readuserspassword'\n})\n\npassport.use(new ActiveDirectoryStrategy({\n  integrated: false,\n  ldap: ad\n}, function (profile, ad, done) {\n  ad.isUserMemberOf(profile._json.dn, 'AccessGroup', function (err, isMember) {\n    if (err) return done(err)\n    return done(null, profile)\n  })\n}))\n```\n\n### API\n\n#### ActiveDirectoryStrategy ( `options`, `verify` )\n\n* `options` { `Object` } - Options for connecting and verification\n  * [`integrated=true`] { `Boolean` } - Use windows integrated login. For username and password authentication set this to `false`\n  * [`passReqToCallback=false`] { `Boolean` } - Pass the request to the callback\n  * [`usernameField=\"username\"`] { `String` } - request body field to use for the username\n  * [`passwordField=\"password\"`] { `String` } - request body field to use for the password\n  * [`mapProfile`] { `Function` } - Custom profile mapping function. Takes user object as only parameter and returns a profile object. `_json` is added to the object with the full object\n  * [`ldap`] { `Object` | `ActiveDirectory` } - LDAP connection object. Extended properties are documented [here](https://github.com/gheeres/node-activedirectory#optional-parameters--extended-functionality). You may also supply an instance of `activedirectory` instead.\n    * `url` { `String` } - LDAP URL (e.g. `ldap://my.domain.com`)\n    * `baseDN` { `String` } - Base LDAP DN to search for users in\n    * `username` { `String` } - User name of account with access to search the directory\n    * `password` { `String` } - Password for username\n    * [`filter`] { `Function` } - Takes `username` as its only parameter and returns an ldap query for that user\n    * [`attributes`] { `Array` } - Array of attributes to include in the profile under the `profile._json` key. The `dn` property is always added because it is used to authenticate the user\n* `verify` { `Function` } - Verification function. Depending on the options supplied the signature will be one of the following\n  * Signatures\n    * `verify ( profile, ad, done )` - Using ldap\n    * `verify( req, profile, ad, done )` - Using ldap and with the `passReqToCallback` option set to `true`\n    * `verify ( profile, done )` - Not using ldap\n    * `verify ( req, profile, done )` - Not using ldap and with the `passReqToCallback` option set to `true`\n  * Params\n    * `profile` { `Object` } - User profile object\n    * `req` { `Object` } - request object\n    * `ad` { `Object` } - `ActiveDirectory` instance\n    * `done` { `Function` } - Passport callback\n\n\n### More Information\n\n* For information on setting up integrated authentication with IIS and Apache, review the documentation at [`passport-windowsauth`](https://github.com/auth0/passport-windowsauth#integrated-authentication-iis)\n* For more information on ActiveDirectory methods review [`activedirectory`](https://github.com/gheeres/node-activedirectory)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbhoriuchi%2Fpassport-activedirectory","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbhoriuchi%2Fpassport-activedirectory","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbhoriuchi%2Fpassport-activedirectory/lists"}