Authing 文档文档
快速开始
概念
使用指南
开发集成 V2 arrow
  • V2 文档
  • V3 文档
元数据
应用集成
身份自动化
加入 APN
开发集成
多租户(内测版)
控制台文档
多租户控制台
租户控制台
Saas 应用 Demo
快速开始
概念
使用指南
开发集成 V2 arrow
  • V2 文档
  • V3 文档
元数据
应用集成
身份自动化
加入 APN
开发集成
多租户(内测版)
控制台文档
多租户控制台
租户控制台
Saas 应用 Demo
旧版
开发集成
  • JavaScript SDK 索引
  • 单点登录(SSO)
  • 登录组件 (Guard)

  • 多因素认证组件(MFA)

  • JavaScript / Node.js

  • Java / Kotlin

  • Python

    • 用户认证模块

      • 认证核心模块
      • 标准协议认证模块
      • 多因素认证模块
    • 管理模块

  • C#

  • PHP

  • Go

  • Ruby
  • Delphi
  • Android

  • iOS

  • Flutter

  • 微信小程序
  • 微信网页授权
  • React Native
  • 框架集成

  • Radius
  • 错误代码
  1. 开发集成
  2. /
  3. Python
  4. /
  5. 用户认证模块
  6. /
  7. 多因素认证模块

¶ 多因素认证模块

更新时间: 2025-02-18 09:00:47
编辑

此模块用于为用户绑定、解绑 TOTP、短信、邮箱、人脸识别等二次认证器。例如用户存在异地行为时,你希望让用户进行二次身份认证,目前 Authing 支持多种二次验证的方式,包括 TOTP、短信、邮箱、人脸识别等。

示例代码:

import { AuthenticationClient } from 'authing-js-sdk';
const authenticationClient = new AuthenticationClient({
  appId: 'AUTHING_APP_ID',
  appHost: 'https://{YOUR_DOMAIN}.authing.cn',
});

authenticationClient.mfa.getMfaAuthenticators;
authenticationClient.mfa.assosicateMfaAuthenticator;
authenticationClient.mfa.verifyTotpMfa;
authenticationClient.mfa.verifyFaceMfa;
authenticationClient.mfa.associateFaceByLocalFile;
authenticationClient.mfa.associateFaceByBlob;
authenticationClient.mfa.associateFaceByUrl;
authenticationClient.mfa.verifyTotpRecoveryCode;
authenticationClient.mfa.phoneOrEmailBindable;
authenticationClient.mfa.verifyAppEmailMfa;
authenticationClient.mfa.verifyAppSmsMfa;
authenticationClient.mfa.confirmAssosicateMfaAuthenticator;
authenticationClient.mfa.deleteMfaAuthenticator;

¶ 获取 MFA 认证器

def get_mfa_authenticators(self, mfa_token=None, type='totp', source='SELF'):
  pass

获取 MFA 认证器

¶ 参数

  • mfa_token <str> Token
  • type <str> 类型
  • source <str> 数据源

¶ 示例

tt = self.authentication.login_by_email("test@example.com", "pwd")
authentication.get_mfa_authenticators(mfa_token=tt['token'])

¶ 示例数据

{
	"code": 200,
	"message": "获取 MFA Authenticator 成功",
	"data": [{
		"id": "6176585c29629448d5fc8b37",
		"createdAt": "2021-10-25T07:10:20.892Z",
		"updatedAt": "2021-10-25T07:11:33.142Z",
		"userId": "61418763xx979c3740",
		"enable": false,
		"secret": "D5LH4xxWEHKX",
		"authenticatorType": "totp",
		"recoveryCode": "c833-xxxx-9180-7240-a048-ebe6",
		"source": "SELF"
	}]
}

¶ 请求 MFA 二维码和密钥信息

def assosicate_mfa_authenticator(self, mfa_token=None, authenticator_type='totp', source='SELF'):
  pass

请求 MFA 二维码和密钥信息

¶ 参数

  • mfa_token <str> Token
  • authenticator_type <str> 类型
  • source <str> 数据源

¶ 示例

tt = self.authentication.login_by_email("test@example.com", "pwd")
res = self.authentication.assosicate_mfa_authenticator(tt['token'])

¶ 示例数据

{
  "message": "获取 MFA 密钥成功",
  "code": 200,
  "data": {
    "recovery_code": "bc5a-6879-617a-6e94-9dd1-9dd2",
    "authenticator_type": "totp",
    "qrcode_data_url": "data:image/png;base64,iVBO Wse1lrXPKy1rnlYa13zsNa65mGtdc3DWuuah7XWNQ9rrWse1lrX/B//adHsf5AaswAAAABJRU5ErkJggg==",
    "secret": "JRYQWOZNJMQXQOAO",
    "qrcode_uri": "otpauth://totp/newSDK:fptvm K"
  }
}

¶ 解绑 MFA

