wikijs-fork/libs/internalAuth.js

27 lines
327 B
JavaScript
Raw Normal View History

2017-02-09 01:52:37 +00:00
'use strict'
2017-02-09 01:52:37 +00:00
const crypto = require('crypto')
/**
* Internal Authentication
*/
module.exports = {
2017-02-09 01:52:37 +00:00
_curKey: false,
2017-02-09 01:52:37 +00:00
init (inKey) {
this._curKey = inKey
2017-02-09 01:52:37 +00:00
return this
},
2017-02-09 01:52:37 +00:00
generateKey () {
return crypto.randomBytes(20).toString('hex')
},
2017-02-09 01:52:37 +00:00
validateKey (inKey) {
return inKey === this._curKey
}
2017-02-09 01:52:37 +00:00
}