{"action":"created","comment":{"url":"https://api.github.com/repos/django/django/pulls/comments/28194603","id":28194603,"diff_hunk":"@@ -0,0 +1,134 @@\n+from __future__ import unicode_literals\n+\n+import os\n+import re\n+from difflib import SequenceMatcher\n+\n+from django.conf import settings\n+from django.core.exceptions import ImproperlyConfigured, ValidationError\n+from django.template.defaultfilters import unordered_list\n+from django.utils.encoding import force_text\n+from django.utils.module_loading import import_string\n+from django.utils.six import string_types\n+from django.utils.translation import ugettext as _\n+\n+\n+def get_password_validators():\n+    validators = []\n+    for validator in settings.AUTH_PASSWORD_VALIDATORS:\n+        try:\n+            klass = import_string(validator['NAME'])\n+            validators.append(klass(**validator.get('OPTIONS', {})))\n+        except ImportError:\n+            raise ImproperlyConfigured(\"Invalid NAME for a password validator: %s. Check \"\n+                                       \"your AUTH_PASSWORD_VALIDATORS setting.\" % validator['NAME'])\n+\n+    return validators\n+\n+\n+def validate_password(password, user=None):\n+    \"\"\"\n+    Validates whether the password meets all validator requirements.\n+\n+    If the password is valid, returns ``None``.\n+    If the password is invalid, raises ValidationError with all error messages.\n+    \"\"\"\n+    errors = []\n+    for validator in get_password_validators():\n+        error = validator.validate(password, user)\n+        if error:\n+            errors.append(error)\n+    if errors:\n+        raise ValidationError(errors)\n+\n+\n+def password_changed(password, user=None):\n+    \"\"\"\n+    Informs all validators, that have implemented this feature, that the password has been changed.\n+    \"\"\"\n+    for validator in get_password_validators():\n+        if hasattr(validator, 'password_changed'):\n+            validator.password_changed(password, user)\n+\n+\n+def password_validators_help_texts():\n+    \"\"\"\n+    Returns a list of all help texts of all configured validators.\n+    \"\"\"\n+    help_texts = []\n+    for validator in get_password_validators():\n+        help_texts.append(validator.get_help_text())\n+    return help_texts\n+\n+\n+def password_validators_help_text_html():\n+    \"\"\"\n+    Returns an HTML string with all help texts of all configured validators in an <ul>.","path":"django/contrib/auth/password_validation.py","position":66,"original_position":66,"commit_id":"6a9f0c244fc69cfd61590f2c2338c33ca8e77c8a","original_commit_id":"6a9f0c244fc69cfd61590f2c2338c33ca8e77c8a","user":{"login":"timgraham","id":411869,"avatar_url":"https://avatars.githubusercontent.com/u/411869?v=3","gravatar_id":"","url":"https://api.github.com/users/timgraham","html_url":"https://github.com/timgraham","followers_url":"https://api.github.com/users/timgraham/followers","following_url":"https://api.github.com/users/timgraham/following{/other_user}","gists_url":"https://api.github.com/users/timgraham/gists{/gist_id}","starred_url":"https://api.github.com/users/timgraham/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timgraham/subscriptions","organizations_url":"https://api.github.com/users/timgraham/orgs","repos_url":"https://api.github.com/users/timgraham/repos","events_url":"https://api.github.com/users/timgraham/events{/privacy}","received_events_url":"https://api.github.com/users/timgraham/received_events","type":"User","site_admin":false},"body":"I would read it as \"validators in a 'U' 'L'\" so I would say \"in a\" rather than \"in an\" but if you read it as \"unordered list\" than \"an\" is fine.","created_at":"2015-04-11T12:40:15Z","updated_at":"2015-04-11T12:40:15Z","html_url":"https://github.com/django/django/pull/4276#discussion_r28194603","pull_request_url":"https://api.github.com/repos/django/django/pulls/4276","_links":{"self":{"href":"https://api.github.com/repos/django/django/pulls/comments/28194603"},"html":{"href":"https://github.com/django/django/pull/4276#discussion_r28194603"},"pull_request":{"href":"https://api.github.com/repos/django/django/pulls/4276"}}},"pull_request":{"url":"https://api.github.com/repos/django/django/pulls/4276","id":30720598,"html_url":"https://github.com/django/django/pull/4276","diff_url":"https://github.com/django/django/pull/4276.diff","patch_url":"https://github.com/django/django/pull/4276.patch","issue_url":"https://api.github.com/repos/django/django/issues/4276","number":4276,"state":"open","locked":false,"title":"WIP - Added password validation to django.contrib.auth","user":{"login":"erikr","id":98594,"avatar_url":"https://avatars.githubusercontent.com/u/98594?v=3","gravatar_id":"","url":"https://api.github.com/users/erikr","html_url":"https://github.com/erikr","followers_url":"https://api.github.com/users/erikr/followers","following_url":"https://api.github.com/users/erikr/following{/other_user}","gists_url":"https://api.github.com/users/erikr/gists{/gist_id}","starred_url":"https://api.github.com/users/erikr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erikr/subscriptions","organizations_url":"https://api.github.com/users/erikr/orgs","repos_url":"https://api.github.com/users/erikr/repos","events_url":"https://api.github.com/users/erikr/events{/privacy}","received_events_url":"https://api.github.com/users/erikr/received_events","type":"User","site_admin":false},"body":"- [x] Aggregate all validation errors.\r\n- [x] Aggregate all requirements with HTML lists.\r\n- [x] Call a method on each validator after a successful change.\r\n- [x] Validator for most common passwords.\r\n- [x] See whether similarity errors can be made more specific.\r\n- [x] Look into performance impact of current similarity validator.\r\n- [x] Tests\r\n- [x] Docs\r\n- [ ] Add a basic regex validator with an option to check for fully numerical passwords.\r\n- [ ] Release notes\r\n\r\nMailing list discussion on: https://groups.google.com/forum/#!topic/django-developers/9GBhgGXmEKs","created_at":"2015-03-08T14:47:10Z","updated_at":"2015-04-11T12:40:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d31ee3780c7855350b5068f0fe7eeb4756a833f9","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/django/django/pulls/4276/commits","review_comments_url":"https://api.github.com/repos/django/django/pulls/4276/comments","review_comment_url":"https://api.github.com/repos/django/django/pulls/comments{/number}","comments_url":"https://api.github.com/repos/django/django/issues/4276/comments","statuses_url":"https://api.github.com/repos/django/django/statuses/6a9f0c244fc69cfd61590f2c2338c33ca8e77c8a","head":{"label":"erikr:password-validation","ref":"password-validation","sha":"6a9f0c244fc69cfd61590f2c2338c33ca8e77c8a","user":{"login":"erikr","id":98594,"avatar_url":"https://avatars.githubusercontent.com/u/98594?v=3","gravatar_id":"","url":"https://api.github.com/users/erikr","html_url":"https://github.com/erikr","followers_url":"https://api.github.com/users/erikr/followers","following_url":"https://api.github.com/users/erikr/following{/other_user}","gists_url":"https://api.github.com/users/erikr/gists{/gist_id}","starred_url":"https://api.github.com/users/erikr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erikr/subscriptions","organizations_url":"https://api.github.com/users/erikr/orgs","repos_url":"https://api.github.com/users/erikr/repos","events_url":"https://api.github.com/users/erikr/events{/privacy}","received_events_url":"https://api.github.com/users/erikr/received_events","type":"User","site_admin":false},"repo":{"id":31775076,"name":"django","full_name":"erikr/django","owner":{"login":"erikr","id":98594,"avatar_url":"https://avatars.githubusercontent.com/u/98594?v=3","gravatar_id":"","url":"https://api.github.com/users/erikr","html_url":"https://github.com/erikr","followers_url":"https://api.github.com/users/erikr/followers","following_url":"https://api.github.com/users/erikr/following{/other_user}","gists_url":"https://api.github.com/users/erikr/gists{/gist_id}","starred_url":"https://api.github.com/users/erikr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erikr/subscriptions","organizations_url":"https://api.github.com/users/erikr/orgs","repos_url":"https://api.github.com/users/erikr/repos","events_url":"https://api.github.com/users/erikr/events{/privacy}","received_events_url":"https://api.github.com/users/erikr/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/erikr/django","description":"The Web framework for perfectionists with deadlines.","fork":true,"url":"https://api.github.com/repos/erikr/django","forks_url":"https://api.github.com/repos/erikr/django/forks","keys_url":"https://api.github.com/repos/erikr/django/keys{/key_id}","collaborators_url":"https://api.github.com/repos/erikr/django/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/erikr/django/teams","hooks_url":"https://api.github.com/repos/erikr/django/hooks","issue_events_url":"https://api.github.com/repos/erikr/django/issues/events{/number}","events_url":"https://api.github.com/repos/erikr/django/events","assignees_url":"https://api.github.com/repos/erikr/django/assignees{/user}","branches_url":"https://api.github.com/repos/erikr/django/branches{/branch}","tags_url":"https://api.github.com/repos/erikr/django/tags","blobs_url":"https://api.github.com/repos/erikr/django/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/erikr/django/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/erikr/django/git/refs{/sha}","trees_url":"https://api.github.com/repos/erikr/django/git/trees{/sha}","statuses_url":"https://api.github.com/repos/erikr/django/statuses/{sha}","languages_url":"https://api.github.com/repos/erikr/django/languages","stargazers_url":"https://api.github.com/repos/erikr/django/stargazers","contributors_url":"https://api.github.com/repos/erikr/django/contributors","subscribers_url":"https://api.github.com/repos/erikr/django/subscribers","subscription_url":"https://api.github.com/repos/erikr/django/subscription","commits_url":"https://api.github.com/repos/erikr/django/commits{/sha}","git_commits_url":"https://api.github.com/repos/erikr/django/git/commits{/sha}","comments_url":"https://api.github.com/repos/erikr/django/comments{/number}","issue_comment_url":"https://api.github.com/repos/erikr/django/issues/comments{/number}","contents_url":"https://api.github.com/repos/erikr/django/contents/{+path}","compare_url":"https://api.github.com/repos/erikr/django/compare/{base}...{head}","merges_url":"https://api.github.com/repos/erikr/django/merges","archive_url":"https://api.github.com/repos/erikr/django/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/erikr/django/downloads","issues_url":"https://api.github.com/repos/erikr/django/issues{/number}","pulls_url":"https://api.github.com/repos/erikr/django/pulls{/number}","milestones_url":"https://api.github.com/repos/erikr/django/milestones{/number}","notifications_url":"https://api.github.com/repos/erikr/django/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/erikr/django/labels{/name}","releases_url":"https://api.github.com/repos/erikr/django/releases{/id}","created_at":"2015-03-06T15:18:02Z","updated_at":"2015-03-14T08:47:05Z","pushed_at":"2015-04-11T09:11:46Z","git_url":"git://github.com/erikr/django.git","ssh_url":"git@github.com:erikr/django.git","clone_url":"https://github.com/erikr/django.git","svn_url":"https://github.com/erikr/django","homepage":"https://www.djangoproject.com/","size":129458,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"django:master","ref":"master","sha":"a7bc00e17bebe34cdf23f744937b3c386ee73d81","user":{"login":"django","id":27804,"avatar_url":"https://avatars.githubusercontent.com/u/27804?v=3","gravatar_id":"","url":"https://api.github.com/users/django","html_url":"https://github.com/django","followers_url":"https://api.github.com/users/django/followers","following_url":"https://api.github.com/users/django/following{/other_user}","gists_url":"https://api.github.com/users/django/gists{/gist_id}","starred_url":"https://api.github.com/users/django/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/django/subscriptions","organizations_url":"https://api.github.com/users/django/orgs","repos_url":"https://api.github.com/users/django/repos","events_url":"https://api.github.com/users/django/events{/privacy}","received_events_url":"https://api.github.com/users/django/received_events","type":"Organization","site_admin":false},"repo":{"id":4164482,"name":"django","full_name":"django/django","owner":{"login":"django","id":27804,"avatar_url":"https://avatars.githubusercontent.com/u/27804?v=3","gravatar_id":"","url":"https://api.github.com/users/django","html_url":"https://github.com/django","followers_url":"https://api.github.com/users/django/followers","following_url":"https://api.github.com/users/django/following{/other_user}","gists_url":"https://api.github.com/users/django/gists{/gist_id}","starred_url":"https://api.github.com/users/django/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/django/subscriptions","organizations_url":"https://api.github.com/users/django/orgs","repos_url":"https://api.github.com/users/django/repos","events_url":"https://api.github.com/users/django/events{/privacy}","received_events_url":"https://api.github.com/users/django/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/django/django","description":"The Web framework for perfectionists with deadlines.","fork":false,"url":"https://api.github.com/repos/django/django","forks_url":"https://api.github.com/repos/django/django/forks","keys_url":"https://api.github.com/repos/django/django/keys{/key_id}","collaborators_url":"https://api.github.com/repos/django/django/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/django/django/teams","hooks_url":"https://api.github.com/repos/django/django/hooks","issue_events_url":"https://api.github.com/repos/django/django/issues/events{/number}","events_url":"https://api.github.com/repos/django/django/events","assignees_url":"https://api.github.com/repos/django/django/assignees{/user}","branches_url":"https://api.github.com/repos/django/django/branches{/branch}","tags_url":"https://api.github.com/repos/django/django/tags","blobs_url":"https://api.github.com/repos/django/django/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/django/django/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/django/django/git/refs{/sha}","trees_url":"https://api.github.com/repos/django/django/git/trees{/sha}","statuses_url":"https://api.github.com/repos/django/django/statuses/{sha}","languages_url":"https://api.github.com/repos/django/django/languages","stargazers_url":"https://api.github.com/repos/django/django/stargazers","contributors_url":"https://api.github.com/repos/django/django/contributors","subscribers_url":"https://api.github.com/repos/django/django/subscribers","subscription_url":"https://api.github.com/repos/django/django/subscription","commits_url":"https://api.github.com/repos/django/django/commits{/sha}","git_commits_url":"https://api.github.com/repos/django/django/git/commits{/sha}","comments_url":"https://api.github.com/repos/django/django/comments{/number}","issue_comment_url":"https://api.github.com/repos/django/django/issues/comments{/number}","contents_url":"https://api.github.com/repos/django/django/contents/{+path}","compare_url":"https://api.github.com/repos/django/django/compare/{base}...{head}","merges_url":"https://api.github.com/repos/django/django/merges","archive_url":"https://api.github.com/repos/django/django/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/django/django/downloads","issues_url":"https://api.github.com/repos/django/django/issues{/number}","pulls_url":"https://api.github.com/repos/django/django/pulls{/number}","milestones_url":"https://api.github.com/repos/django/django/milestones{/number}","notifications_url":"https://api.github.com/repos/django/django/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/django/django/labels{/name}","releases_url":"https://api.github.com/repos/django/django/releases{/id}","created_at":"2012-04-28T02:47:18Z","updated_at":"2015-04-11T11:34:57Z","pushed_at":"2015-04-11T09:11:50Z","git_url":"git://github.com/django/django.git","ssh_url":"git@github.com:django/django.git","clone_url":"https://github.com/django/django.git","svn_url":"https://github.com/django/django","homepage":"https://www.djangoproject.com/","size":283132,"stargazers_count":13738,"watchers_count":13738,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":5398,"mirror_url":null,"open_issues_count":76,"forks":5398,"open_issues":76,"watchers":13738,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/django/django/pulls/4276"},"html":{"href":"https://github.com/django/django/pull/4276"},"issue":{"href":"https://api.github.com/repos/django/django/issues/4276"},"comments":{"href":"https://api.github.com/repos/django/django/issues/4276/comments"},"review_comments":{"href":"https://api.github.com/repos/django/django/pulls/4276/comments"},"review_comment":{"href":"https://api.github.com/repos/django/django/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/django/django/pulls/4276/commits"},"statuses":{"href":"https://api.github.com/repos/django/django/statuses/6a9f0c244fc69cfd61590f2c2338c33ca8e77c8a"}}}}