def delete_mfa_authenticator(self):
  pass

解绑 MFA

¶ 示例

tt = self.authentication.login_by_email("test@example.com", "pwd")
res = authentication.delete_mfa_authenticator()

¶ 示例数据

{
  "message": "TOTP MFA 解绑成功",
  "code": 200
}

¶ 确认绑定 MFA

def confirm_assosicate_mfa_authenticator(self,
                                           totp,
                                           authenticator_type='totp',
                                           source='SELF',
                                           mfa_token=None):
  pass

确认绑定 MFA

¶ 参数

  • totp <str> 验证码
  • authenticator_type <str> 类型
  • source <str> 数据源
  • mfa_token <str> Token

¶ 示例

tt = self.authentication.login_by_email("test@example.com", "pwd")
authentication.confirm_assosicate_mfa_authenticator(tt['token'])

¶ 检验二次验证 MFA 口令

def verify_totp_mfa(self, totp, mfa_token):
  pass

检验二次验证 MFA 口令

¶ 参数

  • totp <str> 验证码
  • mfa_token <str> Token

¶ 示例

tt = self.authentication.login_by_email("test@example.com", "pwd")
authentication.verify_totp_mfa("",tt['token'])

¶ 检验二次验证 MFA 短信验证码

def verify_app_sms_mfa(self, phone, code, mfa_token):
  pass

检验二次验证 MFA 短信验证码

¶ 参数

  • phone <str> 手机号
  • code <str> 验证码
  • mfa_token <str> Token

¶ 示例

tt = self.authentication.login_by_email("test@example.com", "pwd")
authentication.verify_app_sms_mfa("phone","11",tt['token'])

¶ 检验二次验证 MFA 邮箱验证码

def verify_app_email_mfa(self, email, code, mfa_token):
  pass

检验二次验证 MFA 邮箱验证码

¶ 参数

  • email <str> 邮箱
  • code <str> 验证码
  • mfa_token <str> Token

¶ 示例

tt = self.authentication.login_by_email("test@example.com", "pwd")
authentication.verify_app_email_mfa("email","11",tt['token'])

¶ 检测手机号或邮箱是否已被绑定

def phone_or_email_bindable(self, mfa_token, phone=None, email=None):
  pass

检测手机号或邮箱是否已被绑定

¶ 参数

  • email <str> 邮箱
  • phone <str> 手机号
  • mfa_token <str> Token

¶ 示例

tt = self.authentication.login_by_email("test@example.com", "pwd")
authentication.phone_or_email_bindable("email",tt['token'])

¶ 检验二次验证 MFA 恢复代码

def verify_totp_recovery_code(self, recovery_code, mfa_token):
  pass

检验二次验证 MFA 恢复代码

¶ 参数

  • recovery_code <str> 恢复验证码
  • mfa_token <str> Token

¶ 示例

tt = self.authentication.login_by_email("test@example.com", "pwd")
authentication.verify_totp_recovery_code("xxx",tt['token'])

¶ 通过图片 URL 绑定人脸

def associate_face_by_url(self, base_face, compare_face, mfa_token=None):
  pass

通过图片 URL 绑定人脸

¶ 参数

  • base_face <str> 基础照片
  • compare_face <str> 对比照片
  • mfa_token <str> Token

¶ 示例

tt = self.authentication.login_by_email("test@example.com", "pwd")
authentication.associate_face_by_url("url",otherUrl",tt['token'])

¶ 人脸二次认证

def verify_face_mfa(self, photo, mfa_token):
  pass

人脸二次认证

¶ 参数

  • photo <str> 头像
  • mfa_token <str> Token

¶ 示例

tt = self.authentication.login_by_email("test@example.com", "pwd")
authentication.verify_face_mfa("otherUrl",tt['token'])
上一篇: 标准协议认证模块 下一篇: 管理模块
  • 获取 MFA 认证器
  • 请求 MFA 二维码和密钥信息
  • 解绑 MFA
  • 确认绑定 MFA
  • 检验二次验证 MFA 口令
  • 检验二次验证 MFA 短信验证码
  • 检验二次验证 MFA 邮箱验证码
  • 检测手机号或邮箱是否已被绑定
  • 检验二次验证 MFA 恢复代码
  • 通过图片 URL 绑定人脸
  • 人脸二次认证

用户身份管理

集成第三方登录
手机号闪验 (opens new window)
通用登录表单组件
自定义认证流程

企业内部管理

单点登录
多因素认证
权限管理

开发者

开发文档
框架集成
博客 (opens new window)
GitHub (opens new window)
社区用户中心 (opens new window)

公司

400 888 2106
sales@authing.cn
北京市朝阳区北辰世纪中心 B 座 16 层(总)
成都市高新区天府五街 200 号 1 号楼 B 区 4 楼 406 室(分)

京ICP备19051205号

beian京公网安备 11010802035968号

© 北京蒸汽记忆科技有限公司