声明类型中的网址是什么 [英] what are the URLs for in claim-types

查看:112
本文介绍了声明类型中的网址是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于我想向应用程序中添加自定义声明,因此我检查了ClaimTypes的源代码(使用JetBrains反编译器反编译).这是其中的一部分:

Since I want to add custom claims into my application, I checked the sourcecode of ClaimTypes (decompiled with JetBrains decompiler). Here is a piece of it:

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模式或背后的东西. 如果我添加了自定义声明,是否也需要添加类似这些URL的内容?

My question is (and I hope, it's not too silly), what are the URLs for? Are they used somewhere else? When I try to open an URL, my explorer says that the site wasn't found. So I think there is no xml-schema or something behind. If I add my custom claims, do I have to add something like those URLs too?

推荐答案

这些是ClaimTypes,它表示实体可以声明的声明的预定义类型.您提到的内容来自 WIF ,这是 IdentityModel ClaimTypes.

These are ClaimTypes, which represents the pre-defined types of claims that an entity can claim. The ones you mention are from WIF, here are the IdentityModel ClaimTypes.

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

Known claimtypes are automatically deserialized into the context. Like http://schemas.microsoft.com/ws/2008/06/identity/claims/role is added as role to the user.roles collection (used for IsInRole).

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

So the types are not random, but by specification. You can add your own types. This can be any string, but you can also use the same format.

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

Suppose you add a CustomerId as claim, then you'll need to query the Claims collection by claimtype="CustomerId", or the uri you defined (like http://schemas.mycompany.com/2017/06/identity/CustomerId).

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

You can add claims by code, or by inserting records in the Identity.Claims tables.

这篇关于声明类型中的网址是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