-
Notifications
You must be signed in to change notification settings - Fork 368
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
base: master
Are you sure you want to change the base?
Implement RFC 8628 #826
Conversation
7589ecc
to
73d570f
Compare
Looks like the conformity tests are failing because it tries to use this version of fosite on hydra |
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.
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
go 1.20 | ||
go 1.21 | ||
|
||
toolchain go1.21.4 |
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 1.21 needed?
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 was required for the update of ory/x
, I will roll it back to the lateset version that supports 1.20
.
handler/rfc8628/strategy_hmacsha.go
Outdated
key := code + "_limiter" | ||
|
||
keyBytes := []byte(key) | ||
object, err := h.RateLimiterCache.Get(keyBytes) |
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.
This won't work in real world scenarios. The cache is in memory which means:
- It won't work if more than one instance (which is almost always the case) of the library/hydra running
- It won't persist across restarts
In my view, rate limiting should be the concern of the firewall/ingress/reverse proxy and I think we could simplify this PR a bit by removing this part or making it optional and/or more generic
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.
Agreed on all your points. The reason we included this change is to be spec compliant and the reason we didn't implement a more sophisticated solution (which would probably require an external caching system) is that rate limiting should be handled by the ingress/firewall. But looking back at it, it is probably better to leave it unhandled, instead of having partly correct logic.
It is probably better to remove this and leave it as future work.
@@ -5,197 +5,99 @@ package oauth2 | |||
|
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.
This diff is quite challenging to read, would it be possible to reduce the refactoring and separating into different files? Since this is security relevant code, the smaller the diff the faster the review :)
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.
We will try to revert the refactored code and push the changes in the coming days
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 |
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.
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.
24db6b9
to
aa568e6
Compare
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. |
aa568e6
to
bf057ec
Compare
device_write_test.go
Outdated
resp.SetUserCode("AAAA") | ||
resp.SetDeviceCode("BBBB") | ||
resp.SetInterval(int( | ||
oauth2.Config.GetDeviceAuthTokenPollingInterval(context.TODO()).Round(time.Second).Seconds(), |
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.
I'd suggest to add a simple
ctx := context.Background()
in the beginning of each test, and use that as the context everywhere.
bf057ec
to
35c89bf
Compare
bfa2f4e
to
904e20c
Compare
e5035e8
to
94653ee
Compare
c778674
to
ae6e4e3
Compare
ae6e4e3
to
a5ad00e
Compare
a5ad00e
to
acb3361
Compare
… auth/device code is expired
fix: add the OIDC handler for device flow
* fix: fix the refresh token issue * fix: fix the OIDC token missing issue
7309753
to
9d5065e
Compare
Just wanted to leave a big thank you for the massive work you put into this @nsklikas! |
Related Design Document
Implements RFC 8628.
Checklist
If this pull request addresses a security vulnerability,
I confirm that I got approval (please contact security@ory.sh) from the maintainers to push the changes.
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:
go.uber.org/mock/gomock
(github.com/golang/mock/gomock
is deprecated)AuthorizeExplicitGrantHandler
to generalize it to reduce code duplication