Skip to content
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

Synced implementation of token_endpoint #624

Merged
merged 2 commits into from
Mar 8, 2019
Merged

Conversation

tpazderka
Copy link
Collaborator

@tpazderka tpazderka commented Mar 2, 2019

All three providers (oauth2, oic and extension) now share common code.

  • Any changes relevant to users are recorded in the CHANGELOG.md.
  • The documentation has been updated, if necessary.

Prep work for #615 and #617.

Also getting rid of duplicated code...

@tpazderka tpazderka force-pushed the refactor_token_endpoint branch 2 times, most recently from 0e46ea9 to 1d039c1 Compare March 2, 2019 22:28
@codecov-io
Copy link

codecov-io commented Mar 2, 2019

Codecov Report

Merging #624 into master will increase coverage by 0.21%.
The diff coverage is 92.64%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #624      +/-   ##
==========================================
+ Coverage   61.29%   61.51%   +0.21%     
==========================================
  Files          62       62              
  Lines       11175    11140      -35     
  Branches     1979     1973       -6     
==========================================
+ Hits         6850     6853       +3     
+ Misses       3757     3727      -30     
+ Partials      568      560       -8
Impacted Files Coverage Δ
src/oic/extension/provider.py 63.44% <ø> (-0.09%) ⬇️
src/oic/oic/provider.py 65.09% <100%> (+0.9%) ⬆️
src/oic/oauth2/provider.py 70.26% <89.79%> (+2.73%) ⬆️
src/oic/utils/authn/client.py 68.46% <0%> (-1.21%) ⬇️
src/oic/utils/sdb.py 82.94% <0%> (+0.46%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9786ee0...e5ff129. Read the comment docs.

@tpazderka
Copy link
Collaborator Author

I will work on the few missing tests tomorrow.

@CZ-NIC CZ-NIC deleted a comment Mar 2, 2019
@CZ-NIC CZ-NIC deleted a comment Mar 3, 2019
@CZ-NIC CZ-NIC deleted a comment Mar 3, 2019
@CZ-NIC CZ-NIC deleted a comment Mar 3, 2019
@tpazderka
Copy link
Collaborator Author

OK, finished the tests. There are two spots missing. They technically were not changed :) so I am not going to bother with them just yet.

@CZ-NIC CZ-NIC deleted a comment Mar 4, 2019
@CZ-NIC CZ-NIC deleted a comment Mar 5, 2019
All three providers (oauth2, oic and extension) now share common code.
@CZ-NIC CZ-NIC deleted a comment Mar 6, 2019
@tpazderka tpazderka requested a review from schlenk March 6, 2019 18:14
Copy link
Collaborator

@schlenk schlenk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments, nothing major.

I'm not sure if we should raise NotImplementedExceptions there instead of returning an error_response.
And at least RFC 6749 5.2 has a different idea how errors should be handled. It says it should trigger an error with 'unsupported_grant_type' code.

One small thing i noticed at the side: In the oic.Provider() init call, the AProvider is called without server_cls just to overwrite the self.server a few lines later, which does the same thing. Maybe move that to the superclass call instead.

@@ -153,6 +154,8 @@ def re_authenticate(areq, authn):

class Provider(object):
endp = [AuthorizationEndpoint, TokenEndpoint]
# Define the message class that in token_enpdoint
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo in comment 'endpoint'

src/oic/oauth2/provider.py Show resolved Hide resolved
_info = self.sdb[areq["code"]]
except KeyError:
logger.error('Code not present in SessionDB')
error = TokenErrorResponse(error="unauthorized_client")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a reason to not set a error_description? Like we do in line 792.

It hides some information to omit more details, but we leak the info anyway, due to not being constant time here. So more helpful error messages might ease client debugging.

# If redirect_uri was in the initial authorization request verify that they match
if "redirect_uri" in _info and areq["redirect_uri"] != _info["redirect_uri"]:
logger.error('Redirect_uri mismatch')
error = TokenErrorResponse(error="unauthorized_client")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, with error_description

if 'state' in areq:
if _info['state'] != areq['state']:
logger.error('State value mismatch')
error = TokenErrorResponse(error="unauthorized_client")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here too, error_description

@tpazderka
Copy link
Collaborator Author

Thanks for the review. I will probably do a separate issue for the refactoring of init calls. The refactoring is probably needed for most of the shared methods anyway and I would like to keep this focused on token_endpoint.

@CZ-NIC CZ-NIC deleted a comment Mar 6, 2019
Copy link
Collaborator

@schlenk schlenk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

And yes, the init stuff should be an extra change. And yes, the init method has way too many kwargs already.

@tpazderka tpazderka merged commit 8b3dfcb into master Mar 8, 2019
@tpazderka tpazderka deleted the refactor_token_endpoint branch March 8, 2019 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants