Merge lp:~cjwatson/canonical-identity-provider/twofactor-required-error into lp:canonical-identity-provider/release

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: no longer in the source branch.
Merge reported by: Ubuntu One Auto Pilot
Merged at revision: not available
Proposed branch: lp:~cjwatson/canonical-identity-provider/twofactor-required-error
Merge into: lp:canonical-identity-provider/release
Diff against target: 62 lines (+9/-5)
2 files modified
docs/api.txt (+7/-4)
src/api/v20/utils.py (+2/-1)
To merge this branch: bzr merge lp:~cjwatson/canonical-identity-provider/twofactor-required-error
Reviewer Review Type Date Requested Status
Celso Providelo (community) Approve
Review via email: mp+305737@code.launchpad.net

Commit message

Assign a distinct "twofactor-required" error code.

Description of the change

Assign a distinct "twofactor-required" error code.

These errors only moved over to the new style last week, so I think it's unlikely anyone's depending on this being conflated with CAPTCHA_REQUIRED.

To post a comment you must log in.
Revision history for this message
Celso Providelo (cprov) wrote :

Thanks, Colin.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'docs/api.txt'
--- docs/api.txt 2016-09-02 11:31:05 +0000
+++ docs/api.txt 2016-09-14 16:52:23 +0000
@@ -154,23 +154,23 @@
154These are the codes used in the response and their meanings:154These are the codes used in the response and their meanings:
155155
156- ``account-not-ready``: the account is deactivated, suspended or account email156- ``account-not-ready``: the account is deactivated, suspended or account email
157 is not valildated.157 is not validated.
158158
159- ``bad-request``: there is a problem in the structure of the request.159- ``bad-request``: there is a problem in the structure of the request.
160160
161- ``field-required``: the field in the request can't be empty or null.
162
161- ``internal-server-error``: some unexpected problem server side; this will be163- ``internal-server-error``: some unexpected problem server side; this will be
162 the code in all 5xx cases.164 the code in all 5xx cases.
163165
164- ``invalid-credentials``: the credentials for the authentication are not valid166- ``invalid-credentials``: the credentials for the authentication are not valid
165 (e.g.: the username, password are not correct, the 2 factor is needed, etc).167 (e.g.: the username or password is not correct).
166168
167- ``invalid-data``: the data is incorrect or corrupt.169- ``invalid-data``: the data is incorrect or corrupt.
168170
169- ``permission-required``: the macaroon authorization is missing in171- ``permission-required``: the macaroon authorization is missing in
170 the received request or not enough for it to be fulfilled.172 the received request or not enough for it to be fulfilled.
171173
172- ``required``: the field in the request can't be empty or null.
173
174- ``resource-not-found``: one or more fields are included to specify a174- ``resource-not-found``: one or more fields are included to specify a
175 resource, but it is not found in the Store.175 resource, but it is not found in the Store.
176176
@@ -178,6 +178,9 @@
178 ready yet for that purpose; normally something else would need to be done178 ready yet for that purpose; normally something else would need to be done
179 first on the resource before this request can be repeated.179 first on the resource before this request can be repeated.
180180
181- ``twofactor-required``: two-factor authentication is required for this
182 request but was not provided.
183
181- ``user-not-ready``: the user is not ready to issue the received request;184- ``user-not-ready``: the user is not ready to issue the received request;
182 normally some actions would need to be done in the user account before185 normally some actions would need to be done in the user account before
183 repeating the request.186 repeating the request.
184187
=== modified file 'src/api/v20/utils.py'
--- src/api/v20/utils.py 2016-09-02 11:31:05 +0000
+++ src/api/v20/utils.py 2016-09-14 16:52:23 +0000
@@ -69,6 +69,7 @@
69 REQUIRED = 'field-required'69 REQUIRED = 'field-required'
70 RESOURCE_NOT_FOUND = 'resource-not-found'70 RESOURCE_NOT_FOUND = 'resource-not-found'
71 RESOURCE_NOT_READY = 'resource-not-ready'71 RESOURCE_NOT_READY = 'resource-not-ready'
72 TWOFACTOR_REQUIRED = 'twofactor-required'
7273
73 def __init__(self):74 def __init__(self):
74 self._codes = {getattr(self, code) for code in dir(self)75 self._codes = {getattr(self, code) for code in dir(self)
@@ -91,7 +92,7 @@
9192
92 TWOFACTOR_REQUIRED=(93 TWOFACTOR_REQUIRED=(
93 401, _("2-factor authentication required."),94 401, _("2-factor authentication required."),
94 ErrorCode.REQUIRED),95 ErrorCode.TWOFACTOR_REQUIRED),
9596
96 ACCOUNT_SUSPENDED=(97 ACCOUNT_SUSPENDED=(
97 403, _('Your account has been suspended. Please contact login '98 403, _('Your account has been suspended. Please contact login '