gpt4 book ai didi

c# - 声明类型中的 URL 是什么

转载 作者:太空狗 更新时间:2023-10-29 21:37:49 24 4
gpt4 key购买 nike

因为我想在我的应用程序中添加自定义声明,所以我检查了 ClaimTypes 的源代码(使用 JetBrains 反编译器反编译)。这是它的一部分:

namespace System.Security.Claims
{
/// <summary>Defines constants for the well-known claim types that can be assigned to a subject. This class cannot be inherited.</summary>
[ComVisible(false)]
public static class ClaimTypes
{
internal const string ClaimTypeNamespace = "http://schemas.microsoft.com/ws/2008/06/identity/claims";
/// <summary>The URI for a claim that specifies the instant at which an entity was authenticated; http://schemas.microsoft.com/ws/2008/06/identity/claims/authenticationinstant.</summary>
public const string AuthenticationInstant = "http://schemas.microsoft.com/ws/2008/06/identity/claims/authenticationinstant";
/// <summary>The URI for a claim that specifies the method with which an entity was authenticated; http://schemas.microsoft.com/ws/2008/06/identity/claims/authenticationmethod.</summary>
public const string AuthenticationMethod = "http://schemas.microsoft.com/ws/2008/06/identity/claims/authenticationmethod";
/// <summary>The URI for a claim that specifies the cookie path; http://schemas.microsoft.com/ws/2008/06/identity/claims/cookiepath.</summary>
public const string CookiePath = "http://schemas.microsoft.com/ws/2008/06/identity/claims/cookiepath";
/// <summary>The URI for a claim that specifies the deny-only primary SID on an entity; http://schemas.microsoft.com/ws/2008/06/identity/claims/denyonlyprimarysid. A deny-only SID denies the specified entity to a securable object.</summary>
public const string DenyOnlyPrimarySid = "http://schemas.microsoft.com/ws/2008/06/identity/claims/denyonlyprimarysid";
/// <summary>The URI for a claim that specifies the deny-only primary group SID on an entity; http://schemas.microsoft.com/ws/2008/06/identity/claims/denyonlyprimarygroupsid. A deny-only SID denies the specified entity to a securable object.</summary>
public const string DenyOnlyPrimaryGroupSid = "http://schemas.microsoft.com/ws/2008/06/identity/claims/denyonlyprimarygroupsid";

我的问题是(我希望这不是太傻),URL 的用途是什么?它们在其他地方使用过吗?当我尝试打开一个 URL 时,我的资源管理器说找不到该站点。所以我认为没有 xml-schema 或背后的东西。如果我添加自定义声明,是否也必须添加类似这些 URL 的内容?

最佳答案

这些是 ClaimTypes,表示实体可以声明的预定义声明类型。你说的那些来自WIF , 这里是 IdentityModel claim 类型。

已知的声明类型会自动反序列化到上下文中。像 http://schemas.microsoft.com/ws/2008/06/identity/claims/role 作为角色添加到 user.roles 集合(用于 IsInRole)。

所以类型不是随机的,而是按规范。您可以添加自己的类型。这可以是任何字符串,但您也可以使用相同的格式。

假设您添加一个 CustomerId 作为声明,那么您需要通过 claimtype="CustomerId" 或您定义的 uri(如 http://schemas.mycompany.com/2017/06/identity/CustomerId).

您可以通过代码或在 Identity.Claims 表中插入记录来添加声明。

关于c# - 声明类型中的 URL 是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44301737/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com