简体   繁体   English

在本地数据库中存储 OAuth 用户信息(用户名、名字、姓氏等)

[英]Storing OAuth user info (username, first_name, last_name etc) in local database

I recently implemented Oauth 2.0 (FusionAuth) into my Flask API.我最近在我的 Flask API 中实现了 Oauth 2.0 (FusionAuth)。 Because of the way that I implemented OAuth, I have two separate databases, one for the OAuth server and the other for the Flask API.由于我实现 OAuth 的方式,我有两个独立的数据库,一个用于 OAuth 服务器,另一个用于 FlaskA16742318708ZADB9742318704

Based on this I am wondering what is considered best practice.基于此,我想知道什么被认为是最佳实践。 Should I make calls to the Oauth server every time I need to grab a users info such as username, first_name, last_name etc. or should I store this information in my Flask API database to limit the load on the auth server.每次我需要获取用户名、名字、姓氏等用户信息时,我应该调用 Oauth 服务器,还是应该将此信息存储在我的 Flask ZDB974238714CA8DE634A7CE1D083A 数据库中。

If I were to go with option one, my auth server would have increased load because my API is heavily dependent on user info as it is being used as part of a social media platform.如果我使用选项一访问 go,我的身份验证服务器会增加负载,因为我的 API 严重依赖用户信息,因为它被用作社交媒体平台的一部分。

If I go with option two, I reduce the load on the auth server, but I would have to update two different databases if a user were to change their first_name or last_name (rarely happens).如果我使用选项二 go,我会减少身份验证服务器上的负载,但如果用户要更改他们的 first_name 或 last_name(很少发生),我将不得不更新两个不同的数据库。

USER DATA DESIGN用户数据设计

Typically you need a small amount of user info in the Authorization Server, namely these fields:通常,您需要在授权服务器中提供少量用户信息,即这些字段:

  • Given Name给定的名称
  • Family Name
  • Email Email

All other user data is best stored in the Application / Product, where it is easier to change and you can easily do SQL queries on it.所有其他用户数据最好存储在应用程序/产品中,它更容易更改,您可以轻松地对其进行 SQL 查询。

The above OAuth fields in effect become read only in your product schema.上述 OAuth 字段实际上在您的产品架构中变为只读。 When they change in the Authorization Server you need to update your product data.当它们在授权服务器中发生变化时,您需要更新您的产品数据。

MATCHING OAUTH USER DATA TO PRODUCT USER DATA将 OAUTH 用户数据与产品用户数据匹配

This can be done after login in your API by matching the token's sub claim or the User Info's email claim to your Product User Data.这可以在登录 API 后通过将令牌的子声明或用户信息的 email 声明与您的产品用户数据相匹配来完成。 If there are changes then keep the Product User Data.如果有更改,则保留产品用户数据。 This process can involve the API calling the User Info endpoint.此过程可能涉及调用用户信息端点的 API。

RESOURCES OF MINE我的资源

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 通过First_Name和/或Last_Name查询sql表 - query sql table By First_Name and/or Last_Name 编译时:INSERT或IGNORE INTO联系人(姓,名,用户名,电话号码) - while compiling: INSERT OR IGNORE INTO contacts(last_name, first_name, user_id, phoneno) 如有空格,如何将NAME分为3个不同的字段FIRST_NAME,MIDDLE_NAME和LAST_NAME - How to split NAME into 3 different fields FIRST_NAME, MIDDLE_NAME & LAST_NAME when there is a space 具有名称,名字和姓氏的PostgreSQL多表查询 - PostgreSQL multi-table query with name, first_name, and last_name 如何使用sql查询组合first_name和last_name? - How to combined first_name and last_name using sql query? 使用 Reg_exp 从电子邮件预言机中提取名字和姓氏 - Extracting First_name & Last_name from email oracle using Reg_exp 表示 Last_Name + First_Name 有一个具有特定值的记录 - Indicate a Last_Name + First_Name has one record with specific value 将 first_name 和 last_name 列中的名称截断为 1 个字符的最有效方法是什么? - What's the most efficient way of truncating the names in a first_name and last_name column to 1 character? 查询以使用外键获取行值(first_name 和 last_name) - Query to fetch row values (first_name & last_name) using foreign key 在Ruby on Rails 3中合并first_name和last_name列的最佳方法? - Best way to combine first_name and last_name columns in Ruby on Rails 3?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM