下载代码

开源地址:https://github.com/gbraad-apps/gauth/tree/master

解压到网站目录下

修改配置

1、源程序将数据保存在本地,但准备私人使用,故创建json文件,方便编辑

        var init = function() {
            storageService = new StorageService();
            keyUtilities = new KeyUtilities(jsSHA);
//添加开始
fetch('./js/account.json')
  .then(response => response.json())
  .then(accounts => {
    accounts.forEach(account => {
      addAccount(account.name, account.secret);
    });
  });
//添加结束
            // Check if local storage is supported
            if (storageService.isSupported()) {

2、创建json

[
  {"name": "OV", "secret": "71V7TF4ALXS"},
  {"name": "CF", "secret": "UTL2MJ4X5D4"},
  {"name": "EU", "secret": "6J1ZTBQ42OF"},
  {"name": "Go", "secret": "p1hvmc6tae"}
]

3、修改nginx配置,增加目录访问验证

location /gauth {
    auth_basic "Protected Area";
    auth_basic_user_file /www/server/pass/gauth;
}