diff options
author | Brendan Abolivier <babolivier@matrix.org> | 2019-05-22 11:09:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-22 11:09:42 +0100 |
commit | 64365fcbdd803ceb21b26d36968cab5791e5ff7f (patch) | |
tree | f6a5bf5a3238141380a971c6b64566eaaf85f91d /synapse/api | |
parent | Merge branch 'babolivier/account_validity_expiration_date' into dinsic (diff) | |
parent | Test whole dict instead of individual fields (diff) | |
download | synapse-64365fcbdd803ceb21b26d36968cab5791e5ff7f.tar.xz |
Merge pull request #5214 from matrix-org/babolivier/password-policy
Allow server admins to define and enforce a password policy (MSC2000)
Diffstat (limited to 'synapse/api')
-rw-r--r-- | synapse/api/errors.py | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/synapse/api/errors.py b/synapse/api/errors.py index ff89259dec..e6c67acf96 100644 --- a/synapse/api/errors.py +++ b/synapse/api/errors.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # Copyright 2014-2016 OpenMarket Ltd -# Copyright 2018 New Vector Ltd +# Copyright 2017-2018 New Vector Ltd +# Copyright 2019 The Matrix.org Foundation C.I.C. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -61,6 +62,13 @@ class Codes(object): INCOMPATIBLE_ROOM_VERSION = "M_INCOMPATIBLE_ROOM_VERSION" WRONG_ROOM_KEYS_VERSION = "M_WRONG_ROOM_KEYS_VERSION" EXPIRED_ACCOUNT = "ORG_MATRIX_EXPIRED_ACCOUNT" + PASSWORD_TOO_SHORT = "M_PASSWORD_TOO_SHORT" + PASSWORD_NO_DIGIT = "M_PASSWORD_NO_DIGIT" + PASSWORD_NO_UPPERCASE = "M_PASSWORD_NO_UPPERCASE" + PASSWORD_NO_LOWERCASE = "M_PASSWORD_NO_LOWERCASE" + PASSWORD_NO_SYMBOL = "M_PASSWORD_NO_SYMBOL" + PASSWORD_IN_DICTIONARY = "M_PASSWORD_IN_DICTIONARY" + WEAK_PASSWORD = "M_WEAK_PASSWORD" class CodeMessageException(RuntimeError): @@ -349,6 +357,22 @@ class IncompatibleRoomVersionError(SynapseError): ) +class PasswordRefusedError(SynapseError): + """A password has been refused, either during password reset/change or registration. + """ + + def __init__( + self, + msg="This password doesn't comply with the server's policy", + errcode=Codes.WEAK_PASSWORD, + ): + super(PasswordRefusedError, self).__init__( + code=400, + msg=msg, + errcode=errcode, + ) + + class RequestSendFailed(RuntimeError): """Sending a HTTP request over federation failed due to not being able to talk to the remote server for some reason. |