@koopjs/auth-direct-file
Advanced tools
Comparing version 2.0.2 to 2.0.3
@@ -5,2 +5,6 @@ # Change Log | ||
## 2.0.3 | ||
### Fixed | ||
* username and password can arrive on query or body | ||
## 2.0.2 | ||
@@ -7,0 +11,0 @@ * patch - invalidate with user not found |
{ | ||
"name": "@koopjs/auth-direct-file", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"description": "Module for implementing a direct authentication pattern with file-based user-store in Koop", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -75,5 +75,6 @@ const fs = require('fs'); | ||
async function authenticate(req) { | ||
const username = req.query?.username; | ||
const password = req.query?.password; | ||
const { query = {}, body = {} } = req; | ||
const { username, password } = {...query, ...body}; | ||
// Validate user's credentials | ||
@@ -80,0 +81,0 @@ const valid = await validateCredentials( |
@@ -76,3 +76,3 @@ const helpers = require('./validate-credentials'); | ||
test('should validate and send jwt', async () => { | ||
test('should validate creds from query and send jwt', async () => { | ||
helpers.validateCredentials.mockImplementationOnce(() => { | ||
@@ -97,2 +97,23 @@ return true; | ||
}); | ||
test('should validate creds from body and send jwt', async () => { | ||
helpers.validateCredentials.mockImplementationOnce(() => { | ||
return true; | ||
}); | ||
jwt.sign.mockImplementationOnce(() => { | ||
return 'abc'; | ||
}); | ||
const authPlugin = require('./index.js')( | ||
secret, | ||
path.join(__dirname, '../test/fixtures/user-store.json'), | ||
{ useHttp: true } | ||
); | ||
const result = await authPlugin.authenticate({ body: { username: 'foo', password: 'bar' } }); | ||
expect(result.token).toEqual('abc'); | ||
expect(result.expires).toBeGreaterThan(Date.now()); | ||
}); | ||
}); | ||
@@ -99,0 +120,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
60483
494