hachiware_server_module_basic_auth v1.0.4
hachiware_server_module_basic_auth
A module for basic authentication of the web server package "hachiware_server".
It is a dedicated server module of the web server application "hachiware_server".
To use it, you must first install and configure hachiware_server
.
You can install hachiware_server with the following command.
npm i hachiware_server
The server module can be installed with the following npm command.
npm i hachiware_server_module_basic_auth
After installation, you will need the hachiware server configuration file. See here for the procedure for using hachiware_server.
# Setting method
Open the configuration file conf.js
for each Server Section on the hachiware server.
Confirm that hachiware_server_module_basic_auth
is added in modules
.
modules: [
...
"hachiware_server_module_basic_auth",
...
],
Then specify basicAuths
as shown below.
basicAuths: {
name: "authority test sample",
username: "admin",
password: "12345",
onFailed: function(res){
res.write("Authoricate Error!!");
res.end();
},
},
The setting items are as follows.
colum name | overview |
---|---|
name | Certification name. |
username | Authentication user name. |
password | Authentication password. |
onFailed | Callback when authentication fails. |
url | You can specify the URL that implements basic authentication.If not specified, all URLs in the server will be subject to authentication.You can also specify multiple URLs in the list layout. |
After that, restart the server and basic authentication will be applied.
# Life Cycle
The life cycle of this server module is as follows:
(server listen start)
|
load fook start
|
(request)
|
load fook access
|
access callback action <= Basic Authoricate.
|
| * If an error occurs
|
load fook error
|
error callback action
...
|
| * Quit the server
|
load fook end
|
(server listen exit)
- "Load hook start" executes the start hook of each server module.
- "load fook access" executes the access hook of each sserver module.
- "load fook error" executes the error hook of the server module.
- "Load hook end" executes the end hook of each server module.
hachiware_server_module_basic_auth
A module for basic authentication of the web server package "hachiware_server".
License : MIT License.
Author : Nakatsuji Masato
HP URL : https://hachiware-js.com/
GitHub : https://github.com/masatonakatsuji2021/hachiware_server_module_basic_auth
npm : https://www.npmjs.com/package/hachiware_server_module_basic_auth