2017-06-01 7 views
2

私のアプリケーションにカスタムクレームを追加したいので、(JetBrainsデコンパイラで逆コンパイルされた)ClaimTypesのソースコードをチェックしました。ここにその一部があります:クレームタイプのURLは何ですか

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も追加する必要がありますか?

答えて

2

これらはClaimTypesであり、エンティティが要求できる事前定義された種類のクレームを表します。あなたが言及したものはWIFです。ここにはIdentityModel ClaimTypesがあります。

既知のクレームタイプは自動的にコンテキストに逆シリアル化されます。 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テーブルにレコードを挿入することもできます。

+1

「http://schemas.mycompany ...」を意味しましたか? – xr280xr

関連する問題