Skip to content

Commit 99dead1

Browse files
Qup42dopry
authored andcommitted
Small rewording of exception messages
1 parent 97986e8 commit 99dead1

File tree

3 files changed

+21
-23
lines changed

3 files changed

+21
-23
lines changed

oauth2_provider/exceptions.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ class FatalClientError(OAuthToolkitError):
1919
pass
2020

2121

22-
# TODO: Cleanup
2322
class OIDCError(Exception):
23+
"""
24+
General class to derive from for all OIDC related errors.
25+
"""
26+
2427
status_code = 400
2528
error = None
2629

@@ -34,30 +37,29 @@ def __init__(self, description=None):
3437

3538
class InvalidRequestFatalError(OIDCError):
3639
"""
37-
For fatal errors, the request is missing a required parameter, includes
38-
an invalid parameter value, includes a parameter more than once, or is
39-
otherwise malformed.
40+
For fatal errors. These are requests with invalid parameter values, missing parameters or otherwise
41+
incorrect requests.
4042
"""
4143

4244
error = "invalid_request"
4345

4446

4547
class ClientIdMissmatch(InvalidRequestFatalError):
46-
description = "Missmatch between Client ID of the ID Token and provided the Client ID."
48+
description = "Mismatch between the Client ID of the ID Token and the Client ID that was provided."
4749

4850

4951
class InvalidOIDCClientError(InvalidRequestFatalError):
50-
description = "The Client is unknown or no client was included."
52+
description = "The client is unknown or no client has been included."
5153

5254

53-
class MismatchingOIDCRedirectURIError(InvalidRequestFatalError):
54-
description = "Mismatching post logout redirect URI."
55+
class InvalidOIDCRedirectURIError(InvalidRequestFatalError):
56+
description = "Invalid post logout redirect URI."
5557

5658

5759
class InvalidIDTokenError(InvalidRequestFatalError):
58-
description = "The ID Token is expired, revoked, malformed, or invalid for other reasons."
60+
description = "The ID Token is expired, revoked, malformed, or otherwise invalid."
5961

6062

6163
class LogoutDenied(OIDCError):
6264
error = "logout_denied"
63-
description = "Logout was denied by the user."
65+
description = "Logout has been refused by the user."

oauth2_provider/views/oidc.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
ClientIdMissmatch,
1515
InvalidIDTokenError,
1616
InvalidOIDCClientError,
17+
InvalidOIDCRedirectURIError,
1718
LogoutDenied,
18-
MismatchingOIDCRedirectURIError,
1919
OIDCError,
2020
)
2121
from ..forms import ConfirmLogoutForm
@@ -195,13 +195,13 @@ def validate_logout_request(user, id_token_hint, client_id, post_logout_redirect
195195
raise InvalidOIDCClientError()
196196
scheme = urlparse(post_logout_redirect_uri)[0]
197197
if not scheme:
198-
raise MismatchingOIDCRedirectURIError("A Scheme is required for the redirect URI.")
198+
raise InvalidOIDCRedirectURIError("A Scheme is required for the redirect URI.")
199199
if scheme == "http" and application.client_type != "confidential":
200-
raise MismatchingOIDCRedirectURIError("http is only allowed with confidential clients.")
200+
raise InvalidOIDCRedirectURIError("http is only allowed with confidential clients.")
201201
if scheme not in application.get_allowed_schemes():
202-
raise MismatchingOIDCRedirectURIError(f'Redirect to scheme "{scheme}" is not permitted.')
202+
raise InvalidOIDCRedirectURIError(f'Redirect to scheme "{scheme}" is not permitted.')
203203
if not application.post_logout_redirect_uri_allowed(post_logout_redirect_uri):
204-
raise MismatchingOIDCRedirectURIError("This client does not have this redirect uri registered.")
204+
raise InvalidOIDCRedirectURIError("This client does not have this redirect uri registered.")
205205

206206
return prompt_logout, (post_logout_redirect_uri, application)
207207

tests/test_oidc_views.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@
33
from django.test import TestCase
44
from django.urls import reverse
55

6-
from oauth2_provider.exceptions import (
7-
ClientIdMissmatch,
8-
InvalidOIDCClientError,
9-
MismatchingOIDCRedirectURIError,
10-
)
6+
from oauth2_provider.exceptions import ClientIdMissmatch, InvalidOIDCClientError, InvalidOIDCRedirectURIError
117
from oauth2_provider.oauth2_validators import OAuth2Validator
128
from oauth2_provider.settings import oauth2_settings
139
from oauth2_provider.views.oidc import validate_logout_request
@@ -221,21 +217,21 @@ def test_validate_logout_request(oidc_tokens, public_application, other_user, rp
221217
client_id=None,
222218
post_logout_redirect_uri="http://example.org",
223219
)
224-
with pytest.raises(MismatchingOIDCRedirectURIError):
220+
with pytest.raises(InvalidOIDCRedirectURIError):
225221
validate_logout_request(
226222
user=oidc_tokens.user,
227223
id_token_hint=None,
228224
client_id=client_id,
229225
post_logout_redirect_uri="example.org",
230226
)
231-
with pytest.raises(MismatchingOIDCRedirectURIError):
227+
with pytest.raises(InvalidOIDCRedirectURIError):
232228
validate_logout_request(
233229
user=oidc_tokens.user,
234230
id_token_hint=None,
235231
client_id=client_id,
236232
post_logout_redirect_uri="imap://example.org",
237233
)
238-
with pytest.raises(MismatchingOIDCRedirectURIError):
234+
with pytest.raises(InvalidOIDCRedirectURIError):
239235
validate_logout_request(
240236
user=oidc_tokens.user,
241237
id_token_hint=None,

0 commit comments

Comments
 (0)