Skip to content

Commit b2f2b42

Browse files
authored
Merge pull request #39 from akatsoulas/rename-settings
Better naming for project's settings.
2 parents 8085886 + 50aa3d8 commit b2f2b42

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

mozilla_django_oidc/auth.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ def __init__(self, *args, **kwargs):
2020
"""Initialize settings."""
2121
self.OIDC_OP_TOKEN_ENDPOINT = import_from_settings('OIDC_OP_TOKEN_ENDPOINT')
2222
self.OIDC_OP_USER_ENDPOINT = import_from_settings('OIDC_OP_USER_ENDPOINT')
23-
self.OIDC_OP_CLIENT_ID = import_from_settings('OIDC_OP_CLIENT_ID')
24-
self.OIDC_OP_CLIENT_SECRET = import_from_settings('OIDC_OP_CLIENT_SECRET')
23+
self.OIDC_RP_CLIENT_ID = import_from_settings('OIDC_RP_CLIENT_ID')
24+
self.OIDC_RP_CLIENT_SECRET = import_from_settings('OIDC_RP_CLIENT_SECRET')
2525

2626
self.UserModel = get_user_model()
2727

@@ -31,9 +31,9 @@ def verify_token(self, token, **kwargs):
3131
# Get JWT audience without signature verification
3232
audience = jwt.decode(token, verify=False)['aud']
3333

34-
secret = self.OIDC_OP_CLIENT_SECRET
34+
secret = self.OIDC_RP_CLIENT_SECRET
3535
if import_from_settings('OIDC_RP_CLIENT_SECRET_ENCODED', False):
36-
secret = base64.urlsafe_b64decode(self.OIDC_OP_CLIENT_SECRET)
36+
secret = base64.urlsafe_b64decode(self.OIDC_RP_CLIENT_SECRET)
3737

3838
return jwt.decode(token, secret,
3939
verify=import_from_settings('OIDC_VERIFY_JWT', True),
@@ -46,8 +46,8 @@ def authenticate(self, code=None, state=None):
4646
return None
4747

4848
token_payload = {
49-
'client_id': self.OIDC_OP_CLIENT_ID,
50-
'client_secret': self.OIDC_OP_CLIENT_SECRET,
49+
'client_id': self.OIDC_RP_CLIENT_ID,
50+
'client_secret': self.OIDC_RP_CLIENT_SECRET,
5151
'grant_type': 'authorization_code',
5252
'code': code,
5353
'redirect_uri': absolutify(reverse('oidc_authentication_callback'))
@@ -56,7 +56,7 @@ def authenticate(self, code=None, state=None):
5656
# Get the token
5757
response = requests.post(self.OIDC_OP_TOKEN_ENDPOINT,
5858
json=token_payload,
59-
verify=import_from_settings('VERIFY_SSL', True))
59+
verify=import_from_settings('OIDC_VERIFY_SSL', True))
6060
response.raise_for_status()
6161

6262
# Validate the token

mozilla_django_oidc/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def __init__(self, *args, **kwargs):
6565
super(OIDCAuthenticationRequestView, self).__init__(*args, **kwargs)
6666

6767
self.OIDC_OP_AUTH_ENDPOINT = import_from_settings('OIDC_OP_AUTHORIZATION_ENDPOINT')
68-
self.OIDC_OP_CLIENT_ID = import_from_settings('OIDC_OP_CLIENT_ID')
68+
self.OIDC_RP_CLIENT_ID = import_from_settings('OIDC_RP_CLIENT_ID')
6969

7070
def get(self, request):
7171
"""OIDC client authentication initialization HTTP endpoint"""
@@ -74,7 +74,7 @@ def get(self, request):
7474
params = {
7575
'response_type': 'code',
7676
'scope': 'openid',
77-
'client_id': self.OIDC_OP_CLIENT_ID,
77+
'client_id': self.OIDC_RP_CLIENT_ID,
7878
'redirect_uri': absolutify(reverse('oidc_authentication_callback')),
7979
'state': state,
8080
}

tests/test_auth.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ class OIDCAuthenticationBackendTestCase(TestCase):
1414

1515
@override_settings(OIDC_OP_TOKEN_ENDPOINT='https://server.example.com/token')
1616
@override_settings(OIDC_OP_USER_ENDPOINT='https://server.example.com/user')
17-
@override_settings(OIDC_OP_CLIENT_ID='example_id')
18-
@override_settings(OIDC_OP_CLIENT_SECRET='example_secret')
17+
@override_settings(OIDC_RP_CLIENT_ID='example_id')
18+
@override_settings(OIDC_RP_CLIENT_SECRET='example_secret')
1919
def setUp(self):
2020
self.backend = OIDCAuthenticationBackend()
2121

tests/test_views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def setUp(self):
169169
self.factory = RequestFactory()
170170

171171
@override_settings(OIDC_OP_AUTHORIZATION_ENDPOINT='https://server.example.com/auth')
172-
@override_settings(OIDC_OP_CLIENT_ID='example_id')
172+
@override_settings(OIDC_RP_CLIENT_ID='example_id')
173173
@override_settings(SITE_URL='http://site-url.com')
174174
@patch('mozilla_django_oidc.views.get_random_string')
175175
def test_get(self, mock_random_string):

0 commit comments

Comments
 (0)