flora-auth-jwt
Advanced tools
Comparing version 2.0.0-alpha.1 to 2.0.0-alpha.2
14
index.js
@@ -6,8 +6,12 @@ 'use strict'; | ||
exports.name = 'auth-jwt'; | ||
/** | ||
* @param {flora.Api} api - Api instance | ||
* @param {object} options - Plugin options | ||
* @param {string} options.secret - JWT secret | ||
* @param {boolean} [options.credentialsRequired] - Fail on requests without JWT (default: false) | ||
*/ | ||
module.exports = (api, options) => { | ||
if (typeof options !== 'object') throw new Error('options must be an object'); | ||
if (!options.secret) throw new Error('options must contain a "secret" property'); | ||
exports.register = function register(api, options) { | ||
if (typeof options !== 'object') throw new Error('opts must be an object'); | ||
if (!options.secret) throw new Error('opts must contain a "secret" property'); | ||
options.credentialsRequired = !!options.credentialsRequired; | ||
@@ -14,0 +18,0 @@ |
{ | ||
"name": "flora-auth-jwt", | ||
"version": "2.0.0-alpha.1", | ||
"version": "2.0.0-alpha.2", | ||
"description": "JSON Web Token authentication for Flora", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -13,7 +13,7 @@ # flora-auth-jwt | ||
const flora = require('flora'); | ||
const floraAuth = require('flora-auth-jwt'); | ||
const floraAuthJwt = require('flora-auth-jwt'); | ||
const server = new flora.Server('./config.js'); | ||
server.register({ | ||
server.register('auth-jwt', floraAuthJwt, { | ||
secret: 'My Secret Key', | ||
@@ -20,0 +20,0 @@ credentialsRequired: false, // default: true |
6964
82