Usurp a user identity by checking a header presence
Install it
npm i usurper
#OR
yarn add usurper
Expected pattern
Usurper will expect this pattern :
{
"Authorization": "usurp=anyone@anything.watev"
}
Use it
const Usurper = require('usurper')
//Optionnaly configure it
Usurper.configure(options)
const [success, identity] = Usurper.usurp(ctx.request.headers.authorization)
const user = sucess && await findUser(identity) // do anything you want with usurped user Id
name | description | default |
---|---|---|
disabled | turn off usurper | `process.env.USURPER_DISABLED === 'true' |
verbose | Log in console usurped identity | false |