<!-- review: finished -->

<a id="external-auth-totp"></a>

# Auth TOTP

该模块实现基于时间的一次性密码 (TOTP) 算法，并提供短时有效的一次性密码机制。

特性：

- 使用 TOTP 的标准 HTTP 认证。
- 在 TOTP 过期后基于 cookie 跟踪已认证客户端。
- 可配置的密钥、时间基准、时间步长和截断长度，用于生成 TOTP。
- 可配置的 TOTP 校验时间窗口。

<a id="installation-106"></a>

## 安装

要 [安装](https://cn.angie.software//angie/docs/installation/index.md#install-packages) 该模块，请使用以下软件包之一：

- Angie：`angie-module-auth-totp`
- Angie PRO：`angie-pro-module-auth-totp`

<a id="loading-the-module-106"></a>

## 加载模块

要使用该模块，请在 `main{}` 上下文中加载它：

```nginx
load_module modules/ngx_http_auth_totp_module.so;
```

<a id="configuration-example-106"></a>

## 配置示例

```nginx
server {
    listen 80;

    location /protected {
        auth_totp_realm "Protected";
        auth_totp_file /etc/angie/totp.conf;
        auth_totp_length 8;
        auth_totp_reuse off;
        auth_totp_skew 1;
        auth_totp_step 1m;
        auth_totp_cookie "totp-session";
        auth_totp_expiry 1d;
    }
}
```

<a id="additional-information-106"></a>

## 其他信息

详细文档和源代码可在以下位置获取：
[https://github.com/61131/nginx-http-auth-totp](https://github.com/61131/nginx-http-auth-totp)
