XMLDoc updates.

This commit is contained in:
Barry Dorrans 2015-01-07 12:28:35 -08:00
parent cf68fac658
commit e76d1c2809
3 changed files with 62 additions and 14 deletions

View File

@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
using Microsoft.AspNet.Identity; using Microsoft.AspNet.Identity;
namespace Microsoft.AspNet.Builder namespace Microsoft.AspNet.Builder

View File

@ -5,19 +5,29 @@ using System;
using System.Security.Claims; using System.Security.Claims;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.Framework.OptionsModel; using Microsoft.Framework.OptionsModel;
namespace Microsoft.AspNet.Identity namespace Microsoft.AspNet.Identity
{ {
/// <summary> /// <summary>
/// Creates a ClaimsIdentity from a User /// Provides methods to create a claims identity for a given user.
/// </summary> /// </summary>
/// <typeparam name="TUser"></typeparam> /// <typeparam name="TUser">The type used to represent a user.</typeparam>
/// <typeparam name="TRole">The type used to represent a role.</typeparam>
public class ClaimsIdentityFactory<TUser, TRole> : IClaimsIdentityFactory<TUser> public class ClaimsIdentityFactory<TUser, TRole> : IClaimsIdentityFactory<TUser>
where TUser : class where TUser : class
where TRole : class where TRole : class
{ {
public ClaimsIdentityFactory(UserManager<TUser> userManager, RoleManager<TRole> roleManager, /// <summary>
/// Initializes a new instance of the <see cref="ClaimsIdentityFactory"/> class.
/// </summary>
/// <param name="userManager">The <see cref="UserManager{TUser}"/> to retrieve user information from.</param>
/// <param name="roleManager">The <see cref="RoleManager{TRole}"/> to retrieve a user's roles from.</param>
/// <param name="optionsAccessor">The configured <see cref="IdentityOptions"/>.</param>
public ClaimsIdentityFactory(
UserManager<TUser> userManager,
RoleManager<TRole> roleManager,
IOptions<IdentityOptions> optionsAccessor) IOptions<IdentityOptions> optionsAccessor)
{ {
if (userManager == null) if (userManager == null)
@ -37,19 +47,38 @@ namespace Microsoft.AspNet.Identity
Options = optionsAccessor.Options; Options = optionsAccessor.Options;
} }
/// <summary>
/// Gets the <see cref="UserManager{TUser}"/> for this factory.
/// </summary>
/// <value>
/// The current <see cref="UserManager{TUser}"/> for this factory instance.
/// </value>
public UserManager<TUser> UserManager { get; private set; } public UserManager<TUser> UserManager { get; private set; }
/// <summary>
/// Gets the <see cref="RoleManager{TRole}"/> for this factory.
/// </summary>
/// <value>
/// The current <see cref="RoleManager{TRole}"/> for this factory instance.
/// </value>
public RoleManager<TRole> RoleManager { get; private set; } public RoleManager<TRole> RoleManager { get; private set; }
/// <summary>
/// Gets the <see cref="IdentityOptions"/> for this factory.
/// </summary>
/// <value>
/// The current <see cref="IdentityOptions"/> for this factory instance.
/// </value>
public IdentityOptions Options { get; private set; } public IdentityOptions Options { get; private set; }
/// <summary> /// <summary>
/// CreateAsync a ClaimsIdentity from a user /// Creates a populated <see cref="ClaimsIdentity"/> for the specified <paramref name="user"/>.
/// </summary> /// </summary>
/// <param name="manager"></param> /// <param name="user">The user instance to create claims on.</param>
/// <param name="user"></param> /// <param name="cancellationToken">A <see cref="CancellationToken"/> to observe while waiting for the tasks to complete.</param>
/// <param name="authenticationType"></param> /// <returns>A <see cref="Task{TResult}"/> that represents the started task.</returns>
/// <param name="cancellationToken"></param> public virtual async Task<ClaimsIdentity> CreateAsync(
/// <returns></returns> TUser user,
public virtual async Task<ClaimsIdentity> CreateAsync(TUser user,
CancellationToken cancellationToken = default(CancellationToken)) CancellationToken cancellationToken = default(CancellationToken))
{ {
if (user == null) if (user == null)

View File

@ -5,28 +5,46 @@ using System.Security.Claims;
namespace Microsoft.AspNet.Identity namespace Microsoft.AspNet.Identity
{ {
/// <summary>
/// Options for ClaimType names.
/// </summary>
public class ClaimsIdentityOptions public class ClaimsIdentityOptions
{ {
/// <summary>
/// The ClaimType used for the identity security stamp.
/// </summary>
public static readonly string DefaultSecurityStampClaimType = "AspNet.Identity.SecurityStamp"; public static readonly string DefaultSecurityStampClaimType = "AspNet.Identity.SecurityStamp";
/// <summary> /// <summary>
/// Claim type used for role claims /// Gets the ClaimType used for a Role claim.
/// </summary> /// </summary>
/// <remarks>
/// This defaults to <see cref="ClaimTypes.Role"/>.
/// </remarks>
public string RoleClaimType { get; set; } = ClaimTypes.Role; public string RoleClaimType { get; set; } = ClaimTypes.Role;
/// <summary> /// <summary>
/// Claim type used for the user name /// Gets the ClaimType used for the user name claim.
/// </summary> /// </summary>
/// <remarks>
/// This defaults to <see cref="ClaimTypes.Name"/>.
/// </remarks>
public string UserNameClaimType { get; set; } = ClaimTypes.Name; public string UserNameClaimType { get; set; } = ClaimTypes.Name;
/// <summary> /// <summary>
/// Claim type used for the user id /// Gets the ClaimType used for the user identifier claim.
/// </summary> /// </summary>
/// <remarks>
/// This defaults to <see cref="ClaimTypes.NameIdentifier"/>.
/// </remarks>
public string UserIdClaimType { get; set; } = ClaimTypes.NameIdentifier; public string UserIdClaimType { get; set; } = ClaimTypes.NameIdentifier;
/// <summary> /// <summary>
/// Claim type used for the user security stamp /// Gets the ClaimType used for the security stamp claim..
/// </summary> /// </summary>
/// <remarks>
/// This defaults to "AspNet.Identity.SecurityStamp".
/// </remarks>
public string SecurityStampClaimType { get; set; } = DefaultSecurityStampClaimType; public string SecurityStampClaimType { get; set; } = DefaultSecurityStampClaimType;
} }
} }