����JFIF��H�H����Exif��MM�*���� ��3����V�����3������3�(��������������������3�����
Server IP : 74.208.127.88 / Your IP : 3.147.45.232 Web Server : Apache/2.4.41 (Ubuntu) System : Linux ubuntu 5.4.0-163-generic #180-Ubuntu SMP Tue Sep 5 13:21:23 UTC 2023 x86_64 User : www-data ( 33) PHP Version : 7.4.3-4ubuntu2.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/html/app6/node_modules/basic-auth/ |
Upload File : |
# basic-auth [![NPM Version][npm-image]][npm-url] [![NPM Downloads][downloads-image]][downloads-url] [![Node.js Version][node-version-image]][node-version-url] [![Build Status][travis-image]][travis-url] [![Test Coverage][coveralls-image]][coveralls-url] Generic basic auth Authorization header field parser for whatever. ## Installation This is a [Node.js](https://nodejs.org/en/) module available through the [npm registry](https://www.npmjs.com/). Installation is done using the [`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally): ``` $ npm install basic-auth ``` ## API <!-- eslint-disable no-unused-vars --> ```js var auth = require('basic-auth') ``` ### auth(req) Get the basic auth credentials from the given request. The `Authorization` header is parsed and if the header is invalid, `undefined` is returned, otherwise an object with `name` and `pass` properties. ### auth.parse(string) Parse a basic auth authorization header string. This will return an object with `name` and `pass` properties, or `undefined` if the string is invalid. ## Example Pass a Node.js request object to the module export. If parsing fails `undefined` is returned, otherwise an object with `.name` and `.pass`. <!-- eslint-disable no-unused-vars, no-undef --> ```js var auth = require('basic-auth') var user = auth(req) // => { name: 'something', pass: 'whatever' } ``` A header string from any other location can also be parsed with `auth.parse`, for example a `Proxy-Authorization` header: <!-- eslint-disable no-unused-vars, no-undef --> ```js var auth = require('basic-auth') var user = auth.parse(req.getHeader('Proxy-Authorization')) ``` ### With vanilla node.js http server ```js var http = require('http') var auth = require('basic-auth') var compare = require('tsscmp') // Create server var server = http.createServer(function (req, res) { var credentials = auth(req) // Check credentials // The "check" function will typically be against your user store if (!credentials || !check(credentials.name, credentials.pass)) { res.statusCode = 401 res.setHeader('WWW-Authenticate', 'Basic realm="example"') res.end('Access denied') } else { res.end('Access granted') } }) // Basic function to validate credentials for example function check (name, pass) { var valid = true // Simple method to prevent short-circut and use timing-safe compare valid = compare(name, 'john') && valid valid = compare(pass, 'secret') && valid return valid } // Listen server.listen(3000) ``` # License [MIT](LICENSE) [coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/basic-auth/master [coveralls-url]: https://coveralls.io/r/jshttp/basic-auth?branch=master [downloads-image]: https://badgen.net/npm/dm/basic-auth [downloads-url]: https://npmjs.org/package/basic-auth [node-version-image]: https://badgen.net/npm/node/basic-auth [node-version-url]: https://nodejs.org/en/download [npm-image]: https://badgen.net/npm/v/basic-auth [npm-url]: https://npmjs.org/package/basic-auth [travis-image]: https://badgen.net/travis/jshttp/basic-auth/master [travis-url]: https://travis-ci.org/jshttp/basic-auth