# 游戏开发 - 用户注册和数据库管理（需要建议)

**URL:** <https://meta.discourse.org/t/game-dev-user-registration-db-management-advice-needed/308874>\
**Category:** SSO\
**Created:** [2024年五月21日 13:59 UTC](https://meta.discourse.org/t/game-dev-user-registration-db-management-advice-needed/308874 "2024-05-21T13:59:25Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![renato](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/renato/32/383632_2.png) [@renato](https://meta.discourse.org/u/renato)\
**Post date:** [2024年五月21日 15:52 UTC](https://meta.discourse.org/t/game-dev-user-registration-db-management-advice-needed/308874/5 "2024-05-21T15:52:43Z")

</div>

当您使用 Discourse 作为身份提供者（正如 Richard 所建议的）时，Discourse 会为您处理电子邮件验证。

当用户在 Discourse 上完成 SSO 流程然后返回到您的网站时，您可以使用 Discourse 添加的响应，该响应作为嵌入式查询字符串附加到 `sso` 参数中，其中包含电子邮件、用户名、姓名、用户组等（但不是密码，那 **不** 是好主意），您可以提取并使用提供的 `sig` 正确验证。

> [@techAPJ](#):
>
> ## 从 Discourse 获取响应：
> 
> 如果上述步骤正确完成，Discourse 将把已登录的用户重定向到提供的 `RETURN_URL`。您将收到带有 `sig` 和 `sso` 以及一些用户信息查询字符串参数。现在请按照以下步骤操作：
> 
> - 使用 sso 提供者密钥作为您的密钥，计算 `sso` 的 HMAC-SHA256。
> - 将 `sig` 从其十六进制字符串表示形式转换回字节。
> - 确保上述两个值相等。
> - Base64 解码 `sso`；您将获得传递的嵌入式查询字符串。其中将有一个名为 `nonce` 的键，其值应与最初传递的 nonce 匹配。请确保情况确实如此，并务必从系统中删除 nonce。
> - 您会发现此查询字符串还将包含大量用户信息。根据需要使用。

---

_[View the full topic](https://meta.discourse.org/t/game-dev-user-registration-db-management-advice-needed/308874)._
