auth_totp_realm
为 NGINX 中的 TOTP 身份验证定义一个 realm 名称,该名称显示在身份验证提示中。
Time-based one-time password (TOTP) authentication for NGINX
·
httpserverlocationlimit_except
语法auth_totp_realm realm_name;
默认值none
上下文http, server, location, limit_except
参数1
说明
auth_totp_realm 指令指定在基于时间的一次性密码 (TOTP) 身份验证提示中使用的 realm 名称。该 realm 用作身份验证请求的标签,向用户提供有关他们尝试访问的资源的上下文信息。当用户尝试进行身份验证时,realm 名称会出现在浏览器显示的身份验证对话框中,帮助用户识别正在请求凭据的服务。
该指令可以放在多个上下文中,包括 http、server、location 和 limit_except,从而在 NGINX 配置中灵活地控制身份验证的应用位置。通过设置 realm,服务器管理员可以定制身份验证过程中的用户体验,使其清楚需要哪些凭据以及针对哪些资源。realm 可以设置为任意字符串,允许管理员根据组织标准或安全策略为其服务命名。
配置示例
server {
listen 80;
location /protected {
auth_totp_realm "Protected";
auth_totp_file /etc/nginx/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;
}
}⚠
确保认证域名称具有描述性,以避免在身份验证过程中使用户感到困惑。
⚠
如果未指定认证域,可能会导致通用的身份验证提示,缺乏对最终用户的上下文信息。