"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "keystone/common/validation/validators.py" between
keystone-16.0.1.tar.gz and keystone-17.0.0.tar.gz

About: OpenStack Keystone (Core Service: Identity) provides an authentication and authorization service for other OpenStack services. Provides a catalog of endpoints for all OpenStack services.
The "Ussuri" series (latest release).

validators.py  (keystone-16.0.1):validators.py  (keystone-17.0.0)
skipping to change at line 19 skipping to change at line 19
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
"""Internal implementation of request body validating middleware.""" """Internal implementation of request body validating middleware."""
import re import re
import jsonschema import jsonschema
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log from oslo_log import log
import six
from keystone import exception from keystone import exception
from keystone.i18n import _ from keystone.i18n import _
CONF = cfg.CONF CONF = cfg.CONF
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)
# TODO(rderose): extend schema validation and add this check there # TODO(rderose): extend schema validation and add this check there
def validate_password(password): def validate_password(password):
pattern = CONF.security_compliance.password_regex pattern = CONF.security_compliance.password_regex
if pattern: if pattern:
if not isinstance(password, six.string_types): if not isinstance(password, str):
detail = _("Password must be a string type") detail = _("Password must be a string type")
raise exception.PasswordValidationError(detail=detail) raise exception.PasswordValidationError(detail=detail)
try: try:
if not re.match(pattern, password): if not re.match(pattern, password):
pattern_desc = ( pattern_desc = (
CONF.security_compliance.password_regex_description) CONF.security_compliance.password_regex_description)
raise exception.PasswordRequirementsValidationError( raise exception.PasswordRequirementsValidationError(
detail=pattern_desc) detail=pattern_desc)
except re.error: except re.error:
msg = ("Unable to validate password due to invalid regular " msg = ("Unable to validate password due to invalid regular "
skipping to change at line 81 skipping to change at line 80
# NOTE: For whole OpenStack message consistency, this error # NOTE: For whole OpenStack message consistency, this error
# message has been written in a format consistent with WSME. # message has been written in a format consistent with WSME.
if ex.path: if ex.path:
# NOTE(lbragstad): Here we could think about using iter_errors # NOTE(lbragstad): Here we could think about using iter_errors
# as a method of providing invalid parameters back to the # as a method of providing invalid parameters back to the
# user. # user.
# TODO(lbragstad): If the value of a field is confidential or # TODO(lbragstad): If the value of a field is confidential or
# too long, then we should build the masking in here so that # too long, then we should build the masking in here so that
# we don't expose sensitive user information in the event it # we don't expose sensitive user information in the event it
# fails validation. # fails validation.
path = '/'.join(map(six.text_type, ex.path)) path = '/'.join(map(str, ex.path))
detail = _("Invalid input for field '%(path)s': " detail = _("Invalid input for field '%(path)s': "
"%(message)s") % {'path': path, "%(message)s") % {'path': path,
'message': six.text_type(ex)} 'message': str(ex)}
else: else:
detail = six.text_type(ex) detail = str(ex)
raise exception.SchemaValidationError(detail=detail) raise exception.SchemaValidationError(detail=detail)
 End of changes. 5 change blocks. 
5 lines changed or deleted 4 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)