2017-06-01 1 views
2

Puisque je veux ajouter des revendications personnalisées dans mon application, j'ai vérifié le code source de ClaimTypes (décompilé avec JetBrains decompiler). Voici un morceau:Quelles sont les URL pour les types de revendications

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"; 

Ma question est (et je l'espère, ce n'est pas trop bête), quelles sont les URL? Sont-ils utilisés ailleurs? Lorsque j'essaie d'ouvrir une URL, mon explorateur dit que le site n'a pas été trouvé. Donc, je pense qu'il n'y a pas de schéma XML ou quelque chose derrière. Si j'ajoute mes revendications personnalisées, dois-je ajouter quelque chose comme ces URL?

Répondre

2

Il s'agit de ClaimTypes, qui représentent les types de revendications prédéfinis qu'une entité peut revendiquer. Ceux que vous mentionnez sont de WIF, voici le IdentityModel ClaimTypes.

Les types de revendication connus sont automatiquement désérialisés dans le contexte. Comme http://schemas.microsoft.com/ws/2008/06/identity/claims/role est ajouté en tant que rôle à la collection user.roles (utilisée pour IsInRole). Donc, les types ne sont pas aléatoires, mais par spécification. Vous pouvez ajouter vos propres types. Cela peut être n'importe quelle chaîne, mais vous pouvez également utiliser le même format.

Supposons que vous ajoutez un CustomerId comme réclamation, vous devrez interroger la collection par les revendications claimtype="CustomerId", ou uri que vous avez défini (comme http://schemas/mycompany.com/2017/06/identity/CustomerId).

Vous pouvez ajouter des revendications par code ou en insérant des enregistrements dans les tables Identity.Claims.

+1

Voulez-vous dire 'http: //schemas.mycompany ...'? – xr280xr