micro-basic-auth
Basic Auth for micro based micro-services
API compatible with the microauth modules
Usage
;; /** Use default validate **/const options = realm: 'MyApp' username: 'Bob' password: 'secret';/** or supply a function **/const options = realm: 'MyApp' validate: async { return true // if valid };/********/ // Third `auth` argument will provide error or result of authentication// so it will { err: errorObject} or { result: {// provider: 'basic',// info: userInfo// }}const handler = async { if !auth return ; if autherr // Error handler console; // If you want to prompt for credentials again ; return ; // Otherwise return ; return `Hello `; }; optionshandler;
Install
npm i micro-basic-auth