├── samples └── Sample-AspNet5.Mvc6.Ntlm │ ├── .bowerrc │ ├── wwwroot │ ├── js │ │ └── site.js │ ├── favicon.ico │ ├── images │ │ ├── Banner-02-VS.png │ │ ├── Banner-01-Azure.png │ │ ├── ASP-NET-Banners-01.png │ │ └── ASP-NET-Banners-02.png │ ├── lib │ │ ├── bootstrap │ │ │ ├── dist │ │ │ │ ├── fonts │ │ │ │ │ ├── glyphicons-halflings-regular.eot │ │ │ │ │ ├── glyphicons-halflings-regular.ttf │ │ │ │ │ ├── glyphicons-halflings-regular.woff │ │ │ │ │ └── glyphicons-halflings-regular.woff2 │ │ │ │ ├── js │ │ │ │ │ └── npm.js │ │ │ │ └── css │ │ │ │ │ └── bootstrap-theme.min.css │ │ │ ├── .bower.json │ │ │ └── LICENSE │ │ ├── jquery │ │ │ ├── .bower.json │ │ │ └── MIT-LICENSE.txt │ │ ├── jquery-validation │ │ │ ├── .bower.json │ │ │ ├── LICENSE.md │ │ │ └── dist │ │ │ │ ├── additional-methods.min.js │ │ │ │ └── jquery.validate.min.js │ │ └── jquery-validation-unobtrusive │ │ │ ├── .bower.json │ │ │ ├── jquery.validate.unobtrusive.min.js │ │ │ └── jquery.validate.unobtrusive.js │ ├── _references.js │ ├── web.config │ └── css │ │ └── site.css │ ├── Views │ ├── _ViewStart.cshtml │ ├── _ViewImports.cshtml │ ├── Home │ │ ├── About.cshtml │ │ ├── Contact.cshtml │ │ └── Index.cshtml │ └── Shared │ │ ├── Error.cshtml │ │ └── _Layout.cshtml │ ├── appsettings.json │ ├── bower.json │ ├── package.json │ ├── Properties │ └── launchSettings.json │ ├── Controllers │ └── HomeController.cs │ ├── gulpfile.js │ ├── Sample-AspNet5.Mvc6.Ntlm.xproj │ ├── project.json │ ├── Startup.cs │ └── Project_Readme.html ├── global.json ├── NuGet.config ├── src └── Microsoft.AspNetCore.Authentication.ActiveDirectory │ ├── Events │ ├── AuthenticationFailedContext.cs │ ├── AuthenticationSucceededContext.cs │ ├── IAuthenticationEvents.cs │ ├── BaseActiveDirectoryContext.cs │ └── AuthenticationEvents.cs │ ├── Constants.cs │ ├── Properties │ └── AssemblyInfo.cs │ ├── project.json │ ├── Microsoft.AspNetCore.Authentication.ActiveDirectory.xproj │ ├── Enums.cs │ ├── WindowsAuthenticationController.cs │ ├── ActiveDirectoryExtensions.cs │ ├── ActiveDirectoryCookieOptions.cs │ ├── ActiveDirectoryMiddleware.cs │ ├── Interop.cs │ ├── ActiveDirectoryOptions.cs │ ├── AuthenticationStateCache.cs │ ├── HandshakeState.cs │ ├── Structures.cs │ └── NtlmAuthenticationHandler.cs ├── appveyor.yml ├── Middleware.ActiveDirectory.sln ├── .gitignore ├── README.md └── LICENSE /samples/Sample-AspNet5.Mvc6.Ntlm/.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "wwwroot/lib" 3 | } 4 | -------------------------------------------------------------------------------- /samples/Sample-AspNet5.Mvc6.Ntlm/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Write your Javascript code. 2 | -------------------------------------------------------------------------------- /samples/Sample-AspNet5.Mvc6.Ntlm/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /global.json: -------------------------------------------------------------------------------- 1 | { 2 | "projects": [ "src" ], 3 | "sdk": { 4 | "version": "1.0.0-preview2-003121" 5 | } 6 | } -------------------------------------------------------------------------------- /samples/Sample-AspNet5.Mvc6.Ntlm/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using Sample_AspNet5.Mvc6.Ntlm 2 | @addTagHelper "*, Microsoft.AspNetCore.Mvc.TagHelpers" 3 | -------------------------------------------------------------------------------- /samples/Sample-AspNet5.Mvc6.Ntlm/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneBitSoftware/Microsoft.AspNetCore.Authentication.ActiveDirectory/HEAD/samples/Sample-AspNet5.Mvc6.Ntlm/wwwroot/favicon.ico -------------------------------------------------------------------------------- /samples/Sample-AspNet5.Mvc6.Ntlm/wwwroot/images/Banner-02-VS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneBitSoftware/Microsoft.AspNetCore.Authentication.ActiveDirectory/HEAD/samples/Sample-AspNet5.Mvc6.Ntlm/wwwroot/images/Banner-02-VS.png -------------------------------------------------------------------------------- /samples/Sample-AspNet5.Mvc6.Ntlm/Views/Home/About.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "About"; 3 | } 4 |

@ViewData["Title"].

5 |

@ViewData["Message"]

6 | 7 |

Use this area to provide additional information.

8 | -------------------------------------------------------------------------------- /samples/Sample-AspNet5.Mvc6.Ntlm/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Error"; 3 | } 4 | 5 |

Error.

6 |

An error occurred while processing your request.

