-
Notifications
You must be signed in to change notification settings - Fork 27
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
Add OpenID Connect Token authenticator #167
base: master
Are you sure you want to change the base?
Conversation
cf4aabe
to
bdc2a78
Compare
Signed-off-by: Patrick Uiterwijk <puiterwijk@redhat.com>
Codecov Report
@@ Coverage Diff @@
## master #167 +/- ##
==========================================
- Coverage 60.02% 59.48% -0.54%
==========================================
Files 36 36
Lines 3042 3083 +41
Branches 338 345 +7
==========================================
+ Hits 1826 1834 +8
- Misses 1126 1159 +33
Partials 90 90
Continue to review full report at Codecov.
|
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.
Thanks Patrick, I left a couple of comments.
|
||
|
||
class OpenIDCTokenAuth(HTTPAuthenticator): | ||
token_info_url = PluginOption(str, None, |
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.
You can use REQUIRED
to make an option mandatory
return False | ||
elif request.get('access_token'): | ||
self.logger.debug('Token provided in form') | ||
token = request.get('access_token') |
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.
request['access_token]
self.logger.debug('Missing any credentials in request') | ||
return False | ||
|
||
if not token: |
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.
Is it necessary to check token again?
|
||
try: | ||
tokeninfo = self._get_token_info(token) | ||
except: |
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.
Please don't use a bare except. except Exception
scope = PluginOption(str, 'custodia', 'OAuth2 scope to require') | ||
|
||
def _get_token_info(self, token): | ||
return requests.post(self.token_info_url, |
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.
Other plugins accept a CA cert argument to customize TLS verification. We could have global option for trusted CA cert, too.
@@ -131,3 +133,62 @@ def handle(self, request): | |||
self.audit_svc_access(log.AUDIT_SVC_AUTH_FAIL, | |||
request['client_id'], dn) | |||
return False | |||
|
|||
|
|||
class OpenIDCTokenAuth(HTTPAuthenticator): |
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.
Please add a doc string with an example how to configure and use this plugin with e.g. Ipsilon.
Signed-off-by: Patrick Uiterwijk puiterwijk@redhat.com