{"id":21125330,"url":"https://github.com/ripjar/passport-client-cert","last_synced_at":"2025-07-08T22:31:09.125Z","repository":{"id":18395404,"uuid":"21576673","full_name":"ripjar/passport-client-cert","owner":"ripjar","description":"Passport.js strategy for PKI client certificate authentication","archived":false,"fork":false,"pushed_at":"2022-08-25T02:33:09.000Z","size":56,"stargazers_count":41,"open_issues_count":3,"forks_count":12,"subscribers_count":30,"default_branch":"master","last_synced_at":"2025-06-11T03:37:46.437Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ripjar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-07-07T15:54:58.000Z","updated_at":"2025-03-21T16:57:14.000Z","dependencies_parsed_at":"2022-09-09T23:40:39.488Z","dependency_job_id":null,"html_url":"https://github.com/ripjar/passport-client-cert","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/ripjar/passport-client-cert","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ripjar%2Fpassport-client-cert","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ripjar%2Fpassport-client-cert/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ripjar%2Fpassport-client-cert/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ripjar%2Fpassport-client-cert/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ripjar","download_url":"https://codeload.github.com/ripjar/passport-client-cert/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ripjar%2Fpassport-client-cert/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261225959,"owners_count":23127231,"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":[],"created_at":"2024-11-20T04:24:04.599Z","updated_at":"2025-07-08T22:31:08.850Z","avatar_url":"https://github.com/ripjar.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# passport-client-cert\n\n[![Build](https://travis-ci.org/ripjar/passport-client-cert.svg?branch=master)](https://travis-ci.org/ripjar/passport-client-cert)\n\n[passport.js](http://passportjs.org/) strategy for TLS client certificate authentication and authorisation.\n\npassport-client-cert is for TLS connections direct to a Node.js application.\n\n## Usage\nThe strategy constructor requires a verify callback, which will be executed on each authenticated request. It is responsible for checking the validity of the certificate and user authorisation.\n\n### Options\n\n* `passReqToCallback` - optional. Causes the request object to be supplied to the verify callback as the first parameter.\n\nThe verify callback is passed with the [client certificate object](https://nodejs.org/api/tls.html#tls_tlssocket_getpeercertificate_detailed) and a `done` callback. The `done` callback must be called as per the [passport.js documentation](http://passportjs.org/guide/configure/).\n\n````javascript\nvar passport = require('passport');\nvar ClientCertStrategy = require('passport-client-cert').Strategy;\n\npassport.use(new ClientCertStrategy(function(clientCert, done) {\n  var cn = clientCert.subject.cn,\n      user = null;\n      \n  // The CN will typically be checked against a database\n  if(cn === 'test-cn') {\n    user = { name: 'Test User' }\n  }\n  \n  done(null, user);\n}));\n````\n\nThe verify callback can be supplied with the `request` object by setting the `passReqToCallback` option to `true`, and changing callback arguments accordingly.\n\n````javascript\npassport.use(new ClientCertStrategy({ passReqToCallback: true }, function(req, clientCert, done) {\n  var cn = clientCert.subject.cn,\n      user = null;\n      \n  // The CN will typically be checked against a database\n  if(cn === 'test-cn') {\n    user = { name: 'Test User' }\n  }\n  \n  done(null, user);\n}));\n````\n\n## Examples\n\nInstall and start the example server app:\n\n    $ npm install\n    $ cd example\n    $ node example-server.js\n\nSubmit a request with a client certificate:\n\n    $ curl -k --cert certs/joe.crt --key certs/joe.key --cacert certs/ca.crt https://localhost:3443\n\nIf `curl` fails and you are using OSX Mavericks or newer (where [support for ad-hoc CA certifcates is broken](http://curl.haxx.se/mail/archive-2013-10/0036.html), try `wget` instead:\n\n    $ wget -qSO - --no-check-certificate --certificate=certs/joe.crt --private-key=certs/joe.key --ca-certificate=certs/ca.crt https://localhost:3443/\n\nRequests submitted with `joe.crt` are authorised because `joe` is in the list of valid users. Requests submitted without a certificate, or with `bob.crt` will fail with a HTTP `401`.\n\n## Test\n\n    $ npm install\n    $ npm test\n\n\n## Licence\n\n[The MIT Licence](http://opensource.org/licenses/MIT)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fripjar%2Fpassport-client-cert","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fripjar%2Fpassport-client-cert","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fripjar%2Fpassport-client-cert/lists"}