【发布时间】:2023-03-26 04:04:01
【问题描述】:
我在 docer 中使用 Keycloak 并托管在 https://accounts.example.com。
我使用 React 作为我的客户端库,登录后,用户进入 https://user.example.com。
此 React 客户端使用位于 https://api.user.example.com 的 .NET Core API。
我使用keycloak.js 来管理 React 面板中的访问。
现在假设用户想要创建一张票。我将此票信息发送到 API:
{
title: 'Urgent backup',
priority: 'urgent',
description: 'Please backup my files immediately'
}
在我们的数据库中,我们有这样的设计:
create table Tickets
(
Id bigint not null primary identity(1, 1),
UserGuid uniqueidentifier not null, -- How should I fill this column?
Title nvarchar(200) not null,
PriorityId int not null,
Description nvarchar(max) not null
)
问题是,API 应该从用户那里提取永久数据。
我当然不能在该列中存储email 或username。我什至不能依赖 username 或 email 因为 Keycloak 的管理面板允许配置此设置:
因此,最好的选择是在 Keycloak 中给用户一个 GUID 或 UUID,并在 open id 令牌中检索它。
我搜索过,但找不到如何执行此操作。
你能帮忙吗?
【问题讨论】:
标签: reactjs .net-core keycloak