-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added option to create user if authenticated but not in local database #25
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import os | ||
|
||
SECRET_KEY='secret' | ||
DATABASES = { | ||
'default': { | ||
|
@@ -13,4 +15,5 @@ | |
OIDC_AUTH = { | ||
'OIDC_ENDPOINT': 'http://example.com', | ||
'OIDC_AUDIENCES': ('you',), | ||
'CREATE_USER': os.getenv('CREATE_USER', 'yes') == 'yes', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't this make more sense as a boolean? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a boolean, right? It evaluates to true or false. In my mind it's hard to pass in an env var as a boolean. So in python, it's a boolean. As an env var it's a string. If one wants to use the string 'True' or the string 'False', okay - maybe that would be clearer. Or maybe not using the string 'True', it makes one think, and see what's happening. I'm using the same approach as found in many Django books, here. Thanks for your comments here. It's good to discuss. Hope that makes sense. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hehe, whoops 😅 Must have been that Friday afternoon slip 🙈 Never mind the comment |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
from rest_framework.views import APIView | ||
from requests import Response, HTTPError, ConnectionError | ||
from oidc_auth.authentication import JSONWebTokenAuthentication, BearerTokenAuthentication | ||
from oidc_auth.settings import api_settings | ||
import sys | ||
if sys.version_info > (3,): | ||
long = int | ||
|
@@ -208,7 +209,10 @@ def test_with_too_new_jwt(self): | |
def test_with_unknown_subject(self): | ||
auth = 'JWT ' + make_id_token(self.user.username + 'x') | ||
resp = self.client.get('/test/', HTTP_AUTHORIZATION=auth) | ||
self.assertEqual(resp.status_code, 401) | ||
if not api_settings.CREATE_USER: | ||
self.assertEqual(resp.status_code, 401) | ||
else: | ||
self.assertEqual(resp.status_code, 200) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be nicer to split this up into two tests, one that has the variable set to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for your comments on testing. Unfortunately, I'm not in a environment where I can test, or do any more work on oidc. At the young age of 64, I was asked to retire, so I'm only doing a little coding now, e.g. aws lambda (zappa). And I don't have access to an environment where I can continue to test and improve this type of authentication. Perhaps you can continue to improve this. Thanks for your comments |
||
|
||
def test_with_multiple_audiences(self): | ||
auth = 'JWT ' + make_id_token(self.user.username, aud=['you', 'me']) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice if there were some tests for this, since this is quite some modification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see my comments on testing below - thanks