Authing 文档文档
快速开始
概念
使用指南
开发集成 arrow
  • V2 文档
  • V3 文档
应用集成
加入 APN
开发集成
多租户(内测版)
控制台文档
多租户控制台
租户控制台
Saas 应用 Demo
快速开始
概念
使用指南
开发集成 arrow
  • V2 文档
  • V3 文档
应用集成
加入 APN
开发集成
多租户(内测版)
控制台文档
多租户控制台
租户控制台
Saas 应用 Demo
旧版
使用指南
  • 快速开始

  • 对用户进行认证

    • 使用账号密码认证
    • 使用短信验证码认证
    • 使用社会化登录认证
    • 使用扫码登录认证

    • 在小程序中进行认证
    • 手机号一键登录
    • 实现单点登录(SSO)
    • 在移动端实现单点登录
    • 多因素认证
    • 对认证流程进行扩展

    • 对登录框进行个性化配置
  • 对用户进行权限管理

  • 授权

  • 管理用户账号

  • 管理用户目录

  • 同步中心

  • 应用

  • 成为联邦认证身份源

  • 连接外部身份源(IdP)

  • 微信生态全场景能力

  • 迁移用户到 Authing

  • 管理组织机构

  • 安全设置

  • 品牌化

  • 自动化

  • 审计日志

  • 设置

  • Authing 令牌
  • 私有化部署方案

  • 常见问题 FAQ

  1. 使用指南
  2. /
  3. 对用户进行认证
  4. /
  5. 使用账号密码认证

¶ 使用账号密码认证

更新时间: 2022-11-04 20:07:05
编辑

在 Authing 中,账号密码共分为以下三种形式:

  • 邮箱 + 密码登录
  • 用户名 + 密码登录
  • 手机号 + 密码登录

当为用户提供账号密码形式的认证手段时,作为 IT 系统管理员或者开发者,你还需要实现以下功能:

  • 重置密码:可以通过邮箱验证码或者手机号验证码找回密码。
  • 修改密码:可以通过现有密码重置密码。

要使用 Authing 实现这些功能, 我们提供了三种不同的接入方式:

  1. 使用 Authing 托管登录页,无需一行代码,你可以通过 sample-sso.authing.cn 体验。
  2. 使用 Authing 提供的内嵌登录组件,可以集成到你的 Web 和移动端项目中,你不需要自己实现登录表单 UI。
  3. 使用 API & SDK,Authing 提供 RESTFul 和 GraphQL 两种形式的 API 以及 10 余种语言或框架的 SDK,你可以基于此自定义 UI 和认证流程。

¶ 使用托管登录页

¶ 注册

用户注册成功之后,系统会发送欢迎邮件到用户的邮箱:

你也可以在控制台设置 - 安全信息 - 用户池安全配置 中关闭注册发送欢迎邮件的选项,还可以在控制台设置 - 消息服务中修改默认欢迎邮件的模版。

用户注册成功之后,Authing 会发送验证邮箱邮件到用户的邮箱:

用户点击验证按钮即可验证邮箱。

¶ 登录

默认情况下,未验证邮箱的账号可以进行登录,你也可以在应用详情中修改次配置:

用户登录成功之后,将回调到你配置的回调链接,你可以在此获取用户信息,详情请见 使用 Authing 托管登录页完成认证 。

¶ 重置密码

你可以使用绑定的手机号或邮箱重置密码。

¶ 修改密码

用户可以在个人中心修改自己的密码:

¶ 使用内嵌登录组件

内嵌登录组件和在线托管登录页在样式和交互上基本一致,不同点在于在线托管登录页由 Authing 完全托管运维,与你的应用之间完全独立,而内嵌登录组件则可以嵌入到你的应用中。

详细使用方法请见:使用内嵌登录组件完成认证 。

¶ 使用 API & SDK

¶ 注册

选择语言
Java
Loading...

使用应用 ID(AppID) ,应用密钥(App Secret)和应用 Host(App Host)初始化 Java SDK 的 AuthenticationClient:

如何获取?

import cn.authing.core.auth.AuthenticationClient;
// 使用 AppId, App Secret 和 AppHost 进行初始化
AuthenticationClientOptions options = new AuthenticationClientOptions();
options.setAppId("AUTHING_APP_ID");
options.setAppSecret("AUTHING_APP_SECRET");
options.setAppHost("AUTHING_APP_HOST");
AuthenticationClient authenticationClient = new AuthenticationClient(options);

使用 registerByEmail 方法:

String email = "test@example.com";
String password = "123456";
User user = authenticationClient.registerByEmail(new RegisterByEmailInput(email, password)).execute();

¶ 登录

选择语言
Java
Loading...

使用应用 ID(AppID) ,应用密钥(App Secret)和应用 Host(App Host)初始化 Java SDK 的 AuthenticationClient:

如何获取?

import cn.authing.core.auth.AuthenticationClient;
// 使用 AppId, App Secret 和 AppHost 进行初始化
AuthenticationClientOptions options = new AuthenticationClientOptions();
options.setAppId("AUTHING_APP_ID");
options.setAppSecret("AUTHING_APP_SECRET");
options.setAppHost("AUTHING_APP_HOST");
AuthenticationClient authenticationClient = new AuthenticationClient(options);

使用 loginByEmail 方法:

String email = "test@example.com";
String password = "123456";
User user = authenticationClient.loginByEmail(new LoginByEmailInput(email, password)).execute();

¶ 重置密码

选择语言
Java
Loading...

使用应用 ID(AppID) ,应用密钥(App Secret)和应用 Host(App Host)初始化 Java SDK 的 AuthenticationClient:

如何获取?

import cn.authing.core.auth.AuthenticationClient;
// 使用 AppId, App Secret 和 AppHost 进行初始化
AuthenticationClientOptions options = new AuthenticationClientOptions();
options.setAppId("AUTHING_APP_ID");
options.setAppSecret("AUTHING_APP_SECRET");
options.setAppHost("AUTHING_APP_HOST");
AuthenticationClient authenticationClient = new AuthenticationClient(options);

使用手机号验证码重置密码:

String phone = "phone number";
String code = "1234";
String password = "123456";
authenticationClient.resetPasswordByPhoneCode(phone, code, password).execute();

使用邮箱验证码重置密码:

String email = "test@example.com";
String code = "1234";
String password = "123456";
authenticationClient.resetPasswordByEmailCode(email, code, password).execute();

¶ 修改密码

选择语言
Java
Loading...

使用应用 ID(AppID) ,应用密钥(App Secret)和应用 Host(App Host)初始化 Java SDK 的 AuthenticationClient:

如何获取?

import cn.authing.core.auth.AuthenticationClient;
// 使用 AppId, App Secret 和 AppHost 进行初始化
AuthenticationClientOptions options = new AuthenticationClientOptions();
options.setAppId("AUTHING_APP_ID");
options.setAppSecret("AUTHING_APP_SECRET");
options.setAppHost("AUTHING_APP_HOST");
AuthenticationClient authenticationClient = new AuthenticationClient(options);

如果用户之前没有设置过密码(比如由手机号、社会化登录等方式注册),不需要传入原始密码。

String newPassword = "123456";
User user = authenticationClient.updatePassword(newPassword).execute();

或者:

String oldPassword = "111111";
String newPassword = "123456";
User user = authenticationClient.updatePassword(newPassword, oldPassword).execute();
上一篇: 对用户进行认证 下一篇: 使用短信验证码认证
  • 使用托管登录页
  • 使用内嵌登录组件
  • 使用 API & SDK

用户身份管理

集成第三方登录
手机号闪验 (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号

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