7 | -------------------------------------------------------------------------------- /samples/Sample-AspNet5.Mvc6.Ntlm/wwwroot/images/Banner-01-Azure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneBitSoftware/Microsoft.AspNetCore.Authentication.ActiveDirectory/HEAD/samples/Sample-AspNet5.Mvc6.Ntlm/wwwroot/images/Banner-01-Azure.png -------------------------------------------------------------------------------- /samples/Sample-AspNet5.Mvc6.Ntlm/wwwroot/images/ASP-NET-Banners-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneBitSoftware/Microsoft.AspNetCore.Authentication.ActiveDirectory/HEAD/samples/Sample-AspNet5.Mvc6.Ntlm/wwwroot/images/ASP-NET-Banners-01.png -------------------------------------------------------------------------------- /samples/Sample-AspNet5.Mvc6.Ntlm/wwwroot/images/ASP-NET-Banners-02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneBitSoftware/Microsoft.AspNetCore.Authentication.ActiveDirectory/HEAD/samples/Sample-AspNet5.Mvc6.Ntlm/wwwroot/images/ASP-NET-Banners-02.png -------------------------------------------------------------------------------- /samples/Sample-AspNet5.Mvc6.Ntlm/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "IncludeScopes": false, 4 | "LogLevel": { 5 | "Default": "Verbose", 6 | "System": "Information", 7 | "Microsoft": "Information" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /samples/Sample-AspNet5.Mvc6.Ntlm/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ASP.NET", 3 | "private": true, 4 | "dependencies": { 5 | "bootstrap": "3.3.5", 6 | "jquery": "2.1.4", 7 | "jquery-validation": "1.14.0", 8 | "jquery-validation-unobtrusive": "3.2.4" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /samples/Sample-AspNet5.Mvc6.Ntlm/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneBitSoftware/Microsoft.AspNetCore.Authentication.ActiveDirectory/HEAD/samples/Sample-AspNet5.Mvc6.Ntlm/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /samples/Sample-AspNet5.Mvc6.Ntlm/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneBitSoftware/Microsoft.AspNetCore.Authentication.ActiveDirectory/HEAD/samples/Sample-AspNet5.Mvc6.Ntlm/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /samples/Sample-AspNet5.Mvc6.Ntlm/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ASP.NET", 3 | "version": "0.0.0", 4 | "devDependencies": { 5 | "gulp": "3.8.11", 6 | "gulp-concat": "2.5.2", 7 | "gulp-cssmin": "0.1.7", 8 | "gulp-uglify": "1.2.0", 9 | "rimraf": "2.2.8" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /samples/Sample-AspNet5.Mvc6.Ntlm/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneBitSoftware/Microsoft.AspNetCore.Authentication.ActiveDirectory/HEAD/samples/Sample-AspNet5.Mvc6.Ntlm/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /samples/Sample-AspNet5.Mvc6.Ntlm/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneBitSoftware/Microsoft.AspNetCore.Authentication.ActiveDirectory/HEAD/samples/Sample-AspNet5.Mvc6.Ntlm/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /NuGet.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /samples/Sample-AspNet5.Mvc6.Ntlm/wwwroot/_references.js: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | /// 4 | /// 5 | /// 6 | /// 7 | /// 8 | -------------------------------------------------------------------------------- /samples/Sample-AspNet5.Mvc6.Ntlm/wwwroot/web.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/Microsoft.AspNetCore.Authentication.ActiveDirectory/Events/AuthenticationFailedContext.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.AspNetCore.Authentication.ActiveDirectory.Events 2 | { 3 | using Microsoft.AspNetCore.Http; 4 | 5 | public class AuthenticationFailedContext : BaseActiveDirectoryContext 6 | { 7 | public AuthenticationFailedContext(HttpContext context, ActiveDirectoryOptions options) 8 | : base(context, options) 9 | { 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/Microsoft.AspNetCore.Authentication.ActiveDirectory/Events/AuthenticationSucceededContext.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.AspNetCore.Authentication.ActiveDirectory.Events 2 | { 3 | using AspNetCore.Authentication; 4 | using Microsoft.AspNetCore.Http; 5 | 6 | public class AuthenticationSucceededContext : BaseActiveDirectoryContext 7 | { 8 | public AuthenticationSucceededContext(HttpContext context, ActiveDirectoryOptions options) 9 | : base(context, options) 10 | { 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /samples/Sample-AspNet5.Mvc6.Ntlm/Views/Home/Contact.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Contact"; 3 | } 4 |

@ViewData["Title"].

5 |

@ViewData["Message"]

6 | 7 |
8 | One Microsoft Way
9 | Redmond, WA 98052-6399
10 | P: 11 | 425.555.0100 12 |
13 | 14 |
15 | Support: Support@example.com
16 | Marketing: Marketing@example.com 17 |
18 | -------------------------------------------------------------------------------- /samples/Sample-AspNet5.Mvc6.Ntlm/wwwroot/lib/bootstrap/dist/js/npm.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment. 2 | require('../../js/transition.js') 3 | require('../../js/alert.js') 4 | require('../../js/button.js') 5 | require('../../js/carousel.js') 6 | require('../../js/collapse.js') 7 | require('../../js/dropdown.js') 8 | require('../../js/modal.js') 9 | require('../../js/tooltip.js') 10 | require('../../js/popover.js') 11 | require('../../js/scrollspy.js') 12 | require('../../js/tab.js') 13 | require('../../js/affix.js') -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | nuget: 2 | account_feed: true 3 | 4 | init: 5 | - git config --global core.autocrlf true 6 | 7 | branches: 8 | only: 9 | - master 10 | - release 11 | - dev 12 | - /^(.*\/)?ci-.*$/ 13 | 14 | build_script: 15 | - build.cmd verify 16 | 17 | after_build: 18 | - ps: Get-ChildItem .\*.nupkg | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name } 19 | 20 | artifacts: 21 | - path: '**\Microsoft.AspNetCore.Authentication.ActiveDirectory*.nupkg' 22 | 23 | clone_depth: 1 24 | 25 | deploy: 26 | provider: NuGet 27 | api_key: 28 | secure: 3Riwgut3XJ2XobdaMb7/phU0SNVj/SwDfkY6F0TSqXsnpcdIzZc+s+yK/XjHu+8L 29 | skip_symbols: false -------------------------------------------------------------------------------- /samples/Sample-AspNet5.Mvc6.Ntlm/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": true, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:6286/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "web": { 19 | "commandName": "web", 20 | "environmentVariables": { 21 | "ASPNETCORE_ENVIRONMENT": "Development" 22 | } 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /samples/Sample-AspNet5.Mvc6.Ntlm/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding-top: 50px; 3 | padding-bottom: 20px; 4 | } 5 | 6 | /* Wrapping element */ 7 | /* Set some basic padding to keep content from hitting the edges */ 8 | .body-content { 9 | padding-left: 15px; 10 | padding-right: 15px; 11 | } 12 | 13 | /* Set widths on the form inputs since otherwise they're 100% wide */ 14 | input, 15 | select, 16 | textarea { 17 | max-width: 280px; 18 | } 19 | 20 | /* Carousel */ 21 | .carousel-caption { 22 | z-index: 10 !important; 23 | } 24 | 25 | .carousel-caption p { 26 | font-size: 20px; 27 | line-height: 1.4; 28 | } 29 | 30 | @media (min-width: 768px) { 31 | .carousel-caption { 32 | z-index: 10 !important; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Microsoft.AspNetCore.Authentication.ActiveDirectory/Events/IAuthenticationEvents.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace Microsoft.AspNetCore.Authentication.ActiveDirectory.Events 7 | { 8 | public interface IAuthenticationEvents 9 | { 10 | /// 11 | /// Invoked when the Active Directory authentication process has succeeded and authenticated the user. 12 | /// 13 | Task AuthenticationSucceeded(AuthenticationSucceededContext context); 14 | 15 | 16 | /// 17 | /// Invoked when the authentication handshaking failed and the user is not authenticated. 18 | /// 19 | Task AuthenticationFailed(AuthenticationFailedContext context); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Microsoft.AspNetCore.Authentication.ActiveDirectory/Events/BaseActiveDirectoryContext.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Authentication; 2 | using Microsoft.AspNetCore.Http; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | 8 | namespace Microsoft.AspNetCore.Authentication.ActiveDirectory.Events 9 | { 10 | public class BaseActiveDirectoryContext : BaseControlContext 11 | { 12 | public BaseActiveDirectoryContext(HttpContext context, ActiveDirectoryOptions options) 13 | : base(context) 14 | { 15 | if (options == null) 16 | { 17 | throw new ArgumentNullException(nameof(options)); 18 | } 19 | 20 | Options = options; 21 | } 22 | 23 | public ActiveDirectoryOptions Options { get; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /samples/Sample-AspNet5.Mvc6.Ntlm/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.AspNetCore.Authorization; 3 | 4 | namespace Sample_AspNet5.Mvc6.Ntlm.Controllers 5 | { 6 | public class HomeController : Controller 7 | { 8 | [AllowAnonymous] 9 | public IActionResult Index() 10 | { 11 | return View(); 12 | } 13 | 14 | [Authorize] 15 | public IActionResult About() 16 | { 17 | ViewData["Message"] = "You are authenticated with NTLM. User is " + User.Identity.Name; 18 | 19 | return View(); 20 | } 21 | 22 | public IActionResult Contact() 23 | { 24 | ViewData["Message"] = "Your contact page."; 25 | 26 | return View(); 27 | } 28 | 29 | public IActionResult Error() 30 | { 31 | return View(); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /samples/Sample-AspNet5.Mvc6.Ntlm/wwwroot/lib/jquery/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery", 3 | "version": "2.1.4", 4 | "main": "dist/jquery.js", 5 | "license": "MIT", 6 | "ignore": [ 7 | "**/.*", 8 | "build", 9 | "dist/cdn", 10 | "speed", 11 | "test", 12 | "*.md", 13 | "AUTHORS.txt", 14 | "Gruntfile.js", 15 | "package.json" 16 | ], 17 | "devDependencies": { 18 | "sizzle": "2.1.1-jquery.2.1.2", 19 | "requirejs": "2.1.10", 20 | "qunit": "1.14.0", 21 | "sinon": "1.8.1" 22 | }, 23 | "keywords": [ 24 | "jquery", 25 | "javascript", 26 | "library" 27 | ], 28 | "homepage": "https://github.com/jquery/jquery", 29 | "_release": "2.1.4", 30 | "_resolution": { 31 | "type": "version", 32 | "tag": "2.1.4", 33 | "commit": "7751e69b615c6eca6f783a81e292a55725af6b85" 34 | }, 35 | "_source": "git://github.com/jquery/jquery.git", 36 | "_target": "2.1.4", 37 | "_originalSource": "jquery" 38 | } -------------------------------------------------------------------------------- /src/Microsoft.AspNetCore.Authentication.ActiveDirectory/Constants.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.AspNetCore.Authentication.ActiveDirectory 2 | { 3 | class Constants 4 | { 5 | #region Private constants 6 | private const int ISC_REQ_REPLAY_DETECT = 0x00000004; 7 | private const int ISC_REQ_SEQUENCE_DETECT = 0x00000008; 8 | private const int ISC_REQ_CONFIDENTIALITY = 0x00000010; 9 | private const int ISC_REQ_CONNECTION = 0x00000800; 10 | #endregion 11 | 12 | #region Public constants 13 | public const int StandardContextAttributes = ISC_REQ_CONFIDENTIALITY | ISC_REQ_REPLAY_DETECT | ISC_REQ_SEQUENCE_DETECT | ISC_REQ_CONNECTION; 14 | public const int SecurityNativeDataRepresentation = 0x10; 15 | public const int MaximumTokenSize = 12288; 16 | public const int SecurityCredentialsInbound = 1; 17 | public const int SuccessfulResult = 0; 18 | public const int IntermediateResult = 0x90312; 19 | #endregion 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /samples/Sample-AspNet5.Mvc6.Ntlm/wwwroot/lib/jquery-validation/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery-validation", 3 | "homepage": "http://jqueryvalidation.org/", 4 | "repository": { 5 | "type": "git", 6 | "url": "git://github.com/jzaefferer/jquery-validation.git" 7 | }, 8 | "authors": [ 9 | "Jörn Zaefferer " 10 | ], 11 | "description": "Form validation made easy", 12 | "main": "dist/jquery.validate.js", 13 | "keywords": [ 14 | "forms", 15 | "validation", 16 | "validate" 17 | ], 18 | "license": "MIT", 19 | "ignore": [ 20 | "**/.*", 21 | "node_modules", 22 | "bower_components", 23 | "test", 24 | "demo", 25 | "lib" 26 | ], 27 | "dependencies": { 28 | "jquery": ">= 1.7.2" 29 | }, 30 | "version": "1.14.0", 31 | "_release": "1.14.0", 32 | "_resolution": { 33 | "type": "version", 34 | "tag": "1.14.0", 35 | "commit": "c1343fb9823392aa9acbe1c3ffd337b8c92fed48" 36 | }, 37 | "_source": "git://github.com/jzaefferer/jquery-validation.git", 38 | "_target": ">=1.8", 39 | "_originalSource": "jquery-validation" 40 | } -------------------------------------------------------------------------------- /samples/Sample-AspNet5.Mvc6.Ntlm/wwwroot/lib/bootstrap/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bootstrap", 3 | "description": "The most popular front-end framework for developing responsive, mobile first projects on the web.", 4 | "keywords": [ 5 | "css", 6 | "js", 7 | "less", 8 | "mobile-first", 9 | "responsive", 10 | "front-end", 11 | "framework", 12 | "web" 13 | ], 14 | "homepage": "http://getbootstrap.com", 15 | "license": "MIT", 16 | "moduleType": "globals", 17 | "main": [ 18 | "less/bootstrap.less", 19 | "dist/js/bootstrap.js" 20 | ], 21 | "ignore": [ 22 | "/.*", 23 | "_config.yml", 24 | "CNAME", 25 | "composer.json", 26 | "CONTRIBUTING.md", 27 | "docs", 28 | "js/tests", 29 | "test-infra" 30 | ], 31 | "dependencies": { 32 | "jquery": ">= 1.9.1" 33 | }, 34 | "version": "3.3.5", 35 | "_release": "3.3.5", 36 | "_resolution": { 37 | "type": "version", 38 | "tag": "v3.3.5", 39 | "commit": "16b48259a62f576e52c903c476bd42b90ab22482" 40 | }, 41 | "_source": "git://github.com/twbs/bootstrap.git", 42 | "_target": "3.3.5", 43 | "_originalSource": "bootstrap" 44 | } -------------------------------------------------------------------------------- /samples/Sample-AspNet5.Mvc6.Ntlm/wwwroot/lib/bootstrap/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2015 Twitter, Inc 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/Microsoft.AspNetCore.Authentication.ActiveDirectory/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Microsoft.AspNetCore.Authentication.ActiveDirectory")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Microsoft.AspNetCore.Authentication.ActiveDirectory")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("404a11c5-8f4e-480e-bae7-9ff2d7060bce")] 24 | -------------------------------------------------------------------------------- /samples/Sample-AspNet5.Mvc6.Ntlm/wwwroot/lib/jquery/MIT-LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright 2014 jQuery Foundation and other contributors 2 | http://jquery.com/ 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining 5 | a copy of this software and associated documentation files (the 6 | "Software"), to deal in the Software without restriction, including 7 | without limitation the rights to use, copy, modify, merge, publish, 8 | distribute, sublicense, and/or sell copies of the Software, and to 9 | permit persons to whom the Software is furnished to do so, subject to 10 | the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /samples/Sample-AspNet5.Mvc6.Ntlm/wwwroot/lib/jquery-validation/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright Jörn Zaefferer 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /src/Microsoft.AspNetCore.Authentication.ActiveDirectory/Events/AuthenticationEvents.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace Microsoft.AspNetCore.Authentication.ActiveDirectory.Events 7 | { 8 | public class AuthenticationEvents : IAuthenticationEvents 9 | { 10 | /// 11 | /// Invoked when the Active Directory authentication process has succeeded and authenticated the user. 12 | /// 13 | public Func OnAuthenticationFailed { get; set; } = context => Task.FromResult(0); 14 | 15 | /// 16 | /// Invoked when the authentication handshaking failed and the user is not authenticated. 17 | /// 18 | public Func OnAuthenticationSucceeded { get; set; } = context => Task.FromResult(0); 19 | 20 | public virtual Task AuthenticationFailed(AuthenticationFailedContext context) 21 | => OnAuthenticationFailed(context); 22 | 23 | public virtual Task AuthenticationSucceeded(AuthenticationSucceededContext context) 24 | => OnAuthenticationSucceeded(context); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Microsoft.AspNetCore.Authentication.ActiveDirectory/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.2.0", 3 | "description": "Authentication middleware for Active Directory with WIA, Ntlm and Kerberos support.", 4 | "authors": [ "Radi Atanassov" ], 5 | "packOptions": { 6 | "tags": [ "authentication", "aspnet", "identity", "activedirectory" ], 7 | "projectUrl": "https://github.com/OneBitSoftware/Microsoft.AspNetCore.Authentication.ActiveDirectory", 8 | "licenseUrl": "https://github.com/OneBitSoftware/Microsoft.AspNetCore.Authentication.ActiveDirectory/blob/master/LICENSE" 9 | }, 10 | 11 | "dependencies": { 12 | "Microsoft.AspNetCore.Authentication": "1.0.0", 13 | "Microsoft.AspNetCore.Mvc": "1.0.0", 14 | "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0", 15 | "Microsoft.AspNetCore.Authorization": "1.0.0", 16 | "Microsoft.AspNetCore.Http": "1.0.0", 17 | "Microsoft.AspNetCore.Http.Abstractions": "1.0.0", 18 | "Microsoft.AspNetCore.Http.Extensions": "1.0.0", 19 | "Microsoft.AspNetCore.Http.Features": "1.0.0", 20 | "Microsoft.AspNetCore.WebUtilities": "1.0.0", 21 | "Microsoft.Net.Http.Headers": "1.0.0" 22 | }, 23 | 24 | "frameworks": { 25 | "netcoreapp1.0": {}, 26 | "net451": { 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /samples/Sample-AspNet5.Mvc6.Ntlm/wwwroot/lib/jquery-validation-unobtrusive/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery-validation-unobtrusive", 3 | "version": "3.2.4", 4 | "homepage": "https://github.com/aspnet/jquery-validation-unobtrusive", 5 | "description": "Add-on to jQuery Validation to enable unobtrusive validation options in data-* attributes.", 6 | "main": [ 7 | "jquery.validate.unobtrusive.js" 8 | ], 9 | "ignore": [ 10 | "**/.*", 11 | "*.json", 12 | "*.md", 13 | "*.txt", 14 | "gulpfile.js" 15 | ], 16 | "keywords": [ 17 | "jquery", 18 | "asp.net", 19 | "mvc", 20 | "validation", 21 | "unobtrusive" 22 | ], 23 | "authors": [ 24 | "Microsoft" 25 | ], 26 | "license": "http://www.microsoft.com/web/webpi/eula/net_library_eula_enu.htm", 27 | "repository": { 28 | "type": "git", 29 | "url": "git://github.com/aspnet/jquery-validation-unobtrusive.git" 30 | }, 31 | "dependencies": { 32 | "jquery-validation": ">=1.8", 33 | "jquery": ">=1.8" 34 | }, 35 | "_release": "3.2.4", 36 | "_resolution": { 37 | "type": "version", 38 | "tag": "v3.2.4", 39 | "commit": "13386cd1b5947d8a5d23a12b531ce3960be1eba7" 40 | }, 41 | "_source": "git://github.com/aspnet/jquery-validation-unobtrusive.git", 42 | "_target": "3.2.4", 43 | "_originalSource": "jquery-validation-unobtrusive" 44 | } -------------------------------------------------------------------------------- /samples/Sample-AspNet5.Mvc6.Ntlm/gulpfile.js: -------------------------------------------------------------------------------- 1 | /// 2 | "use strict"; 3 | 4 | var gulp = require("gulp"), 5 | rimraf = require("rimraf"), 6 | concat = require("gulp-concat"), 7 | cssmin = require("gulp-cssmin"), 8 | uglify = require("gulp-uglify"); 9 | 10 | var paths = { 11 | webroot: "./wwwroot/" 12 | }; 13 | 14 | paths.js = paths.webroot + "js/**/*.js"; 15 | paths.minJs = paths.webroot + "js/**/*.min.js"; 16 | paths.css = paths.webroot + "css/**/*.css"; 17 | paths.minCss = paths.webroot + "css/**/*.min.css"; 18 | paths.concatJsDest = paths.webroot + "js/site.min.js"; 19 | paths.concatCssDest = paths.webroot + "css/site.min.css"; 20 | 21 | gulp.task("clean:js", function (cb) { 22 | rimraf(paths.concatJsDest, cb); 23 | }); 24 | 25 | gulp.task("clean:css", function (cb) { 26 | rimraf(paths.concatCssDest, cb); 27 | }); 28 | 29 | gulp.task("clean", ["clean:js", "clean:css"]); 30 | 31 | gulp.task("min:js", function () { 32 | return gulp.src([paths.js, "!" + paths.minJs], { base: "." }) 33 | .pipe(concat(paths.concatJsDest)) 34 | .pipe(uglify()) 35 | .pipe(gulp.dest(".")); 36 | }); 37 | 38 | gulp.task("min:css", function () { 39 | return gulp.src([paths.css, "!" + paths.minCss]) 40 | .pipe(concat(paths.concatCssDest)) 41 | .pipe(cssmin()) 42 | .pipe(gulp.dest(".")); 43 | }); 44 | 45 | gulp.task("min", ["min:js", "min:css"]); 46 | -------------------------------------------------------------------------------- /samples/Sample-AspNet5.Mvc6.Ntlm/Sample-AspNet5.Mvc6.Ntlm.xproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 14.0 5 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 6 | 7 | 8 | 9 | 64853030-74ee-47ce-9362-159aef99939f 10 | Sample_AspNet5.Mvc6.Ntlm 11 | ..\..\artifacts\obj\$(MSBuildProjectName) 12 | .\bin\ 13 | v4.5.2 14 | 15 | 16 | 2.0 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/Microsoft.AspNetCore.Authentication.ActiveDirectory/Microsoft.AspNetCore.Authentication.ActiveDirectory.xproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 14.0 5 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 6 | 7 | 8 | 9 | 404a11c5-8f4e-480e-bae7-9ff2d7060bce 10 | Microsoft.AspNetCore.Authentication.ActiveDirectory 11 | ..\..\artifacts\obj\$(MSBuildProjectName) 12 | .\bin\ 13 | v4.5.2 14 | 15 | 16 | 2.0 17 | 18 | 19 | True 20 | 21 | 22 | True 23 | 24 | 25 | -------------------------------------------------------------------------------- /samples/Sample-AspNet5.Mvc6.Ntlm/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0-*", 3 | 4 | "dependencies": { 5 | "Microsoft.NETCore.App": { 6 | "version": "1.0.0", 7 | "type": "platform" 8 | }, 9 | "Microsoft.AspNetCore.Diagnostics": "1.0.0", 10 | "Microsoft.AspNetCore.Mvc": "1.0.0", 11 | "Microsoft.AspNetCore.Server.Kestrel": "1.0.0", 12 | "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0", 13 | "Microsoft.AspNetCore.StaticFiles": "1.0.0", 14 | "Microsoft.Extensions.Configuration.Json": "1.0.0", 15 | "Microsoft.Extensions.FileProviders.Abstractions": "1.0.0", 16 | "Microsoft.Extensions.Logging": "1.0.0", 17 | "Microsoft.Extensions.Logging.Console": "1.0.0", 18 | "Microsoft.Extensions.Logging.Debug": "1.0.0", 19 | "Microsoft.AspNetCore.Authentication.ActiveDirectory": "1.1.0-*", 20 | "Microsoft.AspNetCore.Authentication": "1.0.0", 21 | "Microsoft.AspNetCore.Http.Abstractions": "1.0.0", 22 | "Microsoft.AspNetCore.Authorization": "1.0.0" 23 | }, 24 | 25 | "tools": { 26 | "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final" 27 | }, 28 | 29 | "commands": { 30 | "web": "Microsoft.AspNetCore.Server.Kestrel" 31 | }, 32 | 33 | "frameworks": { 34 | "netcoreapp1.0": {} 35 | }, 36 | 37 | "buildOptions": { 38 | "emitEntryPoint": true, 39 | "preserveCompilationContext": true, 40 | "compile": { 41 | "exclude": [ 42 | "wwwroot", 43 | "node_modules" 44 | ] 45 | } 46 | }, 47 | "runtimeOptions": { 48 | "configProperties": { 49 | "System.GC.Server": true 50 | } 51 | }, 52 | "publishOptions": { 53 | "exclude": [ 54 | "**.user", 55 | "**.vspscc" 56 | ] 57 | }, 58 | 59 | "scripts": { 60 | "prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ] 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/Microsoft.AspNetCore.Authentication.ActiveDirectory/Enums.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.AspNetCore.Authentication.ActiveDirectory 2 | { 3 | using System; 4 | 5 | enum SecurityBufferType 6 | { 7 | SECBUFFER_VERSION = 0, 8 | SECBUFFER_EMPTY = 0, 9 | SECBUFFER_DATA = 1, 10 | SECBUFFER_TOKEN = 2 11 | } 12 | 13 | [Flags] 14 | enum NtlmFlags : int 15 | { 16 | // The client sets this flag to indicate that it supports Unicode strings. 17 | NegotiateUnicode = 0x00000001, 18 | // This is set to indicate that the client supports OEM strings. 19 | NegotiateOem = 0x00000002, 20 | // This requests that the server send the authentication target with the Type 2 reply. 21 | RequestTarget = 0x00000004, 22 | // Indicates that NTLM authentication is supported. 23 | NegotiateNtlm = 0x00000200, 24 | // When set, the client will send with the message the name of the domain in which the workstation has membership. 25 | NegotiateDomainSupplied = 0x00001000, 26 | // Indicates that the client is sending its workstation name with the message. 27 | NegotiateWorkstationSupplied = 0x00002000, 28 | // Indicates that communication between the client and server after authentication should carry a "dummy" signature. 29 | NegotiateAlwaysSign = 0x00008000, 30 | // Indicates that this client supports the NTLM2 signing and sealing scheme; if negotiated, this can also affect the response calculations. 31 | NegotiateNtlm2Key = 0x00080000, 32 | // Indicates that this client supports strong (128-bit) encryption. 33 | Negotiate128 = 0x20000000, 34 | // Indicates that this client supports medium (56-bit) encryption. 35 | Negotiate56 = (unchecked((int)0x80000000)) 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/Microsoft.AspNetCore.Authentication.ActiveDirectory/WindowsAuthenticationController.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.AspNetCore.Authentication.ActiveDirectory 2 | { 3 | using Microsoft.AspNetCore.Authorization; 4 | using Microsoft.AspNetCore.Http.Authentication; 5 | using Microsoft.AspNetCore.Mvc; 6 | using System.Threading.Tasks; 7 | 8 | public class WindowsAuthenticationController : Controller 9 | { 10 | [AllowAnonymous] 11 | [HttpGet] 12 | public async Task Ntlm(string returnUrl = null) 13 | { 14 | if (this.User.Identity.IsAuthenticated == false) 15 | { 16 | var defaultProperties = new AuthenticationProperties() { RedirectUri = returnUrl }; 17 | 18 | var authContext = new Http.Features.Authentication.AuthenticateContext(ActiveDirectoryOptions.DefaultAuthenticationScheme); 19 | await HttpContext.Authentication.AuthenticateAsync(authContext); 20 | 21 | if (!authContext.Accepted || authContext.Principal == null) 22 | { 23 | return new UnauthorizedResult(); 24 | } 25 | } 26 | 27 | if (string.IsNullOrWhiteSpace(returnUrl)) 28 | return new OkResult(); 29 | else 30 | return Redirect(returnUrl); 31 | } 32 | 33 | [AllowAnonymous] 34 | public async Task LogOut(string returnUrl = null) 35 | { 36 | var context = this.Request.HttpContext; 37 | await context.Authentication.SignOutAsync(ActiveDirectoryOptions.DefaultAuthenticationScheme); 38 | if (string.IsNullOrWhiteSpace(returnUrl)) 39 | return new OkResult(); 40 | else 41 | return Redirect(returnUrl); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Microsoft.AspNetCore.Authentication.ActiveDirectory/ActiveDirectoryExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.AspNetCore.Authentication.ActiveDirectory 2 | { 3 | using Microsoft.AspNetCore.Builder; 4 | using System; 5 | using System.Text.Encodings.Web; 6 | 7 | /// 8 | /// Extension methods for the ActiveDirectoryMiddleware 9 | /// 10 | public static class ActiveDirectoryExtensions 11 | { 12 | /// 13 | /// Enables the NTLM route for challenge/response handshaking 14 | /// 15 | /// 16 | /// An ActiveDirectoryOptions configuration 17 | /// 18 | public static IApplicationBuilder UseNtlm(this IApplicationBuilder app, ActiveDirectoryOptions options = null, UrlEncoder encoder = null) 19 | { 20 | if (app == null) 21 | { 22 | throw new ArgumentNullException(nameof(app)); 23 | } 24 | 25 | //set default encoder if none is provided 26 | if (encoder == null) encoder = UrlEncoder.Default; 27 | 28 | if (options != null) 29 | { 30 | return app.UseMiddleware(options, encoder); 31 | } 32 | 33 | return app.UseMiddleware(encoder); 34 | } 35 | 36 | public static IApplicationBuilder UseKerberos(this IApplicationBuilder app, ActiveDirectoryOptions options = null) 37 | { 38 | throw new NotImplementedException("Kerberos support is not yet ready :("); 39 | } 40 | 41 | public static IApplicationBuilder UseWindowsIntegratedAuthentication(this IApplicationBuilder app, ActiveDirectoryOptions options = null) 42 | { 43 | throw new NotImplementedException("Windows Integrated Authentication support is not yet ready :("); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Microsoft.AspNetCore.Authentication.ActiveDirectory/ActiveDirectoryCookieOptions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Builder; 2 | using Microsoft.AspNetCore.Http; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | 8 | namespace Microsoft.AspNetCore.Authentication.ActiveDirectory 9 | { 10 | /// 11 | /// Represents all the options you can use to configure the cookies middleware. 12 | /// 13 | public class ActiveDirectoryCookieOptions 14 | { 15 | /// 16 | /// Default constructor for AD Cookie Options. Internally instantiates CookieAuthenticationOptions with default values. 17 | /// 18 | public ActiveDirectoryCookieOptions() 19 | { 20 | // Configure all of the cookie middlewares 21 | ApplicationCookie = new CookieAuthenticationOptions 22 | { 23 | AuthenticationScheme = ApplicationCookieAuthenticationScheme, 24 | AutomaticAuthenticate = true, 25 | AutomaticChallenge = true, 26 | ReturnUrlParameter = "ReturnUrl", 27 | LoginPath = new PathString("/windowsauthentication/ntlm"), 28 | }; 29 | } 30 | 31 | /// 32 | /// Constructor accepting CookieAuthenticationOptions 33 | /// 34 | /// 35 | public ActiveDirectoryCookieOptions(CookieAuthenticationOptions cookieOptions) 36 | { 37 | // Configure all of the cookie middlewares 38 | ApplicationCookie = cookieOptions; 39 | } 40 | 41 | public CookieAuthenticationOptions ApplicationCookie { get; set; } 42 | 43 | /// 44 | /// Gets or sets the scheme used to identify application authentication cookies. 45 | /// 46 | /// The scheme used to identify application authentication cookies. 47 | public string ApplicationCookieAuthenticationScheme { get; set; } = typeof(ActiveDirectoryCookieOptions).Namespace + ".Application"; 48 | 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/Microsoft.AspNetCore.Authentication.ActiveDirectory/ActiveDirectoryMiddleware.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.AspNetCore.Authentication.ActiveDirectory 2 | { 3 | using Extensions.WebEncoders; 4 | using Microsoft.AspNetCore.Http; 5 | using Microsoft.AspNetCore.Authentication; 6 | using Microsoft.AspNetCore.Builder; 7 | using Microsoft.Extensions.Logging; 8 | using System; 9 | using System.Text.Encodings.Web; 10 | using Extensions.Options; 11 | 12 | public class ActiveDirectoryMiddleware : AuthenticationMiddleware 13 | { 14 | private readonly RequestDelegate _next; 15 | private readonly ILogger _logger; 16 | 17 | /// 18 | /// Creates a new instance of the ActiveDirectoryMiddleware. 19 | /// 20 | /// The next middleware in the pipeline. 21 | /// The Active Directory configuration options. 22 | /// An instance used to create loggers. 23 | public ActiveDirectoryMiddleware( 24 | RequestDelegate next, 25 | ActiveDirectoryOptions options, 26 | ILoggerFactory loggerFactory, 27 | UrlEncoder encoder) 28 | : base(next, options, loggerFactory, encoder) 29 | { 30 | if (next == null) 31 | { 32 | throw new ArgumentNullException(nameof(next)); 33 | } 34 | 35 | if (encoder == null) 36 | { 37 | throw new ArgumentNullException(nameof(encoder)); 38 | } 39 | 40 | if (options == null) 41 | { 42 | throw new ArgumentNullException(nameof(options)); 43 | } 44 | 45 | if (loggerFactory == null) 46 | { 47 | throw new ArgumentNullException(nameof(loggerFactory)); 48 | } 49 | 50 | _next = next; 51 | _logger = loggerFactory.CreateLogger(); 52 | } 53 | 54 | protected override AuthenticationHandler CreateHandler() 55 | { 56 | return new NtlmAuthenticationHandler(); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Middleware.ActiveDirectory.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Authentication.ActiveDirectory", "src\Microsoft.AspNetCore.Authentication.ActiveDirectory\Microsoft.AspNetCore.Authentication.ActiveDirectory.xproj", "{404A11C5-8F4E-480E-BAE7-9FF2D7060BCE}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{F2C2ED0D-AB6A-425A-A79C-787D93D063ED}" 9 | EndProject 10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{EC6F6CA0-17BA-4D14-B306-23CE4357FD44}" 11 | EndProject 12 | Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Sample-AspNet5.Mvc6.Ntlm", "samples\Sample-AspNet5.Mvc6.Ntlm\Sample-AspNet5.Mvc6.Ntlm.xproj", "{64853030-74EE-47CE-9362-159AEF99939F}" 13 | EndProject 14 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{664EC421-1B80-4F97-BCE3-2D0B759BD42F}" 15 | ProjectSection(SolutionItems) = preProject 16 | global.json = global.json 17 | EndProjectSection 18 | EndProject 19 | Global 20 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 21 | Debug|Any CPU = Debug|Any CPU 22 | Release|Any CPU = Release|Any CPU 23 | EndGlobalSection 24 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 25 | {404A11C5-8F4E-480E-BAE7-9FF2D7060BCE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 26 | {404A11C5-8F4E-480E-BAE7-9FF2D7060BCE}.Debug|Any CPU.Build.0 = Debug|Any CPU 27 | {404A11C5-8F4E-480E-BAE7-9FF2D7060BCE}.Release|Any CPU.ActiveCfg = Release|Any CPU 28 | {404A11C5-8F4E-480E-BAE7-9FF2D7060BCE}.Release|Any CPU.Build.0 = Release|Any CPU 29 | {64853030-74EE-47CE-9362-159AEF99939F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 30 | {64853030-74EE-47CE-9362-159AEF99939F}.Debug|Any CPU.Build.0 = Debug|Any CPU 31 | {64853030-74EE-47CE-9362-159AEF99939F}.Release|Any CPU.ActiveCfg = Release|Any CPU 32 | {64853030-74EE-47CE-9362-159AEF99939F}.Release|Any CPU.Build.0 = Release|Any CPU 33 | EndGlobalSection 34 | GlobalSection(SolutionProperties) = preSolution 35 | HideSolutionNode = FALSE 36 | EndGlobalSection 37 | GlobalSection(NestedProjects) = preSolution 38 | {404A11C5-8F4E-480E-BAE7-9FF2D7060BCE} = {F2C2ED0D-AB6A-425A-A79C-787D93D063ED} 39 | {64853030-74EE-47CE-9362-159AEF99939F} = {EC6F6CA0-17BA-4D14-B306-23CE4357FD44} 40 | EndGlobalSection 41 | EndGlobal 42 | -------------------------------------------------------------------------------- /src/Microsoft.AspNetCore.Authentication.ActiveDirectory/Interop.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.InteropServices; 5 | using System.Threading.Tasks; 6 | 7 | namespace Microsoft.AspNetCore.Authentication.ActiveDirectory 8 | { 9 | class Interop 10 | { 11 | /// 12 | /// The AcquireCredentialsHandle function acquires a handle to preexisting credentials of a security principal. 13 | /// 14 | [DllImport("secur32.dll", CharSet = CharSet.Unicode, SetLastError = false)] 15 | public static extern int AcquireCredentialsHandle( 16 | string pszPrincipal, 17 | string pszPackage, 18 | int fCredentialUse, 19 | IntPtr PAuthenticationID, 20 | IntPtr pAuthData, 21 | int pGetKeyFn, 22 | IntPtr pvGetKeyArgument, 23 | ref SecurityHandle phCredential, 24 | ref SecurityInteger ptsExpiry); 25 | 26 | /// 27 | /// The AcceptSecurityContext (General) function enables the server component of a 28 | /// transport application to establish a security context between the server and a remote client. 29 | /// 30 | [DllImport("secur32.dll", CharSet = CharSet.Unicode, SetLastError = false)] 31 | public static extern int AcceptSecurityContext(ref SecurityHandle phCredential, 32 | IntPtr phContext, 33 | ref SecurityBufferDesciption pInput, 34 | uint fContextReq, 35 | uint TargetDataRep, 36 | out SecurityHandle phNewContext, 37 | out SecurityBufferDesciption pOutput, 38 | out uint pfContextAttr, 39 | out SecurityInteger ptsTimeStamp); 40 | 41 | /// 42 | /// The AcceptSecurityContext (General) function enables the server component of a 43 | /// transport application to establish a security context between the server and a remote client. 44 | /// 45 | [DllImport("secur32.dll", CharSet = CharSet.Unicode, SetLastError = false)] 46 | public static extern int AcceptSecurityContext(ref SecurityHandle phCredential, 47 | ref SecurityHandle phContext, 48 | ref SecurityBufferDesciption pInput, 49 | uint fContextReq, 50 | uint TargetDataRep, 51 | out SecurityHandle phNewContext, 52 | out SecurityBufferDesciption pOutput, 53 | out uint pfContextAttr, 54 | out SecurityInteger ptsTimeStamp); 55 | 56 | /// 57 | /// Obtains the access token for a client security context and uses it directly. 58 | /// 59 | [DllImport("SECUR32.DLL", CharSet = CharSet.Unicode)] 60 | public static extern int QuerySecurityContextToken( 61 | ref SecurityHandle phContext, 62 | ref IntPtr phToken); 63 | 64 | /// 65 | /// Close handle for proper cleanup 66 | /// 67 | /// 68 | /// 69 | [DllImport("kernel32.dll")] 70 | public static extern int CloseHandle(IntPtr hObject); 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /samples/Sample-AspNet5.Mvc6.Ntlm/Views/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | @ViewData["Title"] - Sample_AspNet5.Mvc6.Ntlm 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 18 | 19 | 20 | 44 |
45 | @RenderBody() 46 |
47 |
48 |

© 2016 - Sample_AspNet5.Mvc6.Ntlm

49 |
50 |
51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 62 | 66 | 67 | 68 | 69 | @RenderSection("scripts", required: false) 70 | 71 | 72 | -------------------------------------------------------------------------------- /src/Microsoft.AspNetCore.Authentication.ActiveDirectory/ActiveDirectoryOptions.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.AspNetCore.Authentication.ActiveDirectory 2 | { 3 | using System; 4 | using Microsoft.AspNetCore.Authentication; 5 | using Microsoft.AspNetCore.Builder; 6 | using Microsoft.AspNetCore.Http; 7 | using Microsoft.AspNetCore.Http.Authentication; 8 | using System.Security.Principal; 9 | using Events; 10 | using Extensions.Options; 11 | 12 | public class ActiveDirectoryOptions : AuthenticationOptions, IOptions 13 | { 14 | public const string DefaultAuthenticationScheme = "Ntlm"; 15 | 16 | #region Internal fields 17 | /// 18 | /// The default redirection path used by the NTLM authentication middleware of 19 | /// the full roundtrip / handshakes 20 | /// 21 | internal static readonly PathString DefaultRedirectPath = new PathString("/windowsauthentication/ntlm"); 22 | 23 | /// 24 | /// Secured store for state data 25 | /// 26 | internal ISecureDataFormat StateDataFormat { get; set; } 27 | 28 | /// 29 | /// Store states for the login attempts 30 | /// 31 | internal AuthenticationStateCache LoginStateCache { get; set; } 32 | #endregion 33 | 34 | /// 35 | /// Number of minutes a login can take (defaults to 2 minutes) 36 | /// 37 | public int LoginStateExpirationTime 38 | { 39 | set { LoginStateCache.ExpirationTime = value; } 40 | get { return LoginStateCache.ExpirationTime; } 41 | } 42 | 43 | /// 44 | /// The authentication scheme used for sign in 45 | /// 46 | public string SignInAsAuthenticationScheme { get; set; } 47 | 48 | /// 49 | /// The callback string used for the NTLM authentication roundtrips, 50 | /// defaults to "/authentication/ntlm-signin" 51 | /// 52 | public PathString CallbackPath { get; set; } 53 | 54 | /// 55 | /// If this is set, it must return true to authenticate the user. 56 | /// It can be used to filter out users according to separate criteria. 57 | /// 58 | /// 59 | /// Note that the Windows identity will be disposed shortly after this function has returned 60 | /// 61 | public Func Filter { get; set; } //TODO: httpRquest? 62 | 63 | /// 64 | /// Creates an instance of Ntlm authentication options with default values. 65 | /// 66 | public ActiveDirectoryOptions() 67 | { 68 | this.SignInAsAuthenticationScheme = DefaultAuthenticationScheme; 69 | this.CallbackPath = DefaultRedirectPath; 70 | this.LoginStateCache = new AuthenticationStateCache(); 71 | this.LoginStateExpirationTime = 5; 72 | } 73 | 74 | public ActiveDirectoryCookieOptions Cookies { get; set; } = new ActiveDirectoryCookieOptions(); 75 | 76 | /// 77 | /// The object provided by the application to process events raised by the Active Directory authentication middleware. 78 | /// The application may implement the interface fully, or it may create an instance of AuthenticationEvents 79 | /// and assign delegates only to the events it wants to process. 80 | /// 81 | public IAuthenticationEvents Events { get; set; } = new AuthenticationEvents(); 82 | 83 | public ActiveDirectoryOptions Value 84 | { 85 | get 86 | { 87 | return this; 88 | } 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/Microsoft.AspNetCore.Authentication.ActiveDirectory/AuthenticationStateCache.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.AspNetCore.Authentication.ActiveDirectory 2 | { 3 | using System; 4 | using Microsoft.Extensions.Caching.Memory; 5 | 6 | /// 7 | /// An in-memory cache for the login handshakes 8 | /// 9 | internal class AuthenticationStateCache 10 | { 11 | #region fields 12 | private IMemoryCache Cache; 13 | 14 | /// 15 | /// Expiration time of a login attempt state in minutes, 16 | /// defaults to 2 17 | /// 18 | public int ExpirationTime { get; set; } 19 | #endregion 20 | 21 | /// 22 | /// Create an authentication state cache 23 | /// 24 | /// 25 | public AuthenticationStateCache() 26 | { 27 | this.Cache = new MemoryCache(new MemoryCacheOptions()); 28 | this.ExpirationTime = 2; 29 | } 30 | 31 | /// 32 | /// Try to get a state by its key 33 | /// 34 | /// 35 | /// 36 | /// 37 | public bool TryGet(string key, out HandshakeState state) 38 | { 39 | object tmp; 40 | if (Cache.TryGetValue(key, out tmp)) 41 | { 42 | if (tmp != null) 43 | { 44 | state = (HandshakeState)tmp; 45 | return true; 46 | } 47 | } 48 | 49 | state = default(HandshakeState); 50 | return false; 51 | } 52 | 53 | /// 54 | /// Add a new state to the cache 55 | /// 56 | /// 57 | /// 58 | public void Add(string key, HandshakeState state) 59 | { 60 | this.Cache.Set(key, state, GetCacheEntryOptions(this.ExpirationTime)); 61 | } 62 | 63 | /// 64 | /// Add a new state to the cache and set a custom cache item policy 65 | /// 66 | /// 67 | /// 68 | /// 69 | public void Add(string key, HandshakeState state, MemoryCacheEntryOptions options) 70 | { 71 | this.Cache.Set(key, state, options); 72 | } 73 | 74 | /// 75 | /// Remove a key 76 | /// 77 | /// 78 | /// 79 | public void TryRemove(string key) 80 | { 81 | this.Cache.Remove(key); 82 | } 83 | 84 | #region Helpers 85 | /// 86 | /// Gets a cache item policy. 87 | /// 88 | /// Absolute expiration time in x minutes 89 | /// 90 | private static MemoryCacheEntryOptions GetCacheEntryOptions(int minutes) 91 | { 92 | var cacheEntryOptions = new MemoryCacheEntryOptions() 93 | { 94 | Priority = CacheItemPriority.Normal, 95 | AbsoluteExpiration = DateTimeOffset.Now.AddMinutes(minutes) 96 | 97 | //RemovedCallback = (item) => 98 | //{ 99 | // // dispose cached item at removal 100 | // var asDisposable = item.CacheItem as IDisposable; 101 | // if (asDisposable != null) 102 | // asDisposable.Dispose(); 103 | //} 104 | }; 105 | return cacheEntryOptions; 106 | } 107 | #endregion 108 | 109 | } 110 | 111 | } 112 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | 24 | # Visual Studio 2015 cache/options directory 25 | .vs/ 26 | # Uncomment if you have tasks that create the project's static files in wwwroot 27 | #wwwroot/ 28 | 29 | # MSTest test Results 30 | [Tt]est[Rr]esult*/ 31 | [Bb]uild[Ll]og.* 32 | 33 | # NUNIT 34 | *.VisualState.xml 35 | TestResult.xml 36 | 37 | # Build Results of an ATL Project 38 | [Dd]ebugPS/ 39 | [Rr]eleasePS/ 40 | dlldata.c 41 | 42 | # DNX 43 | project.lock.json 44 | artifacts/ 45 | 46 | *_i.c 47 | *_p.c 48 | *_i.h 49 | *.ilk 50 | *.meta 51 | *.obj 52 | *.pch 53 | *.pdb 54 | *.pgc 55 | *.pgd 56 | *.rsp 57 | *.sbr 58 | *.tlb 59 | *.tli 60 | *.tlh 61 | *.tmp 62 | *.tmp_proj 63 | *.log 64 | *.vspscc 65 | *.vssscc 66 | .builds 67 | *.pidb 68 | *.svclog 69 | *.scc 70 | 71 | # Chutzpah Test files 72 | _Chutzpah* 73 | 74 | # Visual C++ cache files 75 | ipch/ 76 | *.aps 77 | *.ncb 78 | *.opendb 79 | *.opensdf 80 | *.sdf 81 | *.cachefile 82 | 83 | # Visual Studio profiler 84 | *.psess 85 | *.vsp 86 | *.vspx 87 | *.sap 88 | 89 | # TFS 2012 Local Workspace 90 | $tf/ 91 | 92 | # Guidance Automation Toolkit 93 | *.gpState 94 | 95 | # ReSharper is a .NET coding add-in 96 | _ReSharper*/ 97 | *.[Rr]e[Ss]harper 98 | *.DotSettings.user 99 | 100 | # JustCode is a .NET coding add-in 101 | .JustCode 102 | 103 | # TeamCity is a build add-in 104 | _TeamCity* 105 | 106 | # DotCover is a Code Coverage Tool 107 | *.dotCover 108 | 109 | # NCrunch 110 | _NCrunch_* 111 | .*crunch*.local.xml 112 | nCrunchTemp_* 113 | 114 | # MightyMoose 115 | *.mm.* 116 | AutoTest.Net/ 117 | 118 | # Web workbench (sass) 119 | .sass-cache/ 120 | 121 | # Installshield output folder 122 | [Ee]xpress/ 123 | 124 | # DocProject is a documentation generator add-in 125 | DocProject/buildhelp/ 126 | DocProject/Help/*.HxT 127 | DocProject/Help/*.HxC 128 | DocProject/Help/*.hhc 129 | DocProject/Help/*.hhk 130 | DocProject/Help/*.hhp 131 | DocProject/Help/Html2 132 | DocProject/Help/html 133 | 134 | # Click-Once directory 135 | publish/ 136 | 137 | # Publish Web Output 138 | *.[Pp]ublish.xml 139 | *.azurePubxml 140 | # TODO: Comment the next line if you want to checkin your web deploy settings 141 | # but database connection strings (with potential passwords) will be unencrypted 142 | *.pubxml 143 | *.publishproj 144 | 145 | # NuGet Packages 146 | *.nupkg 147 | # The packages folder can be ignored because of Package Restore 148 | **/packages/* 149 | # except build/, which is used as an MSBuild target. 150 | !**/packages/build/ 151 | # Uncomment if necessary however generally it will be regenerated when needed 152 | #!**/packages/repositories.config 153 | # NuGet v3's project.json files produces more ignoreable files 154 | *.nuget.props 155 | *.nuget.targets 156 | 157 | # Microsoft Azure Build Output 158 | csx/ 159 | *.build.csdef 160 | 161 | # Microsoft Azure Emulator 162 | ecf/ 163 | rcf/ 164 | 165 | # Microsoft Azure ApplicationInsights config file 166 | ApplicationInsights.config 167 | 168 | # Windows Store app package directory 169 | AppPackages/ 170 | BundleArtifacts/ 171 | 172 | # Visual Studio cache files 173 | # files ending in .cache can be ignored 174 | *.[Cc]ache 175 | # but keep track of directories ending in .cache 176 | !*.[Cc]ache/ 177 | 178 | # Others 179 | ClientBin/ 180 | ~$* 181 | *~ 182 | *.dbmdl 183 | *.dbproj.schemaview 184 | *.pfx 185 | *.publishsettings 186 | node_modules/ 187 | orleans.codegen.cs 188 | 189 | # RIA/Silverlight projects 190 | Generated_Code/ 191 | 192 | # Backup & report files from converting an old project file 193 | # to a newer Visual Studio version. Backup files are not needed, 194 | # because we have git ;-) 195 | _UpgradeReport_Files/ 196 | Backup*/ 197 | UpgradeLog*.XML 198 | UpgradeLog*.htm 199 | 200 | # SQL Server files 201 | *.mdf 202 | *.ldf 203 | 204 | # Business Intelligence projects 205 | *.rdl.data 206 | *.bim.layout 207 | *.bim_*.settings 208 | 209 | # Microsoft Fakes 210 | FakesAssemblies/ 211 | 212 | # GhostDoc plugin setting file 213 | *.GhostDoc.xml 214 | 215 | # Node.js Tools for Visual Studio 216 | .ntvs_analysis.dat 217 | 218 | # Visual Studio 6 build log 219 | *.plg 220 | 221 | # Visual Studio 6 workspace options file 222 | *.opt 223 | 224 | # Visual Studio LightSwitch build output 225 | **/*.HTMLClient/GeneratedArtifacts 226 | **/*.DesktopClient/GeneratedArtifacts 227 | **/*.DesktopClient/ModelManifest.xml 228 | **/*.Server/GeneratedArtifacts 229 | **/*.Server/ModelManifest.xml 230 | _Pvt_Extensions 231 | 232 | # Paket dependency manager 233 | .paket/paket.exe 234 | 235 | # FAKE - F# Make 236 | .fake/ 237 | -------------------------------------------------------------------------------- /samples/Sample-AspNet5.Mvc6.Ntlm/wwwroot/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js: -------------------------------------------------------------------------------- 1 | /* 2 | ** Unobtrusive validation support library for jQuery and jQuery Validate 3 | ** Copyright (C) Microsoft Corporation. All rights reserved. 4 | */ 5 | !function(a){function e(a,e,n){a.rules[e]=n,a.message&&(a.messages[e]=a.message)}function n(a){return a.replace(/^\s+|\s+$/g,"").split(/\s*,\s*/g)}function t(a){return a.replace(/([!"#$%&'()*+,./:;<=>?@\[\\\]^`{|}~])/g,"\\$1")}function r(a){return a.substr(0,a.lastIndexOf(".")+1)}function i(a,e){return 0===a.indexOf("*.")&&(a=a.replace("*.",e)),a}function o(e,n){var r=a(this).find("[data-valmsg-for='"+t(n[0].name)+"']"),i=r.attr("data-valmsg-replace"),o=i?a.parseJSON(i)!==!1:null;r.removeClass("field-validation-valid").addClass("field-validation-error"),e.data("unobtrusiveContainer",r),o?(r.empty(),e.removeClass("input-validation-error").appendTo(r)):e.hide()}function d(e,n){var t=a(this).find("[data-valmsg-summary=true]"),r=t.find("ul");r&&r.length&&n.errorList.length&&(r.empty(),t.addClass("validation-summary-errors").removeClass("validation-summary-valid"),a.each(n.errorList,function(){a("
  • ").html(this.message).appendTo(r)}))}function s(e){var n=e.data("unobtrusiveContainer");if(n){var t=n.attr("data-valmsg-replace"),r=t?a.parseJSON(t):null;n.addClass("field-validation-valid").removeClass("field-validation-error"),e.removeData("unobtrusiveContainer"),r&&n.empty()}}function l(e){var n=a(this),t="__jquery_unobtrusive_validation_form_reset";if(!n.data(t)){n.data(t,!0);try{n.data("validator").resetForm()}finally{n.removeData(t)}n.find(".validation-summary-errors").addClass("validation-summary-valid").removeClass("validation-summary-errors"),n.find(".field-validation-error").addClass("field-validation-valid").removeClass("field-validation-error").removeData("unobtrusiveContainer").find(">*").removeData("unobtrusiveContainer")}}function m(e){var n=a(e),t=n.data(v),r=a.proxy(l,e),i=p.unobtrusive.options||{},m=function(n,t){var r=i[n];r&&a.isFunction(r)&&r.apply(e,t)};return t||(t={options:{errorClass:i.errorClass||"input-validation-error",errorElement:i.errorElement||"span",errorPlacement:function(){o.apply(e,arguments),m("errorPlacement",arguments)},invalidHandler:function(){d.apply(e,arguments),m("invalidHandler",arguments)},messages:{},rules:{},success:function(){s.apply(e,arguments),m("success",arguments)}},attachValidation:function(){n.off("reset."+v,r).on("reset."+v,r).validate(this.options)},validate:function(){return n.validate(),n.valid()}},n.data(v,t)),t}var u,p=a.validator,v="unobtrusiveValidation";p.unobtrusive={adapters:[],parseElement:function(e,n){var t,r,i,o=a(e),d=o.parents("form")[0];d&&(t=m(d),t.options.rules[e.name]=r={},t.options.messages[e.name]=i={},a.each(this.adapters,function(){var n="data-val-"+this.name,t=o.attr(n),s={};void 0!==t&&(n+="-",a.each(this.params,function(){s[this]=o.attr(n+this)}),this.adapt({element:e,form:d,message:t,params:s,rules:r,messages:i}))}),a.extend(r,{__dummy__:!0}),n||t.attachValidation())},parse:function(e){var n=a(e),t=n.parents().addBack().filter("form").add(n.find("form")).has("[data-val=true]");n.find("[data-val=true]").each(function(){p.unobtrusive.parseElement(this,!0)}),t.each(function(){var a=m(this);a&&a.attachValidation()})}},u=p.unobtrusive.adapters,u.add=function(a,e,n){return n||(n=e,e=[]),this.push({name:a,params:e,adapt:n}),this},u.addBool=function(a,n){return this.add(a,function(t){e(t,n||a,!0)})},u.addMinMax=function(a,n,t,r,i,o){return this.add(a,[i||"min",o||"max"],function(a){var i=a.params.min,o=a.params.max;i&&o?e(a,r,[i,o]):i?e(a,n,i):o&&e(a,t,o)})},u.addSingleVal=function(a,n,t){return this.add(a,[n||"val"],function(r){e(r,t||a,r.params[n])})},p.addMethod("__dummy__",function(a,e,n){return!0}),p.addMethod("regex",function(a,e,n){var t;return this.optional(e)?!0:(t=new RegExp(n).exec(a),t&&0===t.index&&t[0].length===a.length)}),p.addMethod("nonalphamin",function(a,e,n){var t;return n&&(t=a.match(/\W/g),t=t&&t.length>=n),t}),p.methods.extension?(u.addSingleVal("accept","mimtype"),u.addSingleVal("extension","extension")):u.addSingleVal("extension","extension","accept"),u.addSingleVal("regex","pattern"),u.addBool("creditcard").addBool("date").addBool("digits").addBool("email").addBool("number").addBool("url"),u.addMinMax("length","minlength","maxlength","rangelength").addMinMax("range","min","max","range"),u.addMinMax("minlength","minlength").addMinMax("maxlength","minlength","maxlength"),u.add("equalto",["other"],function(n){var o=r(n.element.name),d=n.params.other,s=i(d,o),l=a(n.form).find(":input").filter("[name='"+t(s)+"']")[0];e(n,"equalTo",l)}),u.add("required",function(a){("INPUT"!==a.element.tagName.toUpperCase()||"CHECKBOX"!==a.element.type.toUpperCase())&&e(a,"required",!0)}),u.add("remote",["url","type","additionalfields"],function(o){var d={url:o.params.url,type:o.params.type||"GET",data:{}},s=r(o.element.name);a.each(n(o.params.additionalfields||o.element.name),function(e,n){var r=i(n,s);d.data[r]=function(){var e=a(o.form).find(":input").filter("[name='"+t(r)+"']");return e.is(":checkbox")?e.filter(":checked").val()||e.filter(":hidden").val()||"":e.is(":radio")?e.filter(":checked").val()||"":e.val()}}),e(o,"remote",d)}),u.add("password",["min","nonalphamin","regex"],function(a){a.params.min&&e(a,"minlength",a.params.min),a.params.nonalphamin&&e(a,"nonalphamin",a.params.nonalphamin),a.params.regex&&e(a,"regex",a.params.regex)}),a(function(){p.unobtrusive.parse(document)})}(jQuery); -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Microsoft.AspNetCore.Authentication.ActiveDirectory 2 | NOTE: AppVeyor build is failing due to build scripts not yet updated. Solution is OK. [![Build status](https://ci.appveyor.com/api/projects/status/hhd468o15oct73sg?svg=true)](https://ci.appveyor.com/project/SharePointRadi/microsoft-aspnetcore-authentication-activedirector) 3 | 4 | Middleware for ASP.NET Core for Windows Integrated Authentication with NTLM and Kerberos 5 | 6 | ## Overview 7 | This ASP.NET Core middleware lets you authenticate to Active Directory. 8 | 9 | The old school ASP.NET Membership capabilities and Forms Authentication had a nice LDAP provider, and IIS has native Windows Integrated Authentication capability, supporting both NTLM and Kerberos authentication. 10 | 11 | ASP.NET Core doesn't have NTLM/Kerberos authentication middleware and ASP.NET Identity 3 doesn't have an LDAP provider. Usually, IIS handles this (and it still can), but what if you are hosting on Kestrel? This library allows you to do Windows Integrated Authentication with ASP.NET Core. 12 | 13 | ## Status 14 | NTLM is working. Kerberos is not attempted yet. 15 | 16 | Todo: 17 | - Get some unit tests in place 18 | - Implement Kerberos 19 | 20 | ## Getting Started 21 | 1. Review the sample in the `samples` folder. 22 | 2. Either install through the NuGet package: https://www.nuget.org/packages/Microsoft.AspNetCore.Authentication.ActiveDirectory/ 23 | 24 | OR just reference the source code directly. 25 | 3. Add the `Microsoft.AspNetCore.Authentication.ActiveDirectory` library to your project.json file 26 | 4. Add the following line `services.AddAuthentication(options => new ActiveDirectoryCookieOptions());` in your Startup.cs `ConfigureServices` method 27 | 5. Add `app.UseCookieAuthentication(new ActiveDirectoryCookieOptions().ApplicationCookie);` to your Startup.cs `Configure` method 28 | 6. Add the following after the `app.UseCookieAuthentication()` line (Step 4): 29 | 30 | ```cs 31 | app.UseNtlm(new ActiveDirectoryOptions 32 | { 33 | AutomaticAuthenticate = false, 34 | AutomaticChallenge = false, 35 | AuthenticationScheme = ActiveDirectoryOptions.DefaultAuthenticationScheme, 36 | SignInAsAuthenticationScheme = ActiveDirectoryOptions.DefaultAuthenticationScheme, 37 | }); 38 | ``` 39 | At this stage your middleware is accessible through the {site}/windowsauthentication/ntlm endpoint. ReturnUrl will take the user to the page after login. I use this endpoint to perform NTLM handshaking. 40 | 41 | ## Setting up a custom controller URL 42 | If you don't like the default "/windowsauthentication/ntlm", you can use the CallbackPath and LoginPath settings to configure your alternative route. 43 | 44 | ```cs 45 | //ActiveDirectory: set up cookies for client-side session identitfication 46 | app.UseCookieAuthentication( 47 | new ActiveDirectoryCookieOptions( 48 | new CookieAuthenticationOptions() 49 | { 50 | AuthenticationScheme = typeof(ActiveDirectoryCookieOptions).Namespace + ".Application", 51 | AutomaticAuthenticate = true, 52 | AutomaticChallenge = true, 53 | ReturnUrlParameter = "ReturnUrl", 54 | LoginPath = new PathString("/api/windowsauthentication/ntlm"), 55 | }).ApplicationCookie 56 | ); 57 | 58 | //ActiveDirectory: add the NTLM middlware in the pipeline 59 | app.UseNtlm(new ActiveDirectoryOptions 60 | { 61 | AutomaticAuthenticate = false, 62 | AutomaticChallenge = false, 63 | AuthenticationScheme = ActiveDirectoryOptions.DefaultAuthenticationScheme, 64 | SignInAsAuthenticationScheme = ActiveDirectoryOptions.DefaultAuthenticationScheme, 65 | CallbackPath = new PathString("/api/windowsauthentication/ntlm") 66 | }); 67 | ``` 68 | You will need to make sure MVC can resolve the route in UseMvc(): 69 | 70 | ```cs 71 | routes.MapRoute( 72 | name: "authentication", 73 | template: "api/{controller=WindowsAuthentication}/{action=Ntlm}"); 74 | ``` 75 | 76 | ## Events 77 | If you choose to do so, you can subscribe to authentication events thrown from the middleware. To do so, pass an AuthenticationEvents class to the ActiveDirectoryOptions object during startup: 78 | 79 | ```cs 80 | app.UseNtlm(new ActiveDirectoryOptions 81 | { 82 | AutomaticAuthenticate = false, 83 | AutomaticChallenge = false, 84 | AuthenticationScheme = ActiveDirectoryOptions.DefaultAuthenticationScheme, 85 | SignInAsAuthenticationScheme = ActiveDirectoryOptions.DefaultAuthenticationScheme, 86 | 87 | //Optionally, you can handle the events below 88 | Events = new AuthenticationEvents() 89 | { 90 | OnAuthenticationSucceeded = succeededContext => 91 | { 92 | var userName = succeededContext.AuthenticationTicket.Principal.Identity.Name; 93 | 94 | //do something on successful authentication 95 | 96 | return Task.FromResult(null); 97 | }, 98 | OnAuthenticationFailed = failedContext => 99 | { 100 | //do something on failed authentication 101 | 102 | return Task.FromResult(null); 103 | } 104 | } 105 | }); 106 | ``` 107 | 108 | ## Remarks 109 | Achieving server-side NTLM handshaking depends the Windows platform due to interop, dependency on domain-joined machines and secur32.dll. This will naturally limit this library to Windows-based DNX hosts. 110 | 111 | See https://tools.ietf.org/html/rfc4559 for more info on NTLM 112 | 113 | ## Kudos 114 | Most of the code here is based on what Yannic Staudt developed here: https://github.com/pysco68/Pysco68.Owin.Authentication.Ntlm 115 | It is adapted for ASP.NET Core with some changes to the logic. A HUGE thanks for the interop class! 116 | 117 | ##Contribution 118 | Feel free to reach out, I would love to hear if you are using this (or trying to). Pull requests are more than welcome. 119 | -------------------------------------------------------------------------------- /samples/Sample-AspNet5.Mvc6.Ntlm/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.IO; 5 | using System.Threading.Tasks; 6 | 7 | using Microsoft.AspNetCore.Builder; 8 | using Microsoft.AspNetCore.Hosting; 9 | using Microsoft.Extensions.Configuration; 10 | using Microsoft.Extensions.DependencyInjection; 11 | using Microsoft.Extensions.Logging; 12 | using Microsoft.AspNetCore.Authentication.ActiveDirectory; 13 | using Microsoft.AspNetCore.Authentication.ActiveDirectory.Events; 14 | using Microsoft.AspNetCore.Http; 15 | 16 | namespace Sample_AspNet5.Mvc6.Ntlm 17 | { 18 | public class Startup 19 | { 20 | public Startup(IHostingEnvironment env) 21 | { 22 | // Set up configuration sources. 23 | var builder = new ConfigurationBuilder() 24 | .SetBasePath(Directory.GetCurrentDirectory()) 25 | .AddJsonFile("appsettings.json") 26 | .AddEnvironmentVariables(); 27 | Configuration = builder.Build(); 28 | } 29 | 30 | public IConfigurationRoot Configuration { get; set; } 31 | 32 | // This method gets called by the runtime. Use this method to add services to the container. 33 | public void ConfigureServices(IServiceCollection services) 34 | { 35 | //ActiveDirectory: Add the authentication middleware configuration 36 | services.AddAuthentication(options => new ActiveDirectoryCookieOptions()); 37 | 38 | // Add framework services. 39 | services.AddMvc(); 40 | } 41 | 42 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 43 | public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) 44 | { 45 | loggerFactory.AddConsole(Configuration.GetSection("Logging")); 46 | loggerFactory.AddDebug(); 47 | 48 | if (env.IsDevelopment()) 49 | { 50 | // TODO: Fix this for RTM 51 | //app.UseBrowserLink(); 52 | app.UseDeveloperExceptionPage(); 53 | } 54 | else 55 | { 56 | app.UseExceptionHandler("/Home/Error"); 57 | } 58 | 59 | app.UseStaticFiles(); 60 | 61 | 62 | 63 | //ActiveDirectory: set up cookies for client-side session identitfication 64 | //app.UseCookieAuthentication(new ActiveDirectoryCookieOptions().ApplicationCookie); 65 | 66 | //EXAMPLE: using with a custom action URL 67 | app.UseCookieAuthentication( 68 | new ActiveDirectoryCookieOptions( 69 | new CookieAuthenticationOptions() 70 | { 71 | AuthenticationScheme = typeof(ActiveDirectoryCookieOptions).Namespace + ".Application", 72 | AutomaticAuthenticate = true, 73 | AutomaticChallenge = true, 74 | ReturnUrlParameter = "ReturnUrl", 75 | LoginPath = new PathString("/windowsauthentication/ntlm"), 76 | AccessDeniedPath = new PathString("/windowsauthentication/ntlm") 77 | }).ApplicationCookie 78 | ); 79 | 80 | //ActiveDirectory: add the NTLM middlware in the pipeline 81 | app.UseNtlm(new ActiveDirectoryOptions 82 | { 83 | AutomaticAuthenticate = false, 84 | AutomaticChallenge = false, 85 | AuthenticationScheme = ActiveDirectoryOptions.DefaultAuthenticationScheme, 86 | SignInAsAuthenticationScheme = ActiveDirectoryOptions.DefaultAuthenticationScheme, 87 | 88 | //Optionally, you can handle the events below 89 | Events = new AuthenticationEvents() 90 | { 91 | OnAuthenticationSucceeded = succeededContext => 92 | { 93 | var userName = succeededContext.Ticket.Principal.Identity.Name; 94 | 95 | //do something on successful authentication 96 | 97 | return Task.FromResult(null); 98 | }, 99 | OnAuthenticationFailed = failedContext => 100 | { 101 | //do something on failed authentication 102 | 103 | return Task.FromResult(null); 104 | } 105 | } 106 | }); 107 | 108 | 109 | //EXAMPLE: using with a custom action URL 110 | //ActiveDirectory: add the NTLM middlware in the pipeline 111 | //app.UseNtlm(new ActiveDirectoryOptions 112 | //{ 113 | // AutomaticAuthenticate = false, 114 | // AutomaticChallenge = false, 115 | // AuthenticationScheme = ActiveDirectoryOptions.DefaultAuthenticationScheme, 116 | // SignInAsAuthenticationScheme = ActiveDirectoryOptions.DefaultAuthenticationScheme, 117 | // CallbackPath = new PathString("/api/windowsauthentication/ntlm") 118 | //}); 119 | 120 | app.UseMvc(routes => 121 | { 122 | routes.MapRoute( 123 | name: "default", 124 | template: "{controller=Home}/{action=Index}/{id?}"); 125 | 126 | //EXAMPLE: using with a custom action URL 127 | //routes.MapRoute( 128 | // name: "authentication", 129 | // template: "api/{controller=WindowsAuthentication}/{action=Ntlm}"); 130 | 131 | }); 132 | } 133 | 134 | // Entry point for the application. 135 | public static void Main(string[] args) 136 | { 137 | var webHostBuilder = new WebHostBuilder() 138 | .UseStartup() 139 | .UseKestrel() 140 | .UseContentRoot(Directory.GetCurrentDirectory()) 141 | .UseIISIntegration(); 142 | 143 | var webHost = webHostBuilder.Build(); 144 | webHost.Run(); 145 | } 146 | } 147 | } 148 | -------------------------------------------------------------------------------- /samples/Sample-AspNet5.Mvc6.Ntlm/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Home Page"; 3 | } 4 | 5 | 67 | 68 | 111 | -------------------------------------------------------------------------------- /src/Microsoft.AspNetCore.Authentication.ActiveDirectory/HandshakeState.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.AspNetCore.Authentication.ActiveDirectory 2 | { 3 | using Microsoft.AspNetCore.Http.Authentication; 4 | using System; 5 | using System.Security.Principal; 6 | 7 | /// 8 | /// A windows authentication session 9 | /// 10 | public class HandshakeState : IDisposable 11 | { 12 | public HandshakeState() 13 | { 14 | this.Credentials = new SecurityHandle(0); 15 | this.Context = new SecurityHandle(0); 16 | } 17 | 18 | /// 19 | /// Credentials used to validate NTLM hashes 20 | /// 21 | private SecurityHandle Credentials; 22 | 23 | /// 24 | /// Context will be used to validate HTLM hashes 25 | /// 26 | private SecurityHandle Context; 27 | 28 | /// 29 | /// The authentication properties we extract from the authentication challenge 30 | /// received from application layer 31 | /// 32 | public AuthenticationProperties AuthenticationProperties; 33 | 34 | /// 35 | /// The matching windows identity 36 | /// 37 | public WindowsIdentity WindowsIdentity { get; set; } 38 | 39 | /// 40 | /// Try to acquire the server challenge for this state 41 | /// 42 | /// 43 | /// 44 | public bool TryAcquireServerChallenge(ref byte[] message) 45 | { 46 | SecurityBufferDesciption clientToken = new SecurityBufferDesciption(message); 47 | SecurityBufferDesciption serverToken = new SecurityBufferDesciption(Constants.MaximumTokenSize); 48 | 49 | try 50 | { 51 | int result; 52 | var lifetime = new SecurityInteger(0); 53 | 54 | result = Interop.AcquireCredentialsHandle( 55 | null, 56 | "NTLM", 57 | Constants.SecurityCredentialsInbound, 58 | IntPtr.Zero, 59 | IntPtr.Zero, 60 | 0, 61 | IntPtr.Zero, 62 | ref this.Credentials, 63 | ref lifetime); 64 | 65 | if (result != Constants.SuccessfulResult) 66 | { 67 | // Credentials acquire operation failed. 68 | return false; 69 | } 70 | 71 | uint contextAttributes; 72 | 73 | result = Interop.AcceptSecurityContext( 74 | ref this.Credentials, // [in] handle to the credentials 75 | IntPtr.Zero, // [in/out] handle of partially formed context. Always NULL the first time through 76 | ref clientToken, // [in] pointer to the input buffers 77 | Constants.StandardContextAttributes, // [in] required context attributes 78 | Constants.SecurityNativeDataRepresentation, // [in] data representation on the target 79 | out this.Context, // [in/out] receives the new context handle 80 | out serverToken, // [in/out] pointer to the output buffers 81 | out contextAttributes, // [out] receives the context attributes 82 | out lifetime); // [out] receives the life span of the security context 83 | 84 | if (result != Constants.IntermediateResult) 85 | { 86 | // Client challenge issue operation failed. 87 | return false; 88 | } 89 | } 90 | finally 91 | { 92 | message = serverToken.GetBytes(); 93 | clientToken.Dispose(); 94 | serverToken.Dispose(); 95 | } 96 | 97 | return true; 98 | } 99 | 100 | /// 101 | /// Validate the client response and fill the indentity of the token 102 | /// 103 | /// 104 | /// 105 | public bool IsClientResponseValid(byte[] message) 106 | { 107 | SecurityBufferDesciption clientToken = new SecurityBufferDesciption(message); 108 | SecurityBufferDesciption serverToken = new SecurityBufferDesciption(Constants.MaximumTokenSize); 109 | IntPtr securityContextHandle = IntPtr.Zero; 110 | 111 | try 112 | { 113 | int result; 114 | uint contextAttributes; 115 | var lifetime = new SecurityInteger(0); 116 | 117 | result = Interop.AcceptSecurityContext( 118 | ref this.Credentials, // [in] handle to the credentials 119 | ref this.Context, // [in/out] handle of partially formed context. Always NULL the first time through 120 | ref clientToken, // [in] pointer to the input buffers 121 | Constants.StandardContextAttributes, // [in] required context attributes 122 | Constants.SecurityNativeDataRepresentation, // [in] data representation on the target 123 | out this.Context, // [in/out] receives the new context handle 124 | out serverToken, // [in/out] pointer to the output buffers 125 | out contextAttributes, // [out] receives the context attributes 126 | out lifetime); // [out] receives the life span of the security context 127 | 128 | if (result != Constants.SuccessfulResult) 129 | { 130 | return false; 131 | } 132 | 133 | if (Interop.QuerySecurityContextToken(ref this.Context, ref securityContextHandle) != 0) 134 | { 135 | return false; 136 | } 137 | 138 | var identity = new WindowsIdentity(securityContextHandle); 139 | 140 | if (identity == null) 141 | { 142 | return false; 143 | } 144 | 145 | this.WindowsIdentity = identity; 146 | 147 | } 148 | finally 149 | { 150 | clientToken.Dispose(); 151 | serverToken.Dispose(); 152 | 153 | Interop.CloseHandle(securityContextHandle); 154 | 155 | this.Credentials.Reset(); 156 | this.Context.Reset(); 157 | } 158 | 159 | return true; 160 | } 161 | 162 | public void Dispose() 163 | { 164 | this.Context.Reset(); 165 | this.Credentials.Reset(); 166 | this.WindowsIdentity.Dispose(); 167 | } 168 | } 169 | 170 | } 171 | -------------------------------------------------------------------------------- /samples/Sample-AspNet5.Mvc6.Ntlm/Project_Readme.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Welcome to ASP.NET 5 6 | 127 | 128 | 129 | 130 | 138 | 139 |
    140 |
    141 |

    This application consists of:

    142 |
      143 |
    • Sample pages using ASP.NET MVC 6
    • 144 |
    • Gulp and Bower for managing client-side libraries
    • 145 |
    • Theming using Bootstrap
    • 146 |
    147 |
    148 | 160 | 172 | 181 | 182 | 185 |
    186 | 187 | 188 | 189 | -------------------------------------------------------------------------------- /src/Microsoft.AspNetCore.Authentication.ActiveDirectory/Structures.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.AspNetCore.Authentication.ActiveDirectory 2 | { 3 | using System; 4 | using System.Runtime.InteropServices; 5 | 6 | [StructLayout(LayoutKind.Sequential)] 7 | struct SecurityHandle 8 | { 9 | public IntPtr LowPart; 10 | public IntPtr HighPart; 11 | 12 | public SecurityHandle(int dummy) 13 | { 14 | LowPart = HighPart = IntPtr.Zero; 15 | } 16 | 17 | /// 18 | /// Resets all internal pointers to default value 19 | /// 20 | public void Reset() 21 | { 22 | LowPart = HighPart = IntPtr.Zero; 23 | } 24 | } 25 | 26 | [StructLayout(LayoutKind.Sequential)] 27 | struct SecurityInteger 28 | { 29 | public uint LowPart; 30 | public int HighPart; 31 | public SecurityInteger(int dummy) 32 | { 33 | LowPart = 0; 34 | HighPart = 0; 35 | } 36 | } 37 | 38 | [StructLayout(LayoutKind.Sequential)] 39 | struct SecurityBuffer : IDisposable 40 | { 41 | public int cbBuffer; 42 | public int cbBufferType; 43 | public IntPtr pvBuffer; 44 | 45 | public SecurityBuffer(int bufferSize) 46 | { 47 | cbBuffer = bufferSize; 48 | cbBufferType = (int)SecurityBufferType.SECBUFFER_TOKEN; 49 | pvBuffer = Marshal.AllocHGlobal(bufferSize); 50 | } 51 | 52 | public SecurityBuffer(byte[] secBufferBytes) 53 | { 54 | cbBuffer = secBufferBytes.Length; 55 | cbBufferType = (int)SecurityBufferType.SECBUFFER_TOKEN; 56 | pvBuffer = Marshal.AllocHGlobal(cbBuffer); 57 | Marshal.Copy(secBufferBytes, 0, pvBuffer, cbBuffer); 58 | } 59 | 60 | public SecurityBuffer(byte[] secBufferBytes, SecurityBufferType bufferType) 61 | { 62 | cbBuffer = secBufferBytes.Length; 63 | cbBufferType = (int)bufferType; 64 | pvBuffer = Marshal.AllocHGlobal(cbBuffer); 65 | Marshal.Copy(secBufferBytes, 0, pvBuffer, cbBuffer); 66 | } 67 | 68 | public void Dispose() 69 | { 70 | if (pvBuffer != IntPtr.Zero) 71 | { 72 | Marshal.FreeHGlobal(pvBuffer); 73 | pvBuffer = IntPtr.Zero; 74 | } 75 | } 76 | } 77 | 78 | [StructLayout(LayoutKind.Sequential)] 79 | struct SecurityBufferDesciption : IDisposable 80 | { 81 | 82 | public int ulVersion; 83 | public int cBuffers; 84 | public IntPtr pBuffers; //Point to SecBuffer 85 | 86 | public SecurityBufferDesciption(int bufferSize) 87 | { 88 | ulVersion = (int)SecurityBufferType.SECBUFFER_VERSION; 89 | cBuffers = 1; 90 | SecurityBuffer ThisSecBuffer = new SecurityBuffer(bufferSize); 91 | pBuffers = Marshal.AllocHGlobal(Marshal.SizeOf(ThisSecBuffer)); 92 | Marshal.StructureToPtr(ThisSecBuffer, pBuffers, false); 93 | } 94 | 95 | public SecurityBufferDesciption(byte[] secBufferBytes) 96 | { 97 | ulVersion = (int)SecurityBufferType.SECBUFFER_VERSION; 98 | cBuffers = 1; 99 | SecurityBuffer ThisSecBuffer = new SecurityBuffer(secBufferBytes); 100 | pBuffers = Marshal.AllocHGlobal(Marshal.SizeOf(ThisSecBuffer)); 101 | Marshal.StructureToPtr(ThisSecBuffer, pBuffers, false); 102 | } 103 | 104 | public SecurityBufferDesciption(BufferWrapper[] secBufferBytesArray) 105 | { 106 | if (secBufferBytesArray == null || secBufferBytesArray.Length == 0) 107 | { 108 | throw new ArgumentException("secBufferBytesArray cannot be null or 0 length"); 109 | } 110 | 111 | ulVersion = (int)SecurityBufferType.SECBUFFER_VERSION; 112 | cBuffers = secBufferBytesArray.Length; 113 | 114 | //Allocate memory for SecBuffer Array.... 115 | pBuffers = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Buffer)) * cBuffers); 116 | 117 | for (int Index = 0; Index < secBufferBytesArray.Length; Index++) 118 | { 119 | //Super hack: Now allocate memory for the individual SecBuffers 120 | //and just copy the bit values to the SecBuffer array!!! 121 | SecurityBuffer ThisSecBuffer = new SecurityBuffer(secBufferBytesArray[Index].Buffer, secBufferBytesArray[Index].BufferType); 122 | 123 | //We will write out bits in the following order: 124 | //int cbBuffer; 125 | //int BufferType; 126 | //pvBuffer; 127 | //Note that we won't be releasing the memory allocated by ThisSecBuffer until we 128 | //are disposed... 129 | int CurrentOffset = Index * Marshal.SizeOf(typeof(Buffer)); 130 | Marshal.WriteInt32(pBuffers, CurrentOffset, ThisSecBuffer.cbBuffer); 131 | Marshal.WriteInt32(pBuffers, CurrentOffset + Marshal.SizeOf(ThisSecBuffer.cbBuffer), ThisSecBuffer.cbBufferType); 132 | Marshal.WriteIntPtr(pBuffers, CurrentOffset + Marshal.SizeOf(ThisSecBuffer.cbBuffer) + Marshal.SizeOf(ThisSecBuffer.cbBufferType), ThisSecBuffer.pvBuffer); 133 | } 134 | } 135 | 136 | public void Dispose() 137 | { 138 | if (pBuffers != IntPtr.Zero) 139 | { 140 | if (cBuffers == 1) 141 | { 142 | SecurityBuffer ThisSecBuffer = (SecurityBuffer)Marshal.PtrToStructure(pBuffers); 143 | ThisSecBuffer.Dispose(); 144 | } 145 | else 146 | { 147 | for (int Index = 0; Index < cBuffers; Index++) 148 | { 149 | //The bits were written out the following order: 150 | //int cbBuffer; 151 | //int BufferType; 152 | //pvBuffer; 153 | //What we need to do here is to grab a hold of the pvBuffer allocate by the individual 154 | //SecBuffer and release it... 155 | int CurrentOffset = Index * Marshal.SizeOf(typeof(Buffer)); 156 | IntPtr SecBufferpvBuffer = Marshal.ReadIntPtr(pBuffers, CurrentOffset + Marshal.SizeOf() + Marshal.SizeOf()); 157 | Marshal.FreeHGlobal(SecBufferpvBuffer); 158 | } 159 | } 160 | 161 | Marshal.FreeHGlobal(pBuffers); 162 | pBuffers = IntPtr.Zero; 163 | } 164 | } 165 | 166 | public byte[] GetBytes() 167 | { 168 | byte[] Buffer = null; 169 | 170 | if (pBuffers == IntPtr.Zero) 171 | { 172 | throw new InvalidOperationException("Object has already been disposed!!!"); 173 | } 174 | 175 | if (cBuffers == 1) 176 | { 177 | SecurityBuffer ThisSecBuffer = (SecurityBuffer)Marshal.PtrToStructure(pBuffers); 178 | 179 | if (ThisSecBuffer.cbBuffer > 0) 180 | { 181 | Buffer = new byte[ThisSecBuffer.cbBuffer]; 182 | Marshal.Copy(ThisSecBuffer.pvBuffer, Buffer, 0, ThisSecBuffer.cbBuffer); 183 | } 184 | } 185 | else 186 | { 187 | int BytesToAllocate = 0; 188 | 189 | for (int Index = 0; Index < cBuffers; Index++) 190 | { 191 | //The bits were written out the following order: 192 | //int cbBuffer; 193 | //int BufferType; 194 | //pvBuffer; 195 | //What we need to do here calculate the total number of bytes we need to copy... 196 | int CurrentOffset = Index * Marshal.SizeOf(typeof(Buffer)); 197 | BytesToAllocate += Marshal.ReadInt32(pBuffers, CurrentOffset); 198 | } 199 | 200 | Buffer = new byte[BytesToAllocate]; 201 | 202 | for (int Index = 0, BufferIndex = 0; Index < cBuffers; Index++) 203 | { 204 | //The bits were written out the following order: 205 | //int cbBuffer; 206 | //int BufferType; 207 | //pvBuffer; 208 | //Now iterate over the individual buffers and put them together into a 209 | //byte array... 210 | int CurrentOffset = Index * Marshal.SizeOf(typeof(Buffer)); 211 | int BytesToCopy = Marshal.ReadInt32(pBuffers, CurrentOffset); 212 | IntPtr SecBufferpvBuffer = Marshal.ReadIntPtr(pBuffers, CurrentOffset + Marshal.SizeOf() + Marshal.SizeOf()); 213 | Marshal.Copy(SecBufferpvBuffer, Buffer, BufferIndex, BytesToCopy); 214 | BufferIndex += BytesToCopy; 215 | } 216 | } 217 | 218 | return (Buffer); 219 | } 220 | } 221 | 222 | 223 | struct BufferWrapper 224 | { 225 | public byte[] Buffer; 226 | public SecurityBufferType BufferType; 227 | 228 | public BufferWrapper(byte[] buffer, SecurityBufferType bufferType) 229 | { 230 | if (buffer == null || buffer.Length == 0) 231 | { 232 | throw new ArgumentException("buffer cannot be null or 0 length"); 233 | } 234 | 235 | Buffer = buffer; 236 | BufferType = bufferType; 237 | } 238 | }; 239 | 240 | } 241 | -------------------------------------------------------------------------------- /src/Microsoft.AspNetCore.Authentication.ActiveDirectory/NtlmAuthenticationHandler.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Authentication; 2 | using Microsoft.AspNetCore.Http.Authentication; 3 | using Microsoft.Extensions.Logging; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Security.Claims; 8 | using System.Security.Cryptography; 9 | using System.Threading.Tasks; 10 | using System.Text; 11 | using Microsoft.AspNetCore.Http.Features.Authentication; 12 | using Microsoft.AspNetCore.Builder; 13 | 14 | namespace Microsoft.AspNetCore.Authentication.ActiveDirectory 15 | { 16 | public class NtlmAuthenticationHandler : AuthenticationHandler 17 | { 18 | private const string RedirectToEndpointKey = "NtlmAuthenticationHandlerRedirectToEndpoint"; 19 | private const string RespondNoNtlmKey = "NtlmAuthenticationHandlerRespondNoNtlm"; 20 | private const string RespondType2Key = "NtlmAuthenticationHandlerRespondType2"; 21 | private const string AuthenticatedKey = "NtlmAuthenticationHandlerAuthenticated"; 22 | private const string LocationKey = "LocationKey"; 23 | private const string NtlmAuthUniqueIdCookieKey = "NtlmAuthUniqueId"; 24 | 25 | protected override Task FinishResponseAsync() 26 | { 27 | //We need to fix the issues that the CookieAuthenticationHandler is leaving behind 28 | //CookieAuthenticationHandler doesn't work well with NTLM handshaking 29 | //but we need it to retain the session and remove unnecessary handshaking 30 | if (Response.StatusCode == 302) 31 | { 32 | if (Context.Items.ContainsKey(RespondNoNtlmKey) || 33 | Context.Items.ContainsKey(RespondType2Key)) 34 | { 35 | //we're cleaning up the location set by CookieAuthenticationHandler.HandleUnauthorizedAsync 36 | Response.Headers.Remove(LocationKey); 37 | Response.StatusCode = 401; 38 | } 39 | 40 | if ((Context.Items.ContainsKey(AuthenticatedKey)) 41 | && Request.Query.ContainsKey(Options.Cookies.ApplicationCookie.ReturnUrlParameter)) 42 | { 43 | //we're cleaning up the location set by CookieAuthenticationHandler.HandleUnauthorizedAsync 44 | Response.Redirect(Request.Query[Options.Cookies.ApplicationCookie.ReturnUrlParameter]); 45 | } 46 | } 47 | 48 | //The following prevents the Cookie auth middleware to set the response to 403 Forbidden 49 | if ((Response.StatusCode == 401) && 50 | (Context.Items.ContainsKey(RespondNoNtlmKey)) || 51 | (Context.Items.ContainsKey(RespondType2Key))) 52 | { 53 | if (PriorHandler.GetType().FullName == "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler") 54 | { 55 | var challengeContext = new ChallengeContext(ActiveDirectoryOptions.DefaultAuthenticationScheme); 56 | PriorHandler.ChallengeAsync(challengeContext); 57 | } 58 | } 59 | 60 | return base.FinishResponseAsync(); 61 | } 62 | 63 | protected override async Task HandleAuthenticateAsync() 64 | { 65 | //if accessed from a different URL - ignore 66 | if (!Request.Path.Equals(Options.CallbackPath)) 67 | { 68 | Context.Items[RedirectToEndpointKey] = true; 69 | Response.StatusCode = 302; 70 | return AuthenticateResult.Fail("Redirecting to authentication route /windowsauthentication/ntlm"); 71 | } 72 | 73 | //check if the request has an NTLM header 74 | var authorizationHeader = Request.Headers["Authorization"]; 75 | 76 | byte[] token = null; 77 | var hasNtlm = authorizationHeader.Any(h => h.StartsWith("NTLM ")); 78 | if (!hasNtlm) 79 | { 80 | // This code runs under following conditions: 81 | // - authentication failed (in either step: IsClientResponseValid() or TryAcquireServerChallenge()) 82 | // - there's no token in the headers 83 | // 84 | // This means we've got to set the WWW-Authenticate header and return a 401 85 | // 401 tells the browser that the request is unauthenticated and the WWW-Authenticate 86 | // header tells the browser to try again with NTLM 87 | Response.Headers.Add("WWW-Authenticate", new[] { "NTLM" }); 88 | Response.StatusCode = 401; 89 | Context.Items[RespondNoNtlmKey] = true; 90 | 91 | //We're creating a unique guid to identify the client between the 92 | //Type 2 and Type 3 handshake 93 | var requestUniqueId = Guid.NewGuid(); 94 | Response.Cookies.Append(NtlmAuthUniqueIdCookieKey, requestUniqueId.ToString()); 95 | 96 | return AuthenticateResult.Fail("No NTLM header, returning WWW-Authenticate NTLM."); 97 | } 98 | 99 | if (!string.IsNullOrEmpty(authorizationHeader) && hasNtlm) 100 | { 101 | var header = authorizationHeader.First(h => h.StartsWith("NTLM ")); 102 | token = Convert.FromBase64String(header.Substring(5)); 103 | } 104 | 105 | var responseUniqueId = Request.Cookies[NtlmAuthUniqueIdCookieKey]; 106 | HandshakeState state = null; 107 | //see if the response is from a known client handshake 108 | if (!string.IsNullOrWhiteSpace(responseUniqueId)) 109 | { 110 | this.Options.LoginStateCache.TryGet(responseUniqueId, out state); 111 | } 112 | 113 | if (state == null) state = new HandshakeState(); 114 | 115 | // First eight bytes are header containing NTLMSSP\0 signature 116 | // Next byte contains type of the message recieved. 117 | // No Token - it's the initial request. Add a authenticate header 118 | // Message Type 1 — is initial client's response to server's 401 Unauthorized error. 119 | // Message Type 2 — is the server's response to it. Contains random 8 bytes challenge. 120 | // Message Type 3 — is encrypted password hashes from client ready to server validation. 121 | if (token != null && token[8] == 1) 122 | { 123 | // Message of type 1 was received 124 | if (state.TryAcquireServerChallenge(ref token)) 125 | { 126 | // send the type 2 message 127 | var authorization = Convert.ToBase64String(token); 128 | Response.Headers.Add("WWW-Authenticate", new[] { string.Concat("NTLM ", authorization) }); 129 | Response.StatusCode = 401; 130 | 131 | Options.LoginStateCache.Add(responseUniqueId, state); 132 | Context.Items[RespondType2Key] = true; 133 | 134 | return AuthenticateResult.Fail("Received NTLM Type 1, sending Type 2 with status 401."); 135 | } 136 | } 137 | else if (token != null && token[8] == 3) 138 | { 139 | // message of type 3 was received, we validate it 140 | if (state.IsClientResponseValid(token)) 141 | { 142 | // Authorization successful 143 | var properties = state.AuthenticationProperties; 144 | 145 | if (Options.Filter == null || Options.Filter.Invoke(state.WindowsIdentity, Request)) 146 | { 147 | AuthenticationTicket ticket = await CreateAuthenticationTicket(state.WindowsIdentity.Claims, properties); 148 | 149 | // We don't need that state anymore 150 | Options.LoginStateCache.TryRemove(responseUniqueId); 151 | 152 | //throw the succeded event 153 | await Options.Events.AuthenticationSucceeded(new Events.AuthenticationSucceededContext(Context, Options) 154 | { 155 | Ticket = ticket //pass the ticket 156 | }); 157 | 158 | return AuthenticateResult.Success(ticket); 159 | } 160 | } 161 | } 162 | 163 | await Options.Events.AuthenticationFailed(new Events.AuthenticationFailedContext(Context, Options)); 164 | 165 | return AuthenticateResult.Fail("Unauthorized"); 166 | } 167 | 168 | private async Task CreateAuthenticationTicket(IEnumerable claims, AuthenticationProperties properties) 169 | { 170 | // we need to create a new identity using the sign in type that 171 | // the cookie authentication is listening for 172 | var identity = new ClaimsIdentity(Options.Cookies.ApplicationCookie.AuthenticationScheme); 173 | 174 | //Add WindowsIdentity claims to the Identity object 175 | identity.AddClaims(claims); 176 | 177 | // create the authentication ticket 178 | var principal = new ClaimsPrincipal(identity); 179 | var ticket = new AuthenticationTicket 180 | (principal, properties, 181 | Options.Cookies.ApplicationCookie.AuthenticationScheme); 182 | 183 | //handle the sign in method of the auth middleware 184 | await Context.Authentication.SignInAsync 185 | (Options.Cookies.ApplicationCookie.AuthenticationScheme, 186 | principal, properties); 187 | 188 | Context.Items[AuthenticatedKey] = true; 189 | return ticket; 190 | } 191 | 192 | protected override async Task HandleUnauthorizedAsync(ChallengeContext context) 193 | { 194 | if (Response.StatusCode != 302) 195 | await base.HandleUnauthorizedAsync(context); 196 | 197 | return true; 198 | } 199 | 200 | public override async Task HandleRequestAsync() 201 | { 202 | //var authContext = new AuthenticateContext(Options.Cookies.ApplicationCookie.AuthenticationScheme); 203 | //await this.Context.Authentication.AuthenticateAsync(authContext); 204 | return await base.HandleRequestAsync(); 205 | } 206 | 207 | protected override async Task HandleSignInAsync(SignInContext context) 208 | { 209 | await base.HandleSignInAsync(context); 210 | SignInAccepted = true; 211 | } 212 | 213 | protected override Task HandleForbiddenAsync(ChallengeContext context) 214 | { 215 | return base.HandleForbiddenAsync(context); 216 | } 217 | 218 | protected override async Task HandleSignOutAsync(SignOutContext context) 219 | { 220 | await Context.Authentication.SignOutAsync(Options.Cookies.ApplicationCookie.AuthenticationScheme); 221 | await base.HandleSignOutAsync(context); 222 | } 223 | } 224 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /samples/Sample-AspNet5.Mvc6.Ntlm/wwwroot/lib/jquery-validation/dist/additional-methods.min.js: -------------------------------------------------------------------------------- 1 | /*! jQuery Validation Plugin - v1.14.0 - 6/30/2015 2 | * http://jqueryvalidation.org/ 3 | * Copyright (c) 2015 Jörn Zaefferer; Licensed MIT */ 4 | !function(a){"function"==typeof define&&define.amd?define(["jquery","./jquery.validate.min"],a):a(jQuery)}(function(a){!function(){function b(a){return a.replace(/<.[^<>]*?>/g," ").replace(/ | /gi," ").replace(/[.(),;:!?%#$'\"_+=\/\-“”’]*/g,"")}a.validator.addMethod("maxWords",function(a,c,d){return this.optional(c)||b(a).match(/\b\w+\b/g).length<=d},a.validator.format("Please enter {0} words or less.")),a.validator.addMethod("minWords",function(a,c,d){return this.optional(c)||b(a).match(/\b\w+\b/g).length>=d},a.validator.format("Please enter at least {0} words.")),a.validator.addMethod("rangeWords",function(a,c,d){var e=b(a),f=/\b\w+\b/g;return this.optional(c)||e.match(f).length>=d[0]&&e.match(f).length<=d[1]},a.validator.format("Please enter between {0} and {1} words."))}(),a.validator.addMethod("accept",function(b,c,d){var e,f,g="string"==typeof d?d.replace(/\s/g,"").replace(/,/g,"|"):"image/*",h=this.optional(c);if(h)return h;if("file"===a(c).attr("type")&&(g=g.replace(/\*/g,".*"),c.files&&c.files.length))for(e=0;ec;c++)d=h-c,e=f.substring(c,c+1),g+=d*e;return g%11===0},"Please specify a valid bank account number"),a.validator.addMethod("bankorgiroaccountNL",function(b,c){return this.optional(c)||a.validator.methods.bankaccountNL.call(this,b,c)||a.validator.methods.giroaccountNL.call(this,b,c)},"Please specify a valid bank or giro account number"),a.validator.addMethod("bic",function(a,b){return this.optional(b)||/^([A-Z]{6}[A-Z2-9][A-NP-Z1-2])(X{3}|[A-WY-Z0-9][A-Z0-9]{2})?$/.test(a)},"Please specify a valid BIC code"),a.validator.addMethod("cifES",function(a){"use strict";var b,c,d,e,f,g,h=[];if(a=a.toUpperCase(),!a.match("((^[A-Z]{1}[0-9]{7}[A-Z0-9]{1}$|^[T]{1}[A-Z0-9]{8}$)|^[0-9]{8}[A-Z]{1}$)"))return!1;for(d=0;9>d;d++)h[d]=parseInt(a.charAt(d),10);for(c=h[2]+h[4]+h[6],e=1;8>e;e+=2)f=(2*h[e]).toString(),g=f.charAt(1),c+=parseInt(f.charAt(0),10)+(""===g?0:parseInt(g,10));return/^[ABCDEFGHJNPQRSUVW]{1}/.test(a)?(c+="",b=10-parseInt(c.charAt(c.length-1),10),a+=b,h[8].toString()===String.fromCharCode(64+b)||h[8].toString()===a.charAt(a.length-1)):!1},"Please specify a valid CIF number."),a.validator.addMethod("cpfBR",function(a){if(a=a.replace(/([~!@#$%^&*()_+=`{}\[\]\-|\\:;'<>,.\/? ])+/g,""),11!==a.length)return!1;var b,c,d,e,f=0;if(b=parseInt(a.substring(9,10),10),c=parseInt(a.substring(10,11),10),d=function(a,b){var c=10*a%11;return(10===c||11===c)&&(c=0),c===b},""===a||"00000000000"===a||"11111111111"===a||"22222222222"===a||"33333333333"===a||"44444444444"===a||"55555555555"===a||"66666666666"===a||"77777777777"===a||"88888888888"===a||"99999999999"===a)return!1;for(e=1;9>=e;e++)f+=parseInt(a.substring(e-1,e),10)*(11-e);if(d(f,b)){for(f=0,e=1;10>=e;e++)f+=parseInt(a.substring(e-1,e),10)*(12-e);return d(f,c)}return!1},"Please specify a valid CPF number"),a.validator.addMethod("creditcardtypes",function(a,b,c){if(/[^0-9\-]+/.test(a))return!1;a=a.replace(/\D/g,"");var d=0;return c.mastercard&&(d|=1),c.visa&&(d|=2),c.amex&&(d|=4),c.dinersclub&&(d|=8),c.enroute&&(d|=16),c.discover&&(d|=32),c.jcb&&(d|=64),c.unknown&&(d|=128),c.all&&(d=255),1&d&&/^(5[12345])/.test(a)?16===a.length:2&d&&/^(4)/.test(a)?16===a.length:4&d&&/^(3[47])/.test(a)?15===a.length:8&d&&/^(3(0[012345]|[68]))/.test(a)?14===a.length:16&d&&/^(2(014|149))/.test(a)?15===a.length:32&d&&/^(6011)/.test(a)?16===a.length:64&d&&/^(3)/.test(a)?16===a.length:64&d&&/^(2131|1800)/.test(a)?15===a.length:128&d?!0:!1},"Please enter a valid credit card number."),a.validator.addMethod("currency",function(a,b,c){var d,e="string"==typeof c,f=e?c:c[0],g=e?!0:c[1];return f=f.replace(/,/g,""),f=g?f+"]":f+"]?",d="^["+f+"([1-9]{1}[0-9]{0,2}(\\,[0-9]{3})*(\\.[0-9]{0,2})?|[1-9]{1}[0-9]{0,}(\\.[0-9]{0,2})?|0(\\.[0-9]{0,2})?|(\\.[0-9]{1,2})?)$",d=new RegExp(d),this.optional(b)||d.test(a)},"Please specify a valid currency"),a.validator.addMethod("dateFA",function(a,b){return this.optional(b)||/^[1-4]\d{3}\/((0?[1-6]\/((3[0-1])|([1-2][0-9])|(0?[1-9])))|((1[0-2]|(0?[7-9]))\/(30|([1-2][0-9])|(0?[1-9]))))$/.test(a)},a.validator.messages.date),a.validator.addMethod("dateITA",function(a,b){var c,d,e,f,g,h=!1,i=/^\d{1,2}\/\d{1,2}\/\d{4}$/;return i.test(a)?(c=a.split("/"),d=parseInt(c[0],10),e=parseInt(c[1],10),f=parseInt(c[2],10),g=new Date(Date.UTC(f,e-1,d,12,0,0,0)),h=g.getUTCFullYear()===f&&g.getUTCMonth()===e-1&&g.getUTCDate()===d?!0:!1):h=!1,this.optional(b)||h},a.validator.messages.date),a.validator.addMethod("dateNL",function(a,b){return this.optional(b)||/^(0?[1-9]|[12]\d|3[01])[\.\/\-](0?[1-9]|1[012])[\.\/\-]([12]\d)?(\d\d)$/.test(a)},a.validator.messages.date),a.validator.addMethod("extension",function(a,b,c){return c="string"==typeof c?c.replace(/,/g,"|"):"png|jpe?g|gif",this.optional(b)||a.match(new RegExp("\\.("+c+")$","i"))},a.validator.format("Please enter a value with a valid extension.")),a.validator.addMethod("giroaccountNL",function(a,b){return this.optional(b)||/^[0-9]{1,7}$/.test(a)},"Please specify a valid giro account number"),a.validator.addMethod("iban",function(a,b){if(this.optional(b))return!0;var c,d,e,f,g,h,i,j,k,l=a.replace(/ /g,"").toUpperCase(),m="",n=!0,o="",p="";if(c=l.substring(0,2),h={AL:"\\d{8}[\\dA-Z]{16}",AD:"\\d{8}[\\dA-Z]{12}",AT:"\\d{16}",AZ:"[\\dA-Z]{4}\\d{20}",BE:"\\d{12}",BH:"[A-Z]{4}[\\dA-Z]{14}",BA:"\\d{16}",BR:"\\d{23}[A-Z][\\dA-Z]",BG:"[A-Z]{4}\\d{6}[\\dA-Z]{8}",CR:"\\d{17}",HR:"\\d{17}",CY:"\\d{8}[\\dA-Z]{16}",CZ:"\\d{20}",DK:"\\d{14}",DO:"[A-Z]{4}\\d{20}",EE:"\\d{16}",FO:"\\d{14}",FI:"\\d{14}",FR:"\\d{10}[\\dA-Z]{11}\\d{2}",GE:"[\\dA-Z]{2}\\d{16}",DE:"\\d{18}",GI:"[A-Z]{4}[\\dA-Z]{15}",GR:"\\d{7}[\\dA-Z]{16}",GL:"\\d{14}",GT:"[\\dA-Z]{4}[\\dA-Z]{20}",HU:"\\d{24}",IS:"\\d{22}",IE:"[\\dA-Z]{4}\\d{14}",IL:"\\d{19}",IT:"[A-Z]\\d{10}[\\dA-Z]{12}",KZ:"\\d{3}[\\dA-Z]{13}",KW:"[A-Z]{4}[\\dA-Z]{22}",LV:"[A-Z]{4}[\\dA-Z]{13}",LB:"\\d{4}[\\dA-Z]{20}",LI:"\\d{5}[\\dA-Z]{12}",LT:"\\d{16}",LU:"\\d{3}[\\dA-Z]{13}",MK:"\\d{3}[\\dA-Z]{10}\\d{2}",MT:"[A-Z]{4}\\d{5}[\\dA-Z]{18}",MR:"\\d{23}",MU:"[A-Z]{4}\\d{19}[A-Z]{3}",MC:"\\d{10}[\\dA-Z]{11}\\d{2}",MD:"[\\dA-Z]{2}\\d{18}",ME:"\\d{18}",NL:"[A-Z]{4}\\d{10}",NO:"\\d{11}",PK:"[\\dA-Z]{4}\\d{16}",PS:"[\\dA-Z]{4}\\d{21}",PL:"\\d{24}",PT:"\\d{21}",RO:"[A-Z]{4}[\\dA-Z]{16}",SM:"[A-Z]\\d{10}[\\dA-Z]{12}",SA:"\\d{2}[\\dA-Z]{18}",RS:"\\d{18}",SK:"\\d{20}",SI:"\\d{15}",ES:"\\d{20}",SE:"\\d{20}",CH:"\\d{5}[\\dA-Z]{12}",TN:"\\d{20}",TR:"\\d{5}[\\dA-Z]{17}",AE:"\\d{3}\\d{16}",GB:"[A-Z]{4}\\d{14}",VG:"[\\dA-Z]{4}\\d{16}"},g=h[c],"undefined"!=typeof g&&(i=new RegExp("^[A-Z]{2}\\d{2}"+g+"$",""),!i.test(l)))return!1;for(d=l.substring(4,l.length)+l.substring(0,4),j=0;j9&&a.match(/^(?:(?:(?:00\s?|\+)44\s?|0)7(?:[1345789]\d{2}|624)\s?\d{3}\s?\d{3})$/)},"Please specify a valid mobile number"),a.validator.addMethod("nieES",function(a){"use strict";return a=a.toUpperCase(),a.match("((^[A-Z]{1}[0-9]{7}[A-Z0-9]{1}$|^[T]{1}[A-Z0-9]{8}$)|^[0-9]{8}[A-Z]{1}$)")?/^[T]{1}/.test(a)?a[8]===/^[T]{1}[A-Z0-9]{8}$/.test(a):/^[XYZ]{1}/.test(a)?a[8]==="TRWAGMYFPDXBNJZSQVHLCKE".charAt(a.replace("X","0").replace("Y","1").replace("Z","2").substring(0,8)%23):!1:!1},"Please specify a valid NIE number."),a.validator.addMethod("nifES",function(a){"use strict";return a=a.toUpperCase(),a.match("((^[A-Z]{1}[0-9]{7}[A-Z0-9]{1}$|^[T]{1}[A-Z0-9]{8}$)|^[0-9]{8}[A-Z]{1}$)")?/^[0-9]{8}[A-Z]{1}$/.test(a)?"TRWAGMYFPDXBNJZSQVHLCKE".charAt(a.substring(8,0)%23)===a.charAt(8):/^[KLM]{1}/.test(a)?a[8]===String.fromCharCode(64):!1:!1},"Please specify a valid NIF number."),jQuery.validator.addMethod("notEqualTo",function(b,c,d){return this.optional(c)||!a.validator.methods.equalTo.call(this,b,c,d)},"Please enter a different value, values must not be the same."),a.validator.addMethod("nowhitespace",function(a,b){return this.optional(b)||/^\S+$/i.test(a)},"No white space please"),a.validator.addMethod("pattern",function(a,b,c){return this.optional(b)?!0:("string"==typeof c&&(c=new RegExp("^(?:"+c+")$")),c.test(a))},"Invalid format."),a.validator.addMethod("phoneNL",function(a,b){return this.optional(b)||/^((\+|00(\s|\s?\-\s?)?)31(\s|\s?\-\s?)?(\(0\)[\-\s]?)?|0)[1-9]((\s|\s?\-\s?)?[0-9]){8}$/.test(a)},"Please specify a valid phone number."),a.validator.addMethod("phoneUK",function(a,b){return a=a.replace(/\(|\)|\s+|-/g,""),this.optional(b)||a.length>9&&a.match(/^(?:(?:(?:00\s?|\+)44\s?)|(?:\(?0))(?:\d{2}\)?\s?\d{4}\s?\d{4}|\d{3}\)?\s?\d{3}\s?\d{3,4}|\d{4}\)?\s?(?:\d{5}|\d{3}\s?\d{3})|\d{5}\)?\s?\d{4,5})$/)},"Please specify a valid phone number"),a.validator.addMethod("phoneUS",function(a,b){return a=a.replace(/\s+/g,""),this.optional(b)||a.length>9&&a.match(/^(\+?1-?)?(\([2-9]([02-9]\d|1[02-9])\)|[2-9]([02-9]\d|1[02-9]))-?[2-9]([02-9]\d|1[02-9])-?\d{4}$/)},"Please specify a valid phone number"),a.validator.addMethod("phonesUK",function(a,b){return a=a.replace(/\(|\)|\s+|-/g,""),this.optional(b)||a.length>9&&a.match(/^(?:(?:(?:00\s?|\+)44\s?|0)(?:1\d{8,9}|[23]\d{9}|7(?:[1345789]\d{8}|624\d{6})))$/)},"Please specify a valid uk phone number"),a.validator.addMethod("postalCodeCA",function(a,b){return this.optional(b)||/^[ABCEGHJKLMNPRSTVXY]\d[A-Z] \d[A-Z]\d$/.test(a)},"Please specify a valid postal code"),a.validator.addMethod("postalcodeBR",function(a,b){return this.optional(b)||/^\d{2}.\d{3}-\d{3}?$|^\d{5}-?\d{3}?$/.test(a)},"Informe um CEP válido."),a.validator.addMethod("postalcodeIT",function(a,b){return this.optional(b)||/^\d{5}$/.test(a)},"Please specify a valid postal code"),a.validator.addMethod("postalcodeNL",function(a,b){return this.optional(b)||/^[1-9][0-9]{3}\s?[a-zA-Z]{2}$/.test(a)},"Please specify a valid postal code"),a.validator.addMethod("postcodeUK",function(a,b){return this.optional(b)||/^((([A-PR-UWYZ][0-9])|([A-PR-UWYZ][0-9][0-9])|([A-PR-UWYZ][A-HK-Y][0-9])|([A-PR-UWYZ][A-HK-Y][0-9][0-9])|([A-PR-UWYZ][0-9][A-HJKSTUW])|([A-PR-UWYZ][A-HK-Y][0-9][ABEHMNPRVWXY]))\s?([0-9][ABD-HJLNP-UW-Z]{2})|(GIR)\s?(0AA))$/i.test(a)},"Please specify a valid UK postcode"),a.validator.addMethod("require_from_group",function(b,c,d){var e=a(d[1],c.form),f=e.eq(0),g=f.data("valid_req_grp")?f.data("valid_req_grp"):a.extend({},this),h=e.filter(function(){return g.elementValue(this)}).length>=d[0];return f.data("valid_req_grp",g),a(c).data("being_validated")||(e.data("being_validated",!0),e.each(function(){g.element(this)}),e.data("being_validated",!1)),h},a.validator.format("Please fill at least {0} of these fields.")),a.validator.addMethod("skip_or_fill_minimum",function(b,c,d){var e=a(d[1],c.form),f=e.eq(0),g=f.data("valid_skip")?f.data("valid_skip"):a.extend({},this),h=e.filter(function(){return g.elementValue(this)}).length,i=0===h||h>=d[0];return f.data("valid_skip",g),a(c).data("being_validated")||(e.data("being_validated",!0),e.each(function(){g.element(this)}),e.data("being_validated",!1)),i},a.validator.format("Please either skip these fields or fill at least {0} of them.")),a.validator.addMethod("stateUS",function(a,b,c){var d,e="undefined"==typeof c,f=e||"undefined"==typeof c.caseSensitive?!1:c.caseSensitive,g=e||"undefined"==typeof c.includeTerritories?!1:c.includeTerritories,h=e||"undefined"==typeof c.includeMilitary?!1:c.includeMilitary;return d=g||h?g&&h?"^(A[AEKLPRSZ]|C[AOT]|D[CE]|FL|G[AU]|HI|I[ADLN]|K[SY]|LA|M[ADEINOPST]|N[CDEHJMVY]|O[HKR]|P[AR]|RI|S[CD]|T[NX]|UT|V[AIT]|W[AIVY])$":g?"^(A[KLRSZ]|C[AOT]|D[CE]|FL|G[AU]|HI|I[ADLN]|K[SY]|LA|M[ADEINOPST]|N[CDEHJMVY]|O[HKR]|P[AR]|RI|S[CD]|T[NX]|UT|V[AIT]|W[AIVY])$":"^(A[AEKLPRZ]|C[AOT]|D[CE]|FL|GA|HI|I[ADLN]|K[SY]|LA|M[ADEINOST]|N[CDEHJMVY]|O[HKR]|PA|RI|S[CD]|T[NX]|UT|V[AT]|W[AIVY])$":"^(A[KLRZ]|C[AOT]|D[CE]|FL|GA|HI|I[ADLN]|K[SY]|LA|M[ADEINOST]|N[CDEHJMVY]|O[HKR]|PA|RI|S[CD]|T[NX]|UT|V[AT]|W[AIVY])$",d=f?new RegExp(d):new RegExp(d,"i"),this.optional(b)||d.test(a)},"Please specify a valid state"),a.validator.addMethod("strippedminlength",function(b,c,d){return a(b).text().length>=d},a.validator.format("Please enter at least {0} characters")),a.validator.addMethod("time",function(a,b){return this.optional(b)||/^([01]\d|2[0-3]|[0-9])(:[0-5]\d){1,2}$/.test(a)},"Please enter a valid time, between 00:00 and 23:59"),a.validator.addMethod("time12h",function(a,b){return this.optional(b)||/^((0?[1-9]|1[012])(:[0-5]\d){1,2}(\ ?[AP]M))$/i.test(a)},"Please enter a valid time in 12-hour am/pm format"),a.validator.addMethod("url2",function(a,b){return this.optional(b)||/^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)*(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(a)},a.validator.messages.url),a.validator.addMethod("vinUS",function(a){if(17!==a.length)return!1;var b,c,d,e,f,g,h=["A","B","C","D","E","F","G","H","J","K","L","M","N","P","R","S","T","U","V","W","X","Y","Z"],i=[1,2,3,4,5,6,7,8,1,2,3,4,5,7,9,2,3,4,5,6,7,8,9],j=[8,7,6,5,4,3,2,10,0,9,8,7,6,5,4,3,2],k=0;for(b=0;17>b;b++){if(e=j[b],d=a.slice(b,b+1),8===b&&(g=d),isNaN(d)){for(c=0;c").attr("name",c.submitButton.name).val(a(c.submitButton).val()).appendTo(c.currentForm)),e=c.settings.submitHandler.call(c,c.currentForm,b),c.submitButton&&d.remove(),void 0!==e?e:!1):!0}return c.settings.debug&&b.preventDefault(),c.cancelSubmit?(c.cancelSubmit=!1,d()):c.form()?c.pendingRequest?(c.formSubmitted=!0,!1):d():(c.focusInvalid(),!1)})),c)},valid:function(){var b,c,d;return a(this[0]).is("form")?b=this.validate().form():(d=[],b=!0,c=a(this[0].form).validate(),this.each(function(){b=c.element(this)&&b,d=d.concat(c.errorList)}),c.errorList=d),b},rules:function(b,c){var d,e,f,g,h,i,j=this[0];if(b)switch(d=a.data(j.form,"validator").settings,e=d.rules,f=a.validator.staticRules(j),b){case"add":a.extend(f,a.validator.normalizeRule(c)),delete f.messages,e[j.name]=f,c.messages&&(d.messages[j.name]=a.extend(d.messages[j.name],c.messages));break;case"remove":return c?(i={},a.each(c.split(/\s/),function(b,c){i[c]=f[c],delete f[c],"required"===c&&a(j).removeAttr("aria-required")}),i):(delete e[j.name],f)}return g=a.validator.normalizeRules(a.extend({},a.validator.classRules(j),a.validator.attributeRules(j),a.validator.dataRules(j),a.validator.staticRules(j)),j),g.required&&(h=g.required,delete g.required,g=a.extend({required:h},g),a(j).attr("aria-required","true")),g.remote&&(h=g.remote,delete g.remote,g=a.extend(g,{remote:h})),g}}),a.extend(a.expr[":"],{blank:function(b){return!a.trim(""+a(b).val())},filled:function(b){return!!a.trim(""+a(b).val())},unchecked:function(b){return!a(b).prop("checked")}}),a.validator=function(b,c){this.settings=a.extend(!0,{},a.validator.defaults,b),this.currentForm=c,this.init()},a.validator.format=function(b,c){return 1===arguments.length?function(){var c=a.makeArray(arguments);return c.unshift(b),a.validator.format.apply(this,c)}:(arguments.length>2&&c.constructor!==Array&&(c=a.makeArray(arguments).slice(1)),c.constructor!==Array&&(c=[c]),a.each(c,function(a,c){b=b.replace(new RegExp("\\{"+a+"\\}","g"),function(){return c})}),b)},a.extend(a.validator,{defaults:{messages:{},groups:{},rules:{},errorClass:"error",validClass:"valid",errorElement:"label",focusCleanup:!1,focusInvalid:!0,errorContainer:a([]),errorLabelContainer:a([]),onsubmit:!0,ignore:":hidden",ignoreTitle:!1,onfocusin:function(a){this.lastActive=a,this.settings.focusCleanup&&(this.settings.unhighlight&&this.settings.unhighlight.call(this,a,this.settings.errorClass,this.settings.validClass),this.hideThese(this.errorsFor(a)))},onfocusout:function(a){this.checkable(a)||!(a.name in this.submitted)&&this.optional(a)||this.element(a)},onkeyup:function(b,c){var d=[16,17,18,20,35,36,37,38,39,40,45,144,225];9===c.which&&""===this.elementValue(b)||-1!==a.inArray(c.keyCode,d)||(b.name in this.submitted||b===this.lastElement)&&this.element(b)},onclick:function(a){a.name in this.submitted?this.element(a):a.parentNode.name in this.submitted&&this.element(a.parentNode)},highlight:function(b,c,d){"radio"===b.type?this.findByName(b.name).addClass(c).removeClass(d):a(b).addClass(c).removeClass(d)},unhighlight:function(b,c,d){"radio"===b.type?this.findByName(b.name).removeClass(c).addClass(d):a(b).removeClass(c).addClass(d)}},setDefaults:function(b){a.extend(a.validator.defaults,b)},messages:{required:"This field is required.",remote:"Please fix this field.",email:"Please enter a valid email address.",url:"Please enter a valid URL.",date:"Please enter a valid date.",dateISO:"Please enter a valid date ( ISO ).",number:"Please enter a valid number.",digits:"Please enter only digits.",creditcard:"Please enter a valid credit card number.",equalTo:"Please enter the same value again.",maxlength:a.validator.format("Please enter no more than {0} characters."),minlength:a.validator.format("Please enter at least {0} characters."),rangelength:a.validator.format("Please enter a value between {0} and {1} characters long."),range:a.validator.format("Please enter a value between {0} and {1}."),max:a.validator.format("Please enter a value less than or equal to {0}."),min:a.validator.format("Please enter a value greater than or equal to {0}.")},autoCreateRanges:!1,prototype:{init:function(){function b(b){var c=a.data(this.form,"validator"),d="on"+b.type.replace(/^validate/,""),e=c.settings;e[d]&&!a(this).is(e.ignore)&&e[d].call(c,this,b)}this.labelContainer=a(this.settings.errorLabelContainer),this.errorContext=this.labelContainer.length&&this.labelContainer||a(this.currentForm),this.containers=a(this.settings.errorContainer).add(this.settings.errorLabelContainer),this.submitted={},this.valueCache={},this.pendingRequest=0,this.pending={},this.invalid={},this.reset();var c,d=this.groups={};a.each(this.settings.groups,function(b,c){"string"==typeof c&&(c=c.split(/\s/)),a.each(c,function(a,c){d[c]=b})}),c=this.settings.rules,a.each(c,function(b,d){c[b]=a.validator.normalizeRule(d)}),a(this.currentForm).on("focusin.validate focusout.validate keyup.validate",":text, [type='password'], [type='file'], select, textarea, [type='number'], [type='search'], [type='tel'], [type='url'], [type='email'], [type='datetime'], [type='date'], [type='month'], [type='week'], [type='time'], [type='datetime-local'], [type='range'], [type='color'], [type='radio'], [type='checkbox']",b).on("click.validate","select, option, [type='radio'], [type='checkbox']",b),this.settings.invalidHandler&&a(this.currentForm).on("invalid-form.validate",this.settings.invalidHandler),a(this.currentForm).find("[required], [data-rule-required], .required").attr("aria-required","true")},form:function(){return this.checkForm(),a.extend(this.submitted,this.errorMap),this.invalid=a.extend({},this.errorMap),this.valid()||a(this.currentForm).triggerHandler("invalid-form",[this]),this.showErrors(),this.valid()},checkForm:function(){this.prepareForm();for(var a=0,b=this.currentElements=this.elements();b[a];a++)this.check(b[a]);return this.valid()},element:function(b){var c=this.clean(b),d=this.validationTargetFor(c),e=!0;return this.lastElement=d,void 0===d?delete this.invalid[c.name]:(this.prepareElement(d),this.currentElements=a(d),e=this.check(d)!==!1,e?delete this.invalid[d.name]:this.invalid[d.name]=!0),a(b).attr("aria-invalid",!e),this.numberOfInvalids()||(this.toHide=this.toHide.add(this.containers)),this.showErrors(),e},showErrors:function(b){if(b){a.extend(this.errorMap,b),this.errorList=[];for(var c in b)this.errorList.push({message:b[c],element:this.findByName(c)[0]});this.successList=a.grep(this.successList,function(a){return!(a.name in b)})}this.settings.showErrors?this.settings.showErrors.call(this,this.errorMap,this.errorList):this.defaultShowErrors()},resetForm:function(){a.fn.resetForm&&a(this.currentForm).resetForm(),this.submitted={},this.lastElement=null,this.prepareForm(),this.hideErrors();var b,c=this.elements().removeData("previousValue").removeAttr("aria-invalid");if(this.settings.unhighlight)for(b=0;c[b];b++)this.settings.unhighlight.call(this,c[b],this.settings.errorClass,"");else c.removeClass(this.settings.errorClass)},numberOfInvalids:function(){return this.objectLength(this.invalid)},objectLength:function(a){var b,c=0;for(b in a)c++;return c},hideErrors:function(){this.hideThese(this.toHide)},hideThese:function(a){a.not(this.containers).text(""),this.addWrapper(a).hide()},valid:function(){return 0===this.size()},size:function(){return this.errorList.length},focusInvalid:function(){if(this.settings.focusInvalid)try{a(this.findLastActive()||this.errorList.length&&this.errorList[0].element||[]).filter(":visible").focus().trigger("focusin")}catch(b){}},findLastActive:function(){var b=this.lastActive;return b&&1===a.grep(this.errorList,function(a){return a.element.name===b.name}).length&&b},elements:function(){var b=this,c={};return a(this.currentForm).find("input, select, textarea").not(":submit, :reset, :image, :disabled").not(this.settings.ignore).filter(function(){return!this.name&&b.settings.debug&&window.console&&console.error("%o has no name assigned",this),this.name in c||!b.objectLength(a(this).rules())?!1:(c[this.name]=!0,!0)})},clean:function(b){return a(b)[0]},errors:function(){var b=this.settings.errorClass.split(" ").join(".");return a(this.settings.errorElement+"."+b,this.errorContext)},reset:function(){this.successList=[],this.errorList=[],this.errorMap={},this.toShow=a([]),this.toHide=a([]),this.currentElements=a([])},prepareForm:function(){this.reset(),this.toHide=this.errors().add(this.containers)},prepareElement:function(a){this.reset(),this.toHide=this.errorsFor(a)},elementValue:function(b){var c,d=a(b),e=b.type;return"radio"===e||"checkbox"===e?this.findByName(b.name).filter(":checked").val():"number"===e&&"undefined"!=typeof b.validity?b.validity.badInput?!1:d.val():(c=d.val(),"string"==typeof c?c.replace(/\r/g,""):c)},check:function(b){b=this.validationTargetFor(this.clean(b));var c,d,e,f=a(b).rules(),g=a.map(f,function(a,b){return b}).length,h=!1,i=this.elementValue(b);for(d in f){e={method:d,parameters:f[d]};try{if(c=a.validator.methods[d].call(this,i,b,e.parameters),"dependency-mismatch"===c&&1===g){h=!0;continue}if(h=!1,"pending"===c)return void(this.toHide=this.toHide.not(this.errorsFor(b)));if(!c)return this.formatAndAdd(b,e),!1}catch(j){throw this.settings.debug&&window.console&&console.log("Exception occurred when checking element "+b.id+", check the '"+e.method+"' method.",j),j instanceof TypeError&&(j.message+=". Exception occurred when checking element "+b.id+", check the '"+e.method+"' method."),j}}if(!h)return this.objectLength(f)&&this.successList.push(b),!0},customDataMessage:function(b,c){return a(b).data("msg"+c.charAt(0).toUpperCase()+c.substring(1).toLowerCase())||a(b).data("msg")},customMessage:function(a,b){var c=this.settings.messages[a];return c&&(c.constructor===String?c:c[b])},findDefined:function(){for(var a=0;aWarning: No message defined for "+b.name+"")},formatAndAdd:function(b,c){var d=this.defaultMessage(b,c.method),e=/\$?\{(\d+)\}/g;"function"==typeof d?d=d.call(this,c.parameters,b):e.test(d)&&(d=a.validator.format(d.replace(e,"{$1}"),c.parameters)),this.errorList.push({message:d,element:b,method:c.method}),this.errorMap[b.name]=d,this.submitted[b.name]=d},addWrapper:function(a){return this.settings.wrapper&&(a=a.add(a.parent(this.settings.wrapper))),a},defaultShowErrors:function(){var a,b,c;for(a=0;this.errorList[a];a++)c=this.errorList[a],this.settings.highlight&&this.settings.highlight.call(this,c.element,this.settings.errorClass,this.settings.validClass),this.showLabel(c.element,c.message);if(this.errorList.length&&(this.toShow=this.toShow.add(this.containers)),this.settings.success)for(a=0;this.successList[a];a++)this.showLabel(this.successList[a]);if(this.settings.unhighlight)for(a=0,b=this.validElements();b[a];a++)this.settings.unhighlight.call(this,b[a],this.settings.errorClass,this.settings.validClass);this.toHide=this.toHide.not(this.toShow),this.hideErrors(),this.addWrapper(this.toShow).show()},validElements:function(){return this.currentElements.not(this.invalidElements())},invalidElements:function(){return a(this.errorList).map(function(){return this.element})},showLabel:function(b,c){var d,e,f,g=this.errorsFor(b),h=this.idOrName(b),i=a(b).attr("aria-describedby");g.length?(g.removeClass(this.settings.validClass).addClass(this.settings.errorClass),g.html(c)):(g=a("<"+this.settings.errorElement+">").attr("id",h+"-error").addClass(this.settings.errorClass).html(c||""),d=g,this.settings.wrapper&&(d=g.hide().show().wrap("<"+this.settings.wrapper+"/>").parent()),this.labelContainer.length?this.labelContainer.append(d):this.settings.errorPlacement?this.settings.errorPlacement(d,a(b)):d.insertAfter(b),g.is("label")?g.attr("for",h):0===g.parents("label[for='"+h+"']").length&&(f=g.attr("id").replace(/(:|\.|\[|\]|\$)/g,"\\$1"),i?i.match(new RegExp("\\b"+f+"\\b"))||(i+=" "+f):i=f,a(b).attr("aria-describedby",i),e=this.groups[b.name],e&&a.each(this.groups,function(b,c){c===e&&a("[name='"+b+"']",this.currentForm).attr("aria-describedby",g.attr("id"))}))),!c&&this.settings.success&&(g.text(""),"string"==typeof this.settings.success?g.addClass(this.settings.success):this.settings.success(g,b)),this.toShow=this.toShow.add(g)},errorsFor:function(b){var c=this.idOrName(b),d=a(b).attr("aria-describedby"),e="label[for='"+c+"'], label[for='"+c+"'] *";return d&&(e=e+", #"+d.replace(/\s+/g,", #")),this.errors().filter(e)},idOrName:function(a){return this.groups[a.name]||(this.checkable(a)?a.name:a.id||a.name)},validationTargetFor:function(b){return this.checkable(b)&&(b=this.findByName(b.name)),a(b).not(this.settings.ignore)[0]},checkable:function(a){return/radio|checkbox/i.test(a.type)},findByName:function(b){return a(this.currentForm).find("[name='"+b+"']")},getLength:function(b,c){switch(c.nodeName.toLowerCase()){case"select":return a("option:selected",c).length;case"input":if(this.checkable(c))return this.findByName(c.name).filter(":checked").length}return b.length},depend:function(a,b){return this.dependTypes[typeof a]?this.dependTypes[typeof a](a,b):!0},dependTypes:{"boolean":function(a){return a},string:function(b,c){return!!a(b,c.form).length},"function":function(a,b){return a(b)}},optional:function(b){var c=this.elementValue(b);return!a.validator.methods.required.call(this,c,b)&&"dependency-mismatch"},startRequest:function(a){this.pending[a.name]||(this.pendingRequest++,this.pending[a.name]=!0)},stopRequest:function(b,c){this.pendingRequest--,this.pendingRequest<0&&(this.pendingRequest=0),delete this.pending[b.name],c&&0===this.pendingRequest&&this.formSubmitted&&this.form()?(a(this.currentForm).submit(),this.formSubmitted=!1):!c&&0===this.pendingRequest&&this.formSubmitted&&(a(this.currentForm).triggerHandler("invalid-form",[this]),this.formSubmitted=!1)},previousValue:function(b){return a.data(b,"previousValue")||a.data(b,"previousValue",{old:null,valid:!0,message:this.defaultMessage(b,"remote")})},destroy:function(){this.resetForm(),a(this.currentForm).off(".validate").removeData("validator")}},classRuleSettings:{required:{required:!0},email:{email:!0},url:{url:!0},date:{date:!0},dateISO:{dateISO:!0},number:{number:!0},digits:{digits:!0},creditcard:{creditcard:!0}},addClassRules:function(b,c){b.constructor===String?this.classRuleSettings[b]=c:a.extend(this.classRuleSettings,b)},classRules:function(b){var c={},d=a(b).attr("class");return d&&a.each(d.split(" "),function(){this in a.validator.classRuleSettings&&a.extend(c,a.validator.classRuleSettings[this])}),c},normalizeAttributeRule:function(a,b,c,d){/min|max/.test(c)&&(null===b||/number|range|text/.test(b))&&(d=Number(d),isNaN(d)&&(d=void 0)),d||0===d?a[c]=d:b===c&&"range"!==b&&(a[c]=!0)},attributeRules:function(b){var c,d,e={},f=a(b),g=b.getAttribute("type");for(c in a.validator.methods)"required"===c?(d=b.getAttribute(c),""===d&&(d=!0),d=!!d):d=f.attr(c),this.normalizeAttributeRule(e,g,c,d);return e.maxlength&&/-1|2147483647|524288/.test(e.maxlength)&&delete e.maxlength,e},dataRules:function(b){var c,d,e={},f=a(b),g=b.getAttribute("type");for(c in a.validator.methods)d=f.data("rule"+c.charAt(0).toUpperCase()+c.substring(1).toLowerCase()),this.normalizeAttributeRule(e,g,c,d);return e},staticRules:function(b){var c={},d=a.data(b.form,"validator");return d.settings.rules&&(c=a.validator.normalizeRule(d.settings.rules[b.name])||{}),c},normalizeRules:function(b,c){return a.each(b,function(d,e){if(e===!1)return void delete b[d];if(e.param||e.depends){var f=!0;switch(typeof e.depends){case"string":f=!!a(e.depends,c.form).length;break;case"function":f=e.depends.call(c,c)}f?b[d]=void 0!==e.param?e.param:!0:delete b[d]}}),a.each(b,function(d,e){b[d]=a.isFunction(e)?e(c):e}),a.each(["minlength","maxlength"],function(){b[this]&&(b[this]=Number(b[this]))}),a.each(["rangelength","range"],function(){var c;b[this]&&(a.isArray(b[this])?b[this]=[Number(b[this][0]),Number(b[this][1])]:"string"==typeof b[this]&&(c=b[this].replace(/[\[\]]/g,"").split(/[\s,]+/),b[this]=[Number(c[0]),Number(c[1])]))}),a.validator.autoCreateRanges&&(null!=b.min&&null!=b.max&&(b.range=[b.min,b.max],delete b.min,delete b.max),null!=b.minlength&&null!=b.maxlength&&(b.rangelength=[b.minlength,b.maxlength],delete b.minlength,delete b.maxlength)),b},normalizeRule:function(b){if("string"==typeof b){var c={};a.each(b.split(/\s/),function(){c[this]=!0}),b=c}return b},addMethod:function(b,c,d){a.validator.methods[b]=c,a.validator.messages[b]=void 0!==d?d:a.validator.messages[b],c.length<3&&a.validator.addClassRules(b,a.validator.normalizeRule(b))},methods:{required:function(b,c,d){if(!this.depend(d,c))return"dependency-mismatch";if("select"===c.nodeName.toLowerCase()){var e=a(c).val();return e&&e.length>0}return this.checkable(c)?this.getLength(b,c)>0:b.length>0},email:function(a,b){return this.optional(b)||/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(a)},url:function(a,b){return this.optional(b)||/^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})).?)(?::\d{2,5})?(?:[/?#]\S*)?$/i.test(a)},date:function(a,b){return this.optional(b)||!/Invalid|NaN/.test(new Date(a).toString())},dateISO:function(a,b){return this.optional(b)||/^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/.test(a)},number:function(a,b){return this.optional(b)||/^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test(a)},digits:function(a,b){return this.optional(b)||/^\d+$/.test(a)},creditcard:function(a,b){if(this.optional(b))return"dependency-mismatch";if(/[^0-9 \-]+/.test(a))return!1;var c,d,e=0,f=0,g=!1;if(a=a.replace(/\D/g,""),a.length<13||a.length>19)return!1;for(c=a.length-1;c>=0;c--)d=a.charAt(c),f=parseInt(d,10),g&&(f*=2)>9&&(f-=9),e+=f,g=!g;return e%10===0},minlength:function(b,c,d){var e=a.isArray(b)?b.length:this.getLength(b,c);return this.optional(c)||e>=d},maxlength:function(b,c,d){var e=a.isArray(b)?b.length:this.getLength(b,c);return this.optional(c)||d>=e},rangelength:function(b,c,d){var e=a.isArray(b)?b.length:this.getLength(b,c);return this.optional(c)||e>=d[0]&&e<=d[1]},min:function(a,b,c){return this.optional(b)||a>=c},max:function(a,b,c){return this.optional(b)||c>=a},range:function(a,b,c){return this.optional(b)||a>=c[0]&&a<=c[1]},equalTo:function(b,c,d){var e=a(d);return this.settings.onfocusout&&e.off(".validate-equalTo").on("blur.validate-equalTo",function(){a(c).valid()}),b===e.val()},remote:function(b,c,d){if(this.optional(c))return"dependency-mismatch";var e,f,g=this.previousValue(c);return this.settings.messages[c.name]||(this.settings.messages[c.name]={}),g.originalMessage=this.settings.messages[c.name].remote,this.settings.messages[c.name].remote=g.message,d="string"==typeof d&&{url:d}||d,g.old===b?g.valid:(g.old=b,e=this,this.startRequest(c),f={},f[c.name]=b,a.ajax(a.extend(!0,{mode:"abort",port:"validate"+c.name,dataType:"json",data:f,context:e.currentForm,success:function(d){var f,h,i,j=d===!0||"true"===d;e.settings.messages[c.name].remote=g.originalMessage,j?(i=e.formSubmitted,e.prepareElement(c),e.formSubmitted=i,e.successList.push(c),delete e.invalid[c.name],e.showErrors()):(f={},h=d||e.defaultMessage(c,"remote"),f[c.name]=g.message=a.isFunction(h)?h(b):h,e.invalid[c.name]=!0,e.showErrors(f)),g.valid=j,e.stopRequest(c,j)}},d)),"pending")}}});var b,c={};a.ajaxPrefilter?a.ajaxPrefilter(function(a,b,d){var e=a.port;"abort"===a.mode&&(c[e]&&c[e].abort(),c[e]=d)}):(b=a.ajax,a.ajax=function(d){var e=("mode"in d?d:a.ajaxSettings).mode,f=("port"in d?d:a.ajaxSettings).port;return"abort"===e?(c[f]&&c[f].abort(),c[f]=b.apply(this,arguments),c[f]):b.apply(this,arguments)})}); -------------------------------------------------------------------------------- /samples/Sample-AspNet5.Mvc6.Ntlm/wwwroot/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js: -------------------------------------------------------------------------------- 1 | /*! 2 | ** Unobtrusive validation support library for jQuery and jQuery Validate 3 | ** Copyright (C) Microsoft Corporation. All rights reserved. 4 | */ 5 | 6 | /*jslint white: true, browser: true, onevar: true, undef: true, nomen: true, eqeqeq: true, plusplus: true, bitwise: true, regexp: true, newcap: true, immed: true, strict: false */ 7 | /*global document: false, jQuery: false */ 8 | 9 | (function ($) { 10 | var $jQval = $.validator, 11 | adapters, 12 | data_validation = "unobtrusiveValidation"; 13 | 14 | function setValidationValues(options, ruleName, value) { 15 | options.rules[ruleName] = value; 16 | if (options.message) { 17 | options.messages[ruleName] = options.message; 18 | } 19 | } 20 | 21 | function splitAndTrim(value) { 22 | return value.replace(/^\s+|\s+$/g, "").split(/\s*,\s*/g); 23 | } 24 | 25 | function escapeAttributeValue(value) { 26 | // As mentioned on http://api.jquery.com/category/selectors/ 27 | return value.replace(/([!"#$%&'()*+,./:;<=>?@\[\\\]^`{|}~])/g, "\\$1"); 28 | } 29 | 30 | function getModelPrefix(fieldName) { 31 | return fieldName.substr(0, fieldName.lastIndexOf(".") + 1); 32 | } 33 | 34 | function appendModelPrefix(value, prefix) { 35 | if (value.indexOf("*.") === 0) { 36 | value = value.replace("*.", prefix); 37 | } 38 | return value; 39 | } 40 | 41 | function onError(error, inputElement) { // 'this' is the form element 42 | var container = $(this).find("[data-valmsg-for='" + escapeAttributeValue(inputElement[0].name) + "']"), 43 | replaceAttrValue = container.attr("data-valmsg-replace"), 44 | replace = replaceAttrValue ? $.parseJSON(replaceAttrValue) !== false : null; 45 | 46 | container.removeClass("field-validation-valid").addClass("field-validation-error"); 47 | error.data("unobtrusiveContainer", container); 48 | 49 | if (replace) { 50 | container.empty(); 51 | error.removeClass("input-validation-error").appendTo(container); 52 | } 53 | else { 54 | error.hide(); 55 | } 56 | } 57 | 58 | function onErrors(event, validator) { // 'this' is the form element 59 | var container = $(this).find("[data-valmsg-summary=true]"), 60 | list = container.find("ul"); 61 | 62 | if (list && list.length && validator.errorList.length) { 63 | list.empty(); 64 | container.addClass("validation-summary-errors").removeClass("validation-summary-valid"); 65 | 66 | $.each(validator.errorList, function () { 67 | $("
  • ").html(this.message).appendTo(list); 68 | }); 69 | } 70 | } 71 | 72 | function onSuccess(error) { // 'this' is the form element 73 | var container = error.data("unobtrusiveContainer"); 74 | 75 | if (container) { 76 | var replaceAttrValue = container.attr("data-valmsg-replace"), 77 | replace = replaceAttrValue ? $.parseJSON(replaceAttrValue) : null; 78 | 79 | container.addClass("field-validation-valid").removeClass("field-validation-error"); 80 | error.removeData("unobtrusiveContainer"); 81 | 82 | if (replace) { 83 | container.empty(); 84 | } 85 | } 86 | } 87 | 88 | function onReset(event) { // 'this' is the form element 89 | var $form = $(this), 90 | key = '__jquery_unobtrusive_validation_form_reset'; 91 | if ($form.data(key)) { 92 | return; 93 | } 94 | // Set a flag that indicates we're currently resetting the form. 95 | $form.data(key, true); 96 | try { 97 | $form.data("validator").resetForm(); 98 | } finally { 99 | $form.removeData(key); 100 | } 101 | 102 | $form.find(".validation-summary-errors") 103 | .addClass("validation-summary-valid") 104 | .removeClass("validation-summary-errors"); 105 | $form.find(".field-validation-error") 106 | .addClass("field-validation-valid") 107 | .removeClass("field-validation-error") 108 | .removeData("unobtrusiveContainer") 109 | .find(">*") // If we were using valmsg-replace, get the underlying error 110 | .removeData("unobtrusiveContainer"); 111 | } 112 | 113 | function validationInfo(form) { 114 | var $form = $(form), 115 | result = $form.data(data_validation), 116 | onResetProxy = $.proxy(onReset, form), 117 | defaultOptions = $jQval.unobtrusive.options || {}, 118 | execInContext = function (name, args) { 119 | var func = defaultOptions[name]; 120 | func && $.isFunction(func) && func.apply(form, args); 121 | } 122 | 123 | if (!result) { 124 | result = { 125 | options: { // options structure passed to jQuery Validate's validate() method 126 | errorClass: defaultOptions.errorClass || "input-validation-error", 127 | errorElement: defaultOptions.errorElement || "span", 128 | errorPlacement: function () { 129 | onError.apply(form, arguments); 130 | execInContext("errorPlacement", arguments); 131 | }, 132 | invalidHandler: function () { 133 | onErrors.apply(form, arguments); 134 | execInContext("invalidHandler", arguments); 135 | }, 136 | messages: {}, 137 | rules: {}, 138 | success: function () { 139 | onSuccess.apply(form, arguments); 140 | execInContext("success", arguments); 141 | } 142 | }, 143 | attachValidation: function () { 144 | $form 145 | .off("reset." + data_validation, onResetProxy) 146 | .on("reset." + data_validation, onResetProxy) 147 | .validate(this.options); 148 | }, 149 | validate: function () { // a validation function that is called by unobtrusive Ajax 150 | $form.validate(); 151 | return $form.valid(); 152 | } 153 | }; 154 | $form.data(data_validation, result); 155 | } 156 | 157 | return result; 158 | } 159 | 160 | $jQval.unobtrusive = { 161 | adapters: [], 162 | 163 | parseElement: function (element, skipAttach) { 164 | /// 165 | /// Parses a single HTML element for unobtrusive validation attributes. 166 | /// 167 | /// The HTML element to be parsed. 168 | /// [Optional] true to skip attaching the 169 | /// validation to the form. If parsing just this single element, you should specify true. 170 | /// If parsing several elements, you should specify false, and manually attach the validation 171 | /// to the form when you are finished. The default is false. 172 | var $element = $(element), 173 | form = $element.parents("form")[0], 174 | valInfo, rules, messages; 175 | 176 | if (!form) { // Cannot do client-side validation without a form 177 | return; 178 | } 179 | 180 | valInfo = validationInfo(form); 181 | valInfo.options.rules[element.name] = rules = {}; 182 | valInfo.options.messages[element.name] = messages = {}; 183 | 184 | $.each(this.adapters, function () { 185 | var prefix = "data-val-" + this.name, 186 | message = $element.attr(prefix), 187 | paramValues = {}; 188 | 189 | if (message !== undefined) { // Compare against undefined, because an empty message is legal (and falsy) 190 | prefix += "-"; 191 | 192 | $.each(this.params, function () { 193 | paramValues[this] = $element.attr(prefix + this); 194 | }); 195 | 196 | this.adapt({ 197 | element: element, 198 | form: form, 199 | message: message, 200 | params: paramValues, 201 | rules: rules, 202 | messages: messages 203 | }); 204 | } 205 | }); 206 | 207 | $.extend(rules, { "__dummy__": true }); 208 | 209 | if (!skipAttach) { 210 | valInfo.attachValidation(); 211 | } 212 | }, 213 | 214 | parse: function (selector) { 215 | /// 216 | /// Parses all the HTML elements in the specified selector. It looks for input elements decorated 217 | /// with the [data-val=true] attribute value and enables validation according to the data-val-* 218 | /// attribute values. 219 | /// 220 | /// Any valid jQuery selector. 221 | 222 | // $forms includes all forms in selector's DOM hierarchy (parent, children and self) that have at least one 223 | // element with data-val=true 224 | var $selector = $(selector), 225 | $forms = $selector.parents() 226 | .addBack() 227 | .filter("form") 228 | .add($selector.find("form")) 229 | .has("[data-val=true]"); 230 | 231 | $selector.find("[data-val=true]").each(function () { 232 | $jQval.unobtrusive.parseElement(this, true); 233 | }); 234 | 235 | $forms.each(function () { 236 | var info = validationInfo(this); 237 | if (info) { 238 | info.attachValidation(); 239 | } 240 | }); 241 | } 242 | }; 243 | 244 | adapters = $jQval.unobtrusive.adapters; 245 | 246 | adapters.add = function (adapterName, params, fn) { 247 | /// Adds a new adapter to convert unobtrusive HTML into a jQuery Validate validation. 248 | /// The name of the adapter to be added. This matches the name used 249 | /// in the data-val-nnnn HTML attribute (where nnnn is the adapter name). 250 | /// [Optional] An array of parameter names (strings) that will 251 | /// be extracted from the data-val-nnnn-mmmm HTML attributes (where nnnn is the adapter name, and 252 | /// mmmm is the parameter name). 253 | /// The function to call, which adapts the values from the HTML 254 | /// attributes into jQuery Validate rules and/or messages. 255 | /// 256 | if (!fn) { // Called with no params, just a function 257 | fn = params; 258 | params = []; 259 | } 260 | this.push({ name: adapterName, params: params, adapt: fn }); 261 | return this; 262 | }; 263 | 264 | adapters.addBool = function (adapterName, ruleName) { 265 | /// Adds a new adapter to convert unobtrusive HTML into a jQuery Validate validation, where 266 | /// the jQuery Validate validation rule has no parameter values. 267 | /// The name of the adapter to be added. This matches the name used 268 | /// in the data-val-nnnn HTML attribute (where nnnn is the adapter name). 269 | /// [Optional] The name of the jQuery Validate rule. If not provided, the value 270 | /// of adapterName will be used instead. 271 | /// 272 | return this.add(adapterName, function (options) { 273 | setValidationValues(options, ruleName || adapterName, true); 274 | }); 275 | }; 276 | 277 | adapters.addMinMax = function (adapterName, minRuleName, maxRuleName, minMaxRuleName, minAttribute, maxAttribute) { 278 | /// Adds a new adapter to convert unobtrusive HTML into a jQuery Validate validation, where 279 | /// the jQuery Validate validation has three potential rules (one for min-only, one for max-only, and 280 | /// one for min-and-max). The HTML parameters are expected to be named -min and -max. 281 | /// The name of the adapter to be added. This matches the name used 282 | /// in the data-val-nnnn HTML attribute (where nnnn is the adapter name). 283 | /// The name of the jQuery Validate rule to be used when you only 284 | /// have a minimum value. 285 | /// The name of the jQuery Validate rule to be used when you only 286 | /// have a maximum value. 287 | /// The name of the jQuery Validate rule to be used when you 288 | /// have both a minimum and maximum value. 289 | /// [Optional] The name of the HTML attribute that 290 | /// contains the minimum value. The default is "min". 291 | /// [Optional] The name of the HTML attribute that 292 | /// contains the maximum value. The default is "max". 293 | /// 294 | return this.add(adapterName, [minAttribute || "min", maxAttribute || "max"], function (options) { 295 | var min = options.params.min, 296 | max = options.params.max; 297 | 298 | if (min && max) { 299 | setValidationValues(options, minMaxRuleName, [min, max]); 300 | } 301 | else if (min) { 302 | setValidationValues(options, minRuleName, min); 303 | } 304 | else if (max) { 305 | setValidationValues(options, maxRuleName, max); 306 | } 307 | }); 308 | }; 309 | 310 | adapters.addSingleVal = function (adapterName, attribute, ruleName) { 311 | /// Adds a new adapter to convert unobtrusive HTML into a jQuery Validate validation, where 312 | /// the jQuery Validate validation rule has a single value. 313 | /// The name of the adapter to be added. This matches the name used 314 | /// in the data-val-nnnn HTML attribute(where nnnn is the adapter name). 315 | /// [Optional] The name of the HTML attribute that contains the value. 316 | /// The default is "val". 317 | /// [Optional] The name of the jQuery Validate rule. If not provided, the value 318 | /// of adapterName will be used instead. 319 | /// 320 | return this.add(adapterName, [attribute || "val"], function (options) { 321 | setValidationValues(options, ruleName || adapterName, options.params[attribute]); 322 | }); 323 | }; 324 | 325 | $jQval.addMethod("__dummy__", function (value, element, params) { 326 | return true; 327 | }); 328 | 329 | $jQval.addMethod("regex", function (value, element, params) { 330 | var match; 331 | if (this.optional(element)) { 332 | return true; 333 | } 334 | 335 | match = new RegExp(params).exec(value); 336 | return (match && (match.index === 0) && (match[0].length === value.length)); 337 | }); 338 | 339 | $jQval.addMethod("nonalphamin", function (value, element, nonalphamin) { 340 | var match; 341 | if (nonalphamin) { 342 | match = value.match(/\W/g); 343 | match = match && match.length >= nonalphamin; 344 | } 345 | return match; 346 | }); 347 | 348 | if ($jQval.methods.extension) { 349 | adapters.addSingleVal("accept", "mimtype"); 350 | adapters.addSingleVal("extension", "extension"); 351 | } else { 352 | // for backward compatibility, when the 'extension' validation method does not exist, such as with versions 353 | // of JQuery Validation plugin prior to 1.10, we should use the 'accept' method for 354 | // validating the extension, and ignore mime-type validations as they are not supported. 355 | adapters.addSingleVal("extension", "extension", "accept"); 356 | } 357 | 358 | adapters.addSingleVal("regex", "pattern"); 359 | adapters.addBool("creditcard").addBool("date").addBool("digits").addBool("email").addBool("number").addBool("url"); 360 | adapters.addMinMax("length", "minlength", "maxlength", "rangelength").addMinMax("range", "min", "max", "range"); 361 | adapters.addMinMax("minlength", "minlength").addMinMax("maxlength", "minlength", "maxlength"); 362 | adapters.add("equalto", ["other"], function (options) { 363 | var prefix = getModelPrefix(options.element.name), 364 | other = options.params.other, 365 | fullOtherName = appendModelPrefix(other, prefix), 366 | element = $(options.form).find(":input").filter("[name='" + escapeAttributeValue(fullOtherName) + "']")[0]; 367 | 368 | setValidationValues(options, "equalTo", element); 369 | }); 370 | adapters.add("required", function (options) { 371 | // jQuery Validate equates "required" with "mandatory" for checkbox elements 372 | if (options.element.tagName.toUpperCase() !== "INPUT" || options.element.type.toUpperCase() !== "CHECKBOX") { 373 | setValidationValues(options, "required", true); 374 | } 375 | }); 376 | adapters.add("remote", ["url", "type", "additionalfields"], function (options) { 377 | var value = { 378 | url: options.params.url, 379 | type: options.params.type || "GET", 380 | data: {} 381 | }, 382 | prefix = getModelPrefix(options.element.name); 383 | 384 | $.each(splitAndTrim(options.params.additionalfields || options.element.name), function (i, fieldName) { 385 | var paramName = appendModelPrefix(fieldName, prefix); 386 | value.data[paramName] = function () { 387 | var field = $(options.form).find(":input").filter("[name='" + escapeAttributeValue(paramName) + "']"); 388 | // For checkboxes and radio buttons, only pick up values from checked fields. 389 | if (field.is(":checkbox")) { 390 | return field.filter(":checked").val() || field.filter(":hidden").val() || ''; 391 | } 392 | else if (field.is(":radio")) { 393 | return field.filter(":checked").val() || ''; 394 | } 395 | return field.val(); 396 | }; 397 | }); 398 | 399 | setValidationValues(options, "remote", value); 400 | }); 401 | adapters.add("password", ["min", "nonalphamin", "regex"], function (options) { 402 | if (options.params.min) { 403 | setValidationValues(options, "minlength", options.params.min); 404 | } 405 | if (options.params.nonalphamin) { 406 | setValidationValues(options, "nonalphamin", options.params.nonalphamin); 407 | } 408 | if (options.params.regex) { 409 | setValidationValues(options, "regex", options.params.regex); 410 | } 411 | }); 412 | 413 | $(function () { 414 | $jQval.unobtrusive.parse(document); 415 | }); 416 | }(jQuery)); -------------------------------------------------------------------------------- /samples/Sample-AspNet5.Mvc6.Ntlm/wwwroot/lib/bootstrap/dist/css/bootstrap-theme.min.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap v3.3.5 (http://getbootstrap.com) 3 | * Copyright 2011-2015 Twitter, Inc. 4 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 5 | */.btn-danger,.btn-default,.btn-info,.btn-primary,.btn-success,.btn-warning{text-shadow:0 -1px 0 rgba(0,0,0,.2);-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.15),0 1px 1px rgba(0,0,0,.075);box-shadow:inset 0 1px 0 rgba(255,255,255,.15),0 1px 1px rgba(0,0,0,.075)}.btn-danger.active,.btn-danger:active,.btn-default.active,.btn-default:active,.btn-info.active,.btn-info:active,.btn-primary.active,.btn-primary:active,.btn-success.active,.btn-success:active,.btn-warning.active,.btn-warning:active{-webkit-box-shadow:inset 0 3px 5px rgba(0,0,0,.125);box-shadow:inset 0 3px 5px rgba(0,0,0,.125)}.btn-danger.disabled,.btn-danger[disabled],.btn-default.disabled,.btn-default[disabled],.btn-info.disabled,.btn-info[disabled],.btn-primary.disabled,.btn-primary[disabled],.btn-success.disabled,.btn-success[disabled],.btn-warning.disabled,.btn-warning[disabled],fieldset[disabled] .btn-danger,fieldset[disabled] .btn-default,fieldset[disabled] .btn-info,fieldset[disabled] .btn-primary,fieldset[disabled] .btn-success,fieldset[disabled] .btn-warning{-webkit-box-shadow:none;box-shadow:none}.btn-danger .badge,.btn-default .badge,.btn-info .badge,.btn-primary .badge,.btn-success .badge,.btn-warning .badge{text-shadow:none}.btn.active,.btn:active{background-image:none}.btn-default{text-shadow:0 1px 0 #fff;background-image:-webkit-linear-gradient(top,#fff 0,#e0e0e0 100%);background-image:-o-linear-gradient(top,#fff 0,#e0e0e0 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#fff),to(#e0e0e0));background-image:linear-gradient(to bottom,#fff 0,#e0e0e0 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffe0e0e0', GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);background-repeat:repeat-x;border-color:#dbdbdb;border-color:#ccc}.btn-default:focus,.btn-default:hover{background-color:#e0e0e0;background-position:0 -15px}.btn-default.active,.btn-default:active{background-color:#e0e0e0;border-color:#dbdbdb}.btn-default.disabled,.btn-default.disabled.active,.btn-default.disabled.focus,.btn-default.disabled:active,.btn-default.disabled:focus,.btn-default.disabled:hover,.btn-default[disabled],.btn-default[disabled].active,.btn-default[disabled].focus,.btn-default[disabled]:active,.btn-default[disabled]:focus,.btn-default[disabled]:hover,fieldset[disabled] .btn-default,fieldset[disabled] .btn-default.active,fieldset[disabled] .btn-default.focus,fieldset[disabled] .btn-default:active,fieldset[disabled] .btn-default:focus,fieldset[disabled] .btn-default:hover{background-color:#e0e0e0;background-image:none}.btn-primary{background-image:-webkit-linear-gradient(top,#337ab7 0,#265a88 100%);background-image:-o-linear-gradient(top,#337ab7 0,#265a88 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#337ab7),to(#265a88));background-image:linear-gradient(to bottom,#337ab7 0,#265a88 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7', endColorstr='#ff265a88', GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);background-repeat:repeat-x;border-color:#245580}.btn-primary:focus,.btn-primary:hover{background-color:#265a88;background-position:0 -15px}.btn-primary.active,.btn-primary:active{background-color:#265a88;border-color:#245580}.btn-primary.disabled,.btn-primary.disabled.active,.btn-primary.disabled.focus,.btn-primary.disabled:active,.btn-primary.disabled:focus,.btn-primary.disabled:hover,.btn-primary[disabled],.btn-primary[disabled].active,.btn-primary[disabled].focus,.btn-primary[disabled]:active,.btn-primary[disabled]:focus,.btn-primary[disabled]:hover,fieldset[disabled] .btn-primary,fieldset[disabled] .btn-primary.active,fieldset[disabled] .btn-primary.focus,fieldset[disabled] .btn-primary:active,fieldset[disabled] .btn-primary:focus,fieldset[disabled] .btn-primary:hover{background-color:#265a88;background-image:none}.btn-success{background-image:-webkit-linear-gradient(top,#5cb85c 0,#419641 100%);background-image:-o-linear-gradient(top,#5cb85c 0,#419641 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#5cb85c),to(#419641));background-image:linear-gradient(to bottom,#5cb85c 0,#419641 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5cb85c', endColorstr='#ff419641', GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);background-repeat:repeat-x;border-color:#3e8f3e}.btn-success:focus,.btn-success:hover{background-color:#419641;background-position:0 -15px}.btn-success.active,.btn-success:active{background-color:#419641;border-color:#3e8f3e}.btn-success.disabled,.btn-success.disabled.active,.btn-success.disabled.focus,.btn-success.disabled:active,.btn-success.disabled:focus,.btn-success.disabled:hover,.btn-success[disabled],.btn-success[disabled].active,.btn-success[disabled].focus,.btn-success[disabled]:active,.btn-success[disabled]:focus,.btn-success[disabled]:hover,fieldset[disabled] .btn-success,fieldset[disabled] .btn-success.active,fieldset[disabled] .btn-success.focus,fieldset[disabled] .btn-success:active,fieldset[disabled] .btn-success:focus,fieldset[disabled] .btn-success:hover{background-color:#419641;background-image:none}.btn-info{background-image:-webkit-linear-gradient(top,#5bc0de 0,#2aabd2 100%);background-image:-o-linear-gradient(top,#5bc0de 0,#2aabd2 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#5bc0de),to(#2aabd2));background-image:linear-gradient(to bottom,#5bc0de 0,#2aabd2 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5bc0de', endColorstr='#ff2aabd2', GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);background-repeat:repeat-x;border-color:#28a4c9}.btn-info:focus,.btn-info:hover{background-color:#2aabd2;background-position:0 -15px}.btn-info.active,.btn-info:active{background-color:#2aabd2;border-color:#28a4c9}.btn-info.disabled,.btn-info.disabled.active,.btn-info.disabled.focus,.btn-info.disabled:active,.btn-info.disabled:focus,.btn-info.disabled:hover,.btn-info[disabled],.btn-info[disabled].active,.btn-info[disabled].focus,.btn-info[disabled]:active,.btn-info[disabled]:focus,.btn-info[disabled]:hover,fieldset[disabled] .btn-info,fieldset[disabled] .btn-info.active,fieldset[disabled] .btn-info.focus,fieldset[disabled] .btn-info:active,fieldset[disabled] .btn-info:focus,fieldset[disabled] .btn-info:hover{background-color:#2aabd2;background-image:none}.btn-warning{background-image:-webkit-linear-gradient(top,#f0ad4e 0,#eb9316 100%);background-image:-o-linear-gradient(top,#f0ad4e 0,#eb9316 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#f0ad4e),to(#eb9316));background-image:linear-gradient(to bottom,#f0ad4e 0,#eb9316 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff0ad4e', endColorstr='#ffeb9316', GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);background-repeat:repeat-x;border-color:#e38d13}.btn-warning:focus,.btn-warning:hover{background-color:#eb9316;background-position:0 -15px}.btn-warning.active,.btn-warning:active{background-color:#eb9316;border-color:#e38d13}.btn-warning.disabled,.btn-warning.disabled.active,.btn-warning.disabled.focus,.btn-warning.disabled:active,.btn-warning.disabled:focus,.btn-warning.disabled:hover,.btn-warning[disabled],.btn-warning[disabled].active,.btn-warning[disabled].focus,.btn-warning[disabled]:active,.btn-warning[disabled]:focus,.btn-warning[disabled]:hover,fieldset[disabled] .btn-warning,fieldset[disabled] .btn-warning.active,fieldset[disabled] .btn-warning.focus,fieldset[disabled] .btn-warning:active,fieldset[disabled] .btn-warning:focus,fieldset[disabled] .btn-warning:hover{background-color:#eb9316;background-image:none}.btn-danger{background-image:-webkit-linear-gradient(top,#d9534f 0,#c12e2a 100%);background-image:-o-linear-gradient(top,#d9534f 0,#c12e2a 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#d9534f),to(#c12e2a));background-image:linear-gradient(to bottom,#d9534f 0,#c12e2a 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9534f', endColorstr='#ffc12e2a', GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);background-repeat:repeat-x;border-color:#b92c28}.btn-danger:focus,.btn-danger:hover{background-color:#c12e2a;background-position:0 -15px}.btn-danger.active,.btn-danger:active{background-color:#c12e2a;border-color:#b92c28}.btn-danger.disabled,.btn-danger.disabled.active,.btn-danger.disabled.focus,.btn-danger.disabled:active,.btn-danger.disabled:focus,.btn-danger.disabled:hover,.btn-danger[disabled],.btn-danger[disabled].active,.btn-danger[disabled].focus,.btn-danger[disabled]:active,.btn-danger[disabled]:focus,.btn-danger[disabled]:hover,fieldset[disabled] .btn-danger,fieldset[disabled] .btn-danger.active,fieldset[disabled] .btn-danger.focus,fieldset[disabled] .btn-danger:active,fieldset[disabled] .btn-danger:focus,fieldset[disabled] .btn-danger:hover{background-color:#c12e2a;background-image:none}.img-thumbnail,.thumbnail{-webkit-box-shadow:0 1px 2px rgba(0,0,0,.075);box-shadow:0 1px 2px rgba(0,0,0,.075)}.dropdown-menu>li>a:focus,.dropdown-menu>li>a:hover{background-color:#e8e8e8;background-image:-webkit-linear-gradient(top,#f5f5f5 0,#e8e8e8 100%);background-image:-o-linear-gradient(top,#f5f5f5 0,#e8e8e8 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#f5f5f5),to(#e8e8e8));background-image:linear-gradient(to bottom,#f5f5f5 0,#e8e8e8 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff5f5f5', endColorstr='#ffe8e8e8', GradientType=0);background-repeat:repeat-x}.dropdown-menu>.active>a,.dropdown-menu>.active>a:focus,.dropdown-menu>.active>a:hover{background-color:#2e6da4;background-image:-webkit-linear-gradient(top,#337ab7 0,#2e6da4 100%);background-image:-o-linear-gradient(top,#337ab7 0,#2e6da4 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#337ab7),to(#2e6da4));background-image:linear-gradient(to bottom,#337ab7 0,#2e6da4 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7', endColorstr='#ff2e6da4', GradientType=0);background-repeat:repeat-x}.navbar-default{background-image:-webkit-linear-gradient(top,#fff 0,#f8f8f8 100%);background-image:-o-linear-gradient(top,#fff 0,#f8f8f8 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#fff),to(#f8f8f8));background-image:linear-gradient(to bottom,#fff 0,#f8f8f8 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#fff8f8f8', GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);background-repeat:repeat-x;border-radius:4px;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.15),0 1px 5px rgba(0,0,0,.075);box-shadow:inset 0 1px 0 rgba(255,255,255,.15),0 1px 5px rgba(0,0,0,.075)}.navbar-default .navbar-nav>.active>a,.navbar-default .navbar-nav>.open>a{background-image:-webkit-linear-gradient(top,#dbdbdb 0,#e2e2e2 100%);background-image:-o-linear-gradient(top,#dbdbdb 0,#e2e2e2 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#dbdbdb),to(#e2e2e2));background-image:linear-gradient(to bottom,#dbdbdb 0,#e2e2e2 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffdbdbdb', endColorstr='#ffe2e2e2', GradientType=0);background-repeat:repeat-x;-webkit-box-shadow:inset 0 3px 9px rgba(0,0,0,.075);box-shadow:inset 0 3px 9px rgba(0,0,0,.075)}.navbar-brand,.navbar-nav>li>a{text-shadow:0 1px 0 rgba(255,255,255,.25)}.navbar-inverse{background-image:-webkit-linear-gradient(top,#3c3c3c 0,#222 100%);background-image:-o-linear-gradient(top,#3c3c3c 0,#222 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#3c3c3c),to(#222));background-image:linear-gradient(to bottom,#3c3c3c 0,#222 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff3c3c3c', endColorstr='#ff222222', GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);background-repeat:repeat-x;border-radius:4px}.navbar-inverse .navbar-nav>.active>a,.navbar-inverse .navbar-nav>.open>a{background-image:-webkit-linear-gradient(top,#080808 0,#0f0f0f 100%);background-image:-o-linear-gradient(top,#080808 0,#0f0f0f 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#080808),to(#0f0f0f));background-image:linear-gradient(to bottom,#080808 0,#0f0f0f 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff080808', endColorstr='#ff0f0f0f', GradientType=0);background-repeat:repeat-x;-webkit-box-shadow:inset 0 3px 9px rgba(0,0,0,.25);box-shadow:inset 0 3px 9px rgba(0,0,0,.25)}.navbar-inverse .navbar-brand,.navbar-inverse .navbar-nav>li>a{text-shadow:0 -1px 0 rgba(0,0,0,.25)}.navbar-fixed-bottom,.navbar-fixed-top,.navbar-static-top{border-radius:0}@media (max-width:767px){.navbar .navbar-nav .open .dropdown-menu>.active>a,.navbar .navbar-nav .open .dropdown-menu>.active>a:focus,.navbar .navbar-nav .open .dropdown-menu>.active>a:hover{color:#fff;background-image:-webkit-linear-gradient(top,#337ab7 0,#2e6da4 100%);background-image:-o-linear-gradient(top,#337ab7 0,#2e6da4 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#337ab7),to(#2e6da4));background-image:linear-gradient(to bottom,#337ab7 0,#2e6da4 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7', endColorstr='#ff2e6da4', GradientType=0);background-repeat:repeat-x}}.alert{text-shadow:0 1px 0 rgba(255,255,255,.2);-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 2px rgba(0,0,0,.05)}.alert-success{background-image:-webkit-linear-gradient(top,#dff0d8 0,#c8e5bc 100%);background-image:-o-linear-gradient(top,#dff0d8 0,#c8e5bc 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#dff0d8),to(#c8e5bc));background-image:linear-gradient(to bottom,#dff0d8 0,#c8e5bc 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffdff0d8', endColorstr='#ffc8e5bc', GradientType=0);background-repeat:repeat-x;border-color:#b2dba1}.alert-info{background-image:-webkit-linear-gradient(top,#d9edf7 0,#b9def0 100%);background-image:-o-linear-gradient(top,#d9edf7 0,#b9def0 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#d9edf7),to(#b9def0));background-image:linear-gradient(to bottom,#d9edf7 0,#b9def0 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9edf7', endColorstr='#ffb9def0', GradientType=0);background-repeat:repeat-x;border-color:#9acfea}.alert-warning{background-image:-webkit-linear-gradient(top,#fcf8e3 0,#f8efc0 100%);background-image:-o-linear-gradient(top,#fcf8e3 0,#f8efc0 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#fcf8e3),to(#f8efc0));background-image:linear-gradient(to bottom,#fcf8e3 0,#f8efc0 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffcf8e3', endColorstr='#fff8efc0', GradientType=0);background-repeat:repeat-x;border-color:#f5e79e}.alert-danger{background-image:-webkit-linear-gradient(top,#f2dede 0,#e7c3c3 100%);background-image:-o-linear-gradient(top,#f2dede 0,#e7c3c3 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#f2dede),to(#e7c3c3));background-image:linear-gradient(to bottom,#f2dede 0,#e7c3c3 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff2dede', endColorstr='#ffe7c3c3', GradientType=0);background-repeat:repeat-x;border-color:#dca7a7}.progress{background-image:-webkit-linear-gradient(top,#ebebeb 0,#f5f5f5 100%);background-image:-o-linear-gradient(top,#ebebeb 0,#f5f5f5 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#ebebeb),to(#f5f5f5));background-image:linear-gradient(to bottom,#ebebeb 0,#f5f5f5 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffebebeb', endColorstr='#fff5f5f5', GradientType=0);background-repeat:repeat-x}.progress-bar{background-image:-webkit-linear-gradient(top,#337ab7 0,#286090 100%);background-image:-o-linear-gradient(top,#337ab7 0,#286090 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#337ab7),to(#286090));background-image:linear-gradient(to bottom,#337ab7 0,#286090 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7', endColorstr='#ff286090', GradientType=0);background-repeat:repeat-x}.progress-bar-success{background-image:-webkit-linear-gradient(top,#5cb85c 0,#449d44 100%);background-image:-o-linear-gradient(top,#5cb85c 0,#449d44 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#5cb85c),to(#449d44));background-image:linear-gradient(to bottom,#5cb85c 0,#449d44 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5cb85c', endColorstr='#ff449d44', GradientType=0);background-repeat:repeat-x}.progress-bar-info{background-image:-webkit-linear-gradient(top,#5bc0de 0,#31b0d5 100%);background-image:-o-linear-gradient(top,#5bc0de 0,#31b0d5 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#5bc0de),to(#31b0d5));background-image:linear-gradient(to bottom,#5bc0de 0,#31b0d5 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5bc0de', endColorstr='#ff31b0d5', GradientType=0);background-repeat:repeat-x}.progress-bar-warning{background-image:-webkit-linear-gradient(top,#f0ad4e 0,#ec971f 100%);background-image:-o-linear-gradient(top,#f0ad4e 0,#ec971f 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#f0ad4e),to(#ec971f));background-image:linear-gradient(to bottom,#f0ad4e 0,#ec971f 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff0ad4e', endColorstr='#ffec971f', GradientType=0);background-repeat:repeat-x}.progress-bar-danger{background-image:-webkit-linear-gradient(top,#d9534f 0,#c9302c 100%);background-image:-o-linear-gradient(top,#d9534f 0,#c9302c 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#d9534f),to(#c9302c));background-image:linear-gradient(to bottom,#d9534f 0,#c9302c 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9534f', endColorstr='#ffc9302c', GradientType=0);background-repeat:repeat-x}.progress-bar-striped{background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent)}.list-group{border-radius:4px;-webkit-box-shadow:0 1px 2px rgba(0,0,0,.075);box-shadow:0 1px 2px rgba(0,0,0,.075)}.list-group-item.active,.list-group-item.active:focus,.list-group-item.active:hover{text-shadow:0 -1px 0 #286090;background-image:-webkit-linear-gradient(top,#337ab7 0,#2b669a 100%);background-image:-o-linear-gradient(top,#337ab7 0,#2b669a 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#337ab7),to(#2b669a));background-image:linear-gradient(to bottom,#337ab7 0,#2b669a 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7', endColorstr='#ff2b669a', GradientType=0);background-repeat:repeat-x;border-color:#2b669a}.list-group-item.active .badge,.list-group-item.active:focus .badge,.list-group-item.active:hover .badge{text-shadow:none}.panel{-webkit-box-shadow:0 1px 2px rgba(0,0,0,.05);box-shadow:0 1px 2px rgba(0,0,0,.05)}.panel-default>.panel-heading{background-image:-webkit-linear-gradient(top,#f5f5f5 0,#e8e8e8 100%);background-image:-o-linear-gradient(top,#f5f5f5 0,#e8e8e8 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#f5f5f5),to(#e8e8e8));background-image:linear-gradient(to bottom,#f5f5f5 0,#e8e8e8 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff5f5f5', endColorstr='#ffe8e8e8', GradientType=0);background-repeat:repeat-x}.panel-primary>.panel-heading{background-image:-webkit-linear-gradient(top,#337ab7 0,#2e6da4 100%);background-image:-o-linear-gradient(top,#337ab7 0,#2e6da4 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#337ab7),to(#2e6da4));background-image:linear-gradient(to bottom,#337ab7 0,#2e6da4 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7', endColorstr='#ff2e6da4', GradientType=0);background-repeat:repeat-x}.panel-success>.panel-heading{background-image:-webkit-linear-gradient(top,#dff0d8 0,#d0e9c6 100%);background-image:-o-linear-gradient(top,#dff0d8 0,#d0e9c6 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#dff0d8),to(#d0e9c6));background-image:linear-gradient(to bottom,#dff0d8 0,#d0e9c6 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffdff0d8', endColorstr='#ffd0e9c6', GradientType=0);background-repeat:repeat-x}.panel-info>.panel-heading{background-image:-webkit-linear-gradient(top,#d9edf7 0,#c4e3f3 100%);background-image:-o-linear-gradient(top,#d9edf7 0,#c4e3f3 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#d9edf7),to(#c4e3f3));background-image:linear-gradient(to bottom,#d9edf7 0,#c4e3f3 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9edf7', endColorstr='#ffc4e3f3', GradientType=0);background-repeat:repeat-x}.panel-warning>.panel-heading{background-image:-webkit-linear-gradient(top,#fcf8e3 0,#faf2cc 100%);background-image:-o-linear-gradient(top,#fcf8e3 0,#faf2cc 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#fcf8e3),to(#faf2cc));background-image:linear-gradient(to bottom,#fcf8e3 0,#faf2cc 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffcf8e3', endColorstr='#fffaf2cc', GradientType=0);background-repeat:repeat-x}.panel-danger>.panel-heading{background-image:-webkit-linear-gradient(top,#f2dede 0,#ebcccc 100%);background-image:-o-linear-gradient(top,#f2dede 0,#ebcccc 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#f2dede),to(#ebcccc));background-image:linear-gradient(to bottom,#f2dede 0,#ebcccc 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff2dede', endColorstr='#ffebcccc', GradientType=0);background-repeat:repeat-x}.well{background-image:-webkit-linear-gradient(top,#e8e8e8 0,#f5f5f5 100%);background-image:-o-linear-gradient(top,#e8e8e8 0,#f5f5f5 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#e8e8e8),to(#f5f5f5));background-image:linear-gradient(to bottom,#e8e8e8 0,#f5f5f5 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffe8e8e8', endColorstr='#fff5f5f5', GradientType=0);background-repeat:repeat-x;border-color:#dcdcdc;-webkit-box-shadow:inset 0 1px 3px rgba(0,0,0,.05),0 1px 0 rgba(255,255,255,.1);box-shadow:inset 0 1px 3px rgba(0,0,0,.05),0 1px 0 rgba(255,255,255,.1)} --------------------------------------------------------------------------------