Login

SAS70 Compliant Password Validator

Author:
czieler
Posted:
August 2, 2007
Language:
Python
Version:
.96
Score:
3 (after 3 ratings)

Validator to verify a password is SAS70 compliant: greater than or equal to eight characters, and contains at least three out of the four characters( Uppercase, Lowercase, Number, Special Character ).

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
specialchar_list = ['!','@','#','$','%','^','&','*','(',')','-','_','=','+','{','}','[',']']
def validate_password(field_data, all_data):
                if len(field_data) < 8:
                         raise validators.ValidationError("Passwords must be a least 8 characters long.")
                # is it sas 70 compliant?

                passcount = 0
                if re.search('[A-Z]', field_data):
                        passcount = passcount + 1

                if re.search('[a-z]', field_data):
                        passcount = passcount + 1

                if re.search('[0-9]', field_data):
                        passcount = passcount + 1

                # does it contain special characters?
                for char in field_data:
                        if char in specialchar_list:
                                passcount = passcount + 1
                                break

                if passcount < 3:
                        raise validators.ValidationError("Passwords must contain three of the following four:<br>&nbsp;&nbsp;&nbsp;Uppercase, Lowercase, Number, Special Character.")

More like this

  1. Template tag - list punctuation for a list of items by shapiromatron 10 months, 1 week ago
  2. JSONRequestMiddleware adds a .json() method to your HttpRequests by cdcarter 10 months, 2 weeks ago
  3. Serializer factory with Django Rest Framework by julio 1 year, 5 months ago
  4. Image compression before saving the new model / work with JPG, PNG by Schleidens 1 year, 6 months ago
  5. Help text hyperlinks by sa2812 1 year, 6 months ago

Comments

Please login first before commenting.