-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
feat: add session and requester to refresh token webhook data #3204
Conversation
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.
Epic :) I think we can send the whole session in the payload!
To ensure that the change has the desired effect, can you please add the appropriate assertions to the test case:
hydra/oauth2/oauth2_auth_code_test.go
Line 916 in ceada19
t.Run("should call refresh token hook if configured", func(t *testing.T) { |
The documentation will also need to explain the new key, the appropriate document for that should be: https://github.com/ory/docs/blob/45a1f9268d693b164d169e16272a30327860c4e9/docs/hydra/guides/updating-claims-at-refresh.mdx
@aeneasr Is there a good approach to make |
A common practice, if the types don't work in swagger, is to create a replacement / patch like here: hydra/.schema/openapi/patches/oauth2.yaml Lines 3 to 4 in c9be891
Basically, this will patch the given path in https://github.com/ory/hydra/blob/master/spec/api.json with the value you provide. This can be helpful in scenarios where go-swagger creates types that just aren't correct. Regarding the files generated, that is fine and sometimes expected with OpenAPI generator - feel free to push your changes if you want me to take a look. |
Codecov Report
@@ Coverage Diff @@
## master #3204 +/- ##
==========================================
+ Coverage 79.28% 79.32% +0.04%
==========================================
Files 111 111
Lines 8077 8084 +7
==========================================
+ Hits 6404 6413 +9
+ Misses 1259 1258 -1
+ Partials 414 413 -1
Help us with your feedback. Take ten seconds to tell us how you rate us. |
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.
Great, this looks really good already! :)
Once finished, could you please also update the docs PR accordingly? Thank you!
oauth2/oauth2_auth_code_test.go
Outdated
require.Equal(t, hookReq.Requester.ClientID, oauthConfig.ClientID) | ||
require.ElementsMatch(t, hookReq.Requester.GrantedScopes, expectedGrantedScopes) | ||
|
||
assertx.EqualAsJSONExcept(t, hookReq.Session, json.RawMessage(`{ |
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.
If you use snapshotx.
it will create a JSON file on the disk which makes the content a bit easier to read:
snapshotx.SnapshotT(t, json.RawMessage("..."), snapshotx.ExceptPaths("...") )
To update snapshots set env var UPDATE_SNAPSHOTS=true
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 looks like snapshotx.SnapshotT
is not available in the version of snapshotx
that hydra
uses (0.0.368
). Tried to bump to lastest - 0.0.450
- a lot of tests fail. So I used SnapshotTExcept
.
Also, it generated 6 snapshots with the same content - probably because tests are run in parallel.
"session.id_token.id_token_claims.rat", | ||
"session.id_token.id_token_claims.auth_time", | ||
} | ||
snapshotx.SnapshotTExcept(t, hookReq, 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.
This is indeed tidier, thanks for pointing me into snapshotx
!
Docs PR is also updated with the latest schema. |
Hello @sgal |
Hey @aeneasr Is there a chance to rename the files so that Windows contributors are not blocked? |
Yes it’s already fixed on master! |
Sorry @aeneasr, but these two files are still in
Their names contain
Am I missing anything? |
Oh I see, then it's only fixed on the v2.x branch! |
Is there a chance to get the changes backported to |
Sure, can you maybe just cherry-pick the commit and make a PR? |
Sure, will do. |
👍 |
Related issue(s)
Feature: This patch adds
session
andrequester
data to the refresh webhook for session tracking by integrators. Fixes #3203.Checklist
If this pull request addresses a security. vulnerability,
I confirm that I got green light (please contact security@ory.sh) from the maintainers to push the changes.
Further Comments
Changes outside of
hook.go
are created by runningmake sdk
.