private ClaimsIdentity BuildIdentity(CasAuthenticationOptions options, string username, XElement successNode) { var identity = new ClaimsIdentity(options.AuthenticationType, options.NameClaimType, ClaimTypes.Role); identity.AddClaim(new Claim(ClaimTypes.Name, username, "http://www.w3.org/2001/XMLSchema#string", options.AuthenticationType)); var attributesNode = successNode.Element(_ns + "attributes"); if (attributesNode != null) { foreach (var element in attributesNode.Elements()) { identity.AddClaim(new Claim(element.Name.LocalName, element.Value)); } } string identityValue = username; if (options.NameIdentifierAttribute != null && attributesNode != null) { var identityAttribute = attributesNode.Elements().FirstOrDefault(x => x.Name.LocalName == options.NameIdentifierAttribute); if (identityAttribute == null) { throw new ApplicationException(string.Format("Identity attribute [{0}] not found for user: {1}", options.NameIdentifierAttribute, username)); } identityValue = identityAttribute.Value; } identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, identityValue, "http://www.w3.org/2001/XMLSchema#string", options.AuthenticationType)); return(identity); }
/// <summary> /// Authenticate users using Cas /// </summary> /// <param name="app">The <see cref="IAppBuilder"/> passed to the configuration method</param> /// <param name="options">Middleware configuration options</param> /// <returns>The updated <see cref="IAppBuilder"/></returns> public static IAppBuilder UseCasAuthentication(this IAppBuilder app, CasAuthenticationOptions options) { if (app == null) { throw new ArgumentNullException("app"); } if (options == null) { throw new ArgumentNullException("options"); } app.Use(typeof(CasAuthenticationMiddleware), app, options); return(app); }
public CasSignOutHandler(CasAuthenticationOptions options) { _options = options; }
public Cas1ValidateTicketValidator(CasAuthenticationOptions options) { _options = options; }