diff --git a/.github/workflows/semgrep.yml b/.github/workflows/semgrep.yml new file mode 100644 index 0000000..e58d5d5 --- /dev/null +++ b/.github/workflows/semgrep.yml @@ -0,0 +1,15 @@ +name: Semgrep +on: + pull_request_target: {} + push: + branches: ["master"] +jobs: + semgrep: + name: Scan + runs-on: ubuntu-latest + if: (github.actor != 'dependabot[bot]' && github.actor != 'snyk-bot') + steps: + - uses: actions/checkout@v2 + - uses: returntocorp/semgrep-action@v1 + with: + publishToken: ${{ secrets.SEMGREP_APP_TOKEN }} diff --git a/lib/passport-http/strategies/basic.js b/lib/passport-http/strategies/basic.js index a1f251c..785f3c0 100644 --- a/lib/passport-http/strategies/basic.js +++ b/lib/passport-http/strategies/basic.js @@ -85,10 +85,10 @@ BasicStrategy.prototype.authenticate = function(req) { var self = this; - function verified(err, user) { + function verified(err, user, info) { if (err) { return self.error(err); } if (!user) { return self.fail(self._challenge()); } - self.success(user); + self.success(user, info); } if (self._passReqToCallback) { diff --git a/opslevel.yml b/opslevel.yml new file mode 100644 index 0000000..fe71abd --- /dev/null +++ b/opslevel.yml @@ -0,0 +1,5 @@ +--- +version: 1 +repository: + owner: iam_federations + tags: diff --git a/package.json b/package.json index cf71f87..8523006 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,16 @@ { "name": "passport-http", - "version": "0.3.0", + "version": "0.3.1", "description": "HTTP Basic and Digest authentication strategies for Passport.", - "keywords": ["passport", "http", "basic", "digest", "auth", "authn", "authentication"], + "keywords": [ + "passport", + "http", + "basic", + "digest", + "auth", + "authn", + "authentication" + ], "repository": { "type": "git", "url": "git://github.com/jaredhanson/passport-http.git" @@ -15,10 +23,12 @@ "email": "jaredhanson@gmail.com", "url": "http://www.jaredhanson.net/" }, - "licenses": [ { - "type": "MIT", - "url": "http://www.opensource.org/licenses/MIT" - } ], + "licenses": [ + { + "type": "MIT", + "url": "http://www.opensource.org/licenses/MIT" + } + ], "main": "./lib/passport-http", "dependencies": { "passport-strategy": "1.x.x" @@ -29,5 +39,7 @@ "scripts": { "test": "NODE_PATH=lib node_modules/.bin/vows test/*-test.js test/**/*-test.js" }, - "engines": { "node": ">= 0.4.0" } + "engines": { + "node": ">= 0.4.0" + } } diff --git a/test/strategies/basic-test.js b/test/strategies/basic-test.js index 6a5b453..931cc6b 100644 --- a/test/strategies/basic-test.js +++ b/test/strategies/basic-test.js @@ -52,6 +52,48 @@ vows.describe('BasicStrategy').addBatch({ }, }, + 'strategy that verifies a request with additional info': { + topic: function() { + var strategy = new BasicStrategy(function(userid, password, done) { + done(null, { username: userid, password: password }, { foo: 'bar' }); + }); + return strategy; + }, + + 'after augmenting with actions': { + topic: function(strategy) { + var self = this; + var req = {}; + strategy.success = function(user, info) { + self.callback(null, user, info); + } + strategy.fail = function() { + self.callback(new Error('should not be called')); + } + strategy.error = function() { + self.callback(new Error('should not be called')); + } + + req.headers = {}; + req.headers.authorization = 'Basic Ym9iOnNlY3JldA=='; + process.nextTick(function () { + strategy.authenticate(req); + }); + }, + + 'should not generate an error' : function(err, user) { + assert.isNull(err); + }, + 'should authenticate' : function(err, user) { + assert.equal(user.username, 'bob'); + assert.equal(user.password, 'secret'); + }, + 'should authenticate with additional info' : function(err, user, info) { + assert.equal(info.foo, 'bar'); + }, + }, + }, + 'strategy handling a request that is not verified': { topic: function() { var strategy = new BasicStrategy(function(userid, password, done) {