Authing 知识库
🛠 开发资源🥂 集成案例🔭 常见问题🖥 控制台
1.0.0
1.0.0
  • 欢迎
  • Authing 概述
  • 快速开始
    • 第一个应用
    • 基础概念
    • 实现单点登录
    • 控制台概览
    • 部署模型
  • 进阶指南
    • 理解认证和授权
      • 用户名 - 密码认证
      • 邮箱 - 密码认证
      • 手机 - 验证码认证
      • JWT Token 释义及使用
      • 验证 JWT Token
    • 配置用户权限
    • 最佳开发实践
    • 接入小程序扫码登录
      • 接入私有化小程序
    • 接入社会化登录
    • 接入 OAuth 2.0
      • 创建 OAuth 应用
      • 使用 OAuth 授权
    • 接入 OpenID Connect
      • 创建 OIDC 应用
      • 使用 OIDC 授权
      • 理解 OIDC 流程
      • OIDC 常见问题
    • 配置 LDAP 服务
    • 使用 Authing 的 LDAP 用户目录
    • 接入 SAML
      • 创建 SAML Identity Provider 应用
      • 创建 SAML Service Provider 应用
      • 理解 SAML 流程
      • 同时使用 Authing 作为 SP 和 IdP
      • 使用 SAML Identity Provider
        • 在阿里云访问管理中使用
        • 在腾讯云访问管理中使用
        • 在 Auth0 中使用
      • 使用 SAML Service Provider
        • 与 Auth0 SAML IdP 对接
        • 与 SSOCircle SAML IdP 对接
    • 使用 Webhook
    • 错误代码
  • 开发资源
    • 开发资源
    • API(GraphQL)
    • Guard for Web
    • Guard VS 自定义 UI
    • SDK for Web
      • 读取/修改用户权限
      • 绑定社会化登录
      • 管理 MFA 口令
      • 自定义请求链接
    • SDK for 微信小程序
    • SDK for Java
    • SDK for Objective-C
    • SDK for Python
    • SDK for Go
    • SDK for PHP
    • 函数计算(FaaS)
  • 通信
    • 邮件
    • SMS
  • MFA
    • 配置 MFA 安全口令
    • 接入 MFA
  • 安全
    • 配置 Web 安全域
    • 配置用户池密码强度
    • 配置密码加密函数
  • 其他
    • 常见问题
    • 集成案例
      • 使用 Authing 补充 AWS 中国区 Cognito User Pool
    • 社交互联数据
      • Authing 与社交互联数据
    • 为 Authing 贡献 SDK
      • 了解 Authing 的模块
Powered by GitBook
On this page
  • 查询 MFA 状态
  • 更改 MFA 状态

Was this helpful?

  1. 开发资源
  2. SDK for Web

管理 MFA 口令

查询 MFA 状态

Authing.queryMFA(options)

允许用户本人或用户池所有者查看 MFA 的信息。

传参的两种方式:

  1. 通过用户 id 和用户池 id 参数来查询一个用户的 MFA 信息,此时 userId 和 userPoolId 两个参数必填。

  2. 也可以通过 MFA 主体的 id 来查询 MFA 的信息,此时只需传入 _id 参数,userId 和 userPoolId 参数可以不传。

  • 参数:

    • {Object} options

      • _id {String},MFA 主体的 id

      • userPoolId {String},用户池 id

      • userId {String},用户 id

  • 使用方法:

    • (async function() {
        const authing = await new Authing({
          clientId: 'your_client_id',
          timestamp: Math.round(new Date() / 1000),
          nonce: Math.ceil(Math.random() * Math.pow(10, 6)),
        });
        try {
          await authing.queryMFA({
            userId: '用户 id',
            userPoolId: '用户所属用户池 id'
          })
        } catch (err) {
         console.log(err)
        }
      })();
  • 返回数据:

    • {
          "_id": "5d6789aea9ee8e9a77b73521",
          "userId": "5d678970a9ee8e8f75b7350f",
          "userPoolId": "5cbd6716aaaa70cb9a58d86f",
          "shareKey": "NRMFAWTPMZ5FOQZWKNJFS5BXOZXGOV3Z",
          "enable": true
      }

更改 MFA 状态

Authing.changeMFA(options)

只允许用户本人修改自己的 MFA 口令,在使用该方法前需要先使用用户账户登录,或使用用户的 token 进行初始化。

传参的两种方式:

  1. 通过用户 id 和用户池 id 参数来指定一个用户的 MFA 状态,此时 userId 和 userPoolId 两个参数必填。

  2. 也可以通过 MFA 主体的 id 来修改 MFA 的状态,此时只需传入 _id 参数,userId 和 userPoolId 参数可以不传。

  • 参数:

    • {Object} options

      • _id {String},MFA 主体的 id

      • userPoolId {String},用户池 id

      • userId {String},用户 id

      • enable {Boolean},MFA 开启或关闭

      • refreshKey {Boolean},是否刷新 MFA secret

开启用户的 MFA

  • 使用方法:

    • (async function() {
        const authing = await new Authing({
          clientId: 'your_client_id',
          timestamp: Math.round(new Date() / 1000),
          nonce: Math.ceil(Math.random() * Math.pow(10, 6)),
        });
        try {
          // 需要先以用户的身份登录
          await authing.login({
            email: 'test@authing.cn',
            password: 'password'
          });
          // 或者使用用户的 token 初始化
          // authing.initUserClient('用户的 JWT token');
          await authing.changeMFA({
            userId: '用户 id',
            userPoolId: '用户所属用户池 id',
            enable: true,
          })
        } catch (err) {
         console.log(err)
        }
      })();
  • 返回数据:

    • {
          "_id": "5d6789aea9ee8e9a77b73521",
          "userId": "5d678970a9ee8e8f75b7350f",
          "userPoolId": "5cbd6716aaaa70cb9a58d86f",
          "shareKey": "NRMFAWTPMZ5FOQZWKNJFS5BXOZXGOV3Z",
          "enable": true
      }

刷新用户的 MFA secret

  • 使用方法:

    • (async function() {
        const authing = await new Authing({
          clientId: 'your_client_id',
          timestamp: Math.round(new Date() / 1000),
          nonce: Math.ceil(Math.random() * Math.pow(10, 6)),
        });
        try {
          // 需要先以用户的身份登录
          await authing.login({
            email: 'test@authing.cn',
            password: 'password'
          });
          // 或者使用用户的 token 初始化
          // authing.initUserClient('用户的 JWT token');
          await authing.changeMFA({
            userId: '用户 id',
            userPoolId: '用户所属用户池 id',
            enable: true,
            refeshKey: true
          })
        } catch (err) {
         console.log(err)
        }
      })();
  • 返回数据:

    • {
          "_id": "5d6789aea9ee8e9a77b73521", // MFA 主体的 id
          "userId": "5d678970a9ee8e8f75b7350f",
          "userPoolId": "5cbd6716aaaa70cb9a58d86f",
          "shareKey": "JVRWQOLHOJJVOZSOGN4G4OKWNVHXQMSQ", // 新的密钥
          "enable": true
      }

Previous绑定社会化登录Next自定义请求链接

Last updated 5 years ago

Was this helpful?