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

Implement RFC 8628 #826

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open

Implement RFC 8628 #826

wants to merge 36 commits into from

Conversation

nsklikas
Copy link

@nsklikas nsklikas commented Sep 30, 2024

BREAKING CHANGES: This patch breaks up `OAuth2AuthorizeExplicitFactory` into
`OAuth2AuthorizeExplicitAuthFactory` and `Oauth2AuthorizeExplicitTokenFactory`

Related Design Document

Implements RFC 8628.

Checklist

  • I have read the contributing guidelines and signed the CLA.
  • I have referenced an issue containing the design document if my change introduces a new feature.
  • I have read the security policy.
  • I confirm that this pull request does not address a security vulnerability.
    If this pull request addresses a security vulnerability,
    I confirm that I got approval (please contact [email protected]) from the maintainers to push the changes.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added the necessary documentation within the code base (if appropriate).

Further comments

This PR is based on the work done on #701, by @supercairos and @BuzzBumbleBee. That PR was based on an older version of fosite and was missing some features/tests.

Comments:

  • Due to some dependency issues we had to switch to go.uber.org/mock/gomock (github.com/golang/mock/gomock is deprecated)
  • We had to do a small refactor of the AuthorizeExplicitGrantHandler to generalize it to reduce code duplication

@nsklikas nsklikas requested a review from aeneasr as a code owner September 30, 2024 06:50
@CLAassistant
Copy link

CLAassistant commented Sep 30, 2024

CLA assistant check
All committers have signed the CLA.

@nsklikas
Copy link
Author

Looks like the conformity tests are failing because it tries to use this version of fosite on hydra master. But they pass on the hydra PR with this version of fosite. Changes are needed on the hydra config DefaultProvider object, how should we fix this?

Copy link
Member

@aeneasr aeneasr left a comment

Choose a reason for hiding this comment

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

Thank you very much for this massive PR! There's still thousands of lines to review, but here are some first remarks.

Primarily, some of the diffs are hard to read because they re-organize code into different files. Would it be possible to focus the changes on what's required to change and leave the refactoring out? We can always re-organize the code later, but given the sensitivity of the files touched (core token methods), it will be significantly easier to review those changes. Thank you!

go.mod Outdated Show resolved Hide resolved
fosite.go Show resolved Hide resolved
handler/rfc8628/strategy_hmacsha.go Outdated Show resolved Hide resolved
handler/oauth2/flow_authorize_code_token.go Outdated Show resolved Hide resolved
@aeneasr
Copy link
Member

aeneasr commented Oct 9, 2024

Looks like the conformity tests are failing because it tries to use this version of fosite on hydra master. But they pass on the hydra PR with this version of fosite. Changes are needed on the hydra config DefaultProvider object, how should we fix this?

You should be able to change the target commit in the CI file to target your PR in hydra, which should make the tests pass

Copy link
Member

@zepatrik zepatrik left a comment

Choose a reason for hiding this comment

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

This looks great already, however due to the security implications I agree with @aeneasr that we should pull out some of the unrelated refactoring into separate PRs to reduce the size and complexity of this one, especially the migration from github.com/golang/mock/gomock to go.uber.org/mock/gomock and maybe also some other code style changes.
I did not yet fully review all parts, but these are some preliminary suggestions already.

device_request_handler.go Show resolved Hide resolved
device_request_handler.go Outdated Show resolved Hide resolved
device_request_handler.go Show resolved Hide resolved
device_request_handler_test.go Outdated Show resolved Hide resolved
device_request_handler_test.go Show resolved Hide resolved
device_request_handler_test.go Outdated Show resolved Hide resolved
device_request_test.go Outdated Show resolved Hide resolved
device_response.go Outdated Show resolved Hide resolved
errors.go Outdated Show resolved Hide resolved
handler/oauth2/flow_authorize_code_token.go Show resolved Hide resolved
handler/rfc8628/strategy_hmacsha.go Outdated Show resolved Hide resolved
handler/oauth2/flow_generic_code_token.go Outdated Show resolved Hide resolved
@nsklikas nsklikas force-pushed the canonical-master branch 3 times, most recently from 24db6b9 to aa568e6 Compare October 18, 2024 10:09
@nsklikas
Copy link
Author

Thank you for the reviews.

I reverted the refactor on the oauth2 handlers and tried to address all the comments. Also pinned the ci to use hydra from the PR branch and now the tests pass. Please have another go.

device_write_test.go Outdated Show resolved Hide resolved
device_write_test.go Outdated Show resolved Hide resolved
handler/rfc8628/auth_handler.go Show resolved Hide resolved
handler/rfc8628/storage.go Outdated Show resolved Hide resolved
@nsklikas nsklikas requested review from aeneasr, J-tt and zepatrik October 29, 2024 08:47
@nsklikas nsklikas force-pushed the canonical-master branch 2 times, most recently from bfa2f4e to 904e20c Compare November 6, 2024 14:17
@nsklikas nsklikas force-pushed the canonical-master branch 2 times, most recently from e5035e8 to 94653ee Compare November 13, 2024 10:57
@nsklikas nsklikas force-pushed the canonical-master branch 2 times, most recently from c778674 to ae6e4e3 Compare November 18, 2024 09:33
@nsklikas nsklikas requested a review from a team as a code owner January 7, 2025 15:45
@nsklikas nsklikas requested a review from aeneasr January 7, 2025 16:58
@eseliger
Copy link

Just wanted to leave a big thank you for the massive work you put into this @nsklikas!

Copy link
Member

@aeneasr aeneasr left a comment

Choose a reason for hiding this comment

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

Amazing work, there is one comment left around DeleteOpenIDSession, otherwise this is good to merge IMO

Next step is to get the hydra changes reviewed and then we can merge everything

}

// ValidateUserCode validates a user_code
func (h *DefaultDeviceStrategy) ValidateUserCode(ctx context.Context, r fosite.DeviceRequester, code string) error {
Copy link
Member

Choose a reason for hiding this comment

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

code is not being validated here?

if !exp.IsZero() && exp.Before(time.Now().UTC()) {
return errorsx.WithStack(fosite.ErrDeviceExpiredToken.WithHintf("User code expired at '%s'.", exp))
}
return nil
Copy link
Member

Choose a reason for hiding this comment

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

Actually, I think you forgot to validate the code here

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.

7 participants