-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added hapi-auth-bearer-token * auth strategy is registered in it's own plugin './authtoken.js' * all routes must have valid token to be accessed - currently only one route exists. * adjusted project values to reflect assignment4 * tests adjusted to posses valid token.
- Loading branch information
Showing
7 changed files
with
59 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
* lesson1 | ||
* lesson2 | ||
* lesson3 | ||
* lesson4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
'use strict'; | ||
|
||
// Declare internals | ||
|
||
const internals = {}; | ||
|
||
|
||
const defaultValidateFunc = (request, token) => { | ||
|
||
// Put database query to authenticate the token is valid here. | ||
|
||
return { | ||
isValid: token === '12345678', | ||
credentials: { token } | ||
}; | ||
}; | ||
|
||
exports.plugin = { | ||
name: 'authtoken', | ||
version: '1.0.0', | ||
description: 'register hapi-auth-bearer-token strategy.', | ||
register: function (server, options) { | ||
|
||
server.auth.strategy('default', 'bearer-access-token', { | ||
validate: defaultValidateFunc | ||
}); | ||
server.auth.default('default'); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters