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

feat: return verification flow ID after registration flow #3144

Merged
merged 8 commits into from Mar 23, 2023

Conversation

jonas-jonas
Copy link
Contributor

@jonas-jonas jonas-jonas commented Mar 3, 2023

Related issue(s)

Closes #2975

Checklist

@jonas-jonas jonas-jonas force-pushed the jonas-jonas/fix/verificationIdAfterRegistration branch from c125149 to 5e64e93 Compare March 9, 2023 14:44
@jonas-jonas jonas-jonas force-pushed the jonas-jonas/fix/verificationIdAfterRegistration branch 3 times, most recently from 0e4f251 to 1da0e40 Compare March 9, 2023 15:19
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.

Nice, looking pretty good 👍
What other actions do we expect to be added?

selfservice/flow/continue_with.go Outdated Show resolved Hide resolved
selfservice/flow/continue_with.go Show resolved Hide resolved
selfservice/flow/registration/session.go Show resolved Hide resolved
selfservice/flow/settings/hook.go Outdated Show resolved Hide resolved
selfservice/hook/verification.go Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Mar 9, 2023

Codecov Report

Merging #3144 (56d29b0) into master (0002668) will increase coverage by 0.04%.
The diff coverage is 94.44%.

❗ Current head 56d29b0 differs from pull request most recent head 6330e71. Consider uploading reports for the commit 6330e71 to get more accurate results

@@            Coverage Diff             @@
##           master    #3144      +/-   ##
==========================================
+ Coverage   77.62%   77.66%   +0.04%     
==========================================
  Files         317      319       +2     
  Lines       20046    20110      +64     
==========================================
+ Hits        15561    15619      +58     
- Misses       3292     3296       +4     
- Partials     1193     1195       +2     
Impacted Files Coverage Δ
driver/registry_default.go 86.92% <ø> (ø)
identity/identity_verification.go 70.96% <ø> (ø)
selfservice/flow/verification/flow.go 92.00% <ø> (ø)
selfservice/hook/verification.go 73.68% <85.71%> (+1.27%) ⬆️
selfservice/flow/continue_with.go 88.88% <88.88%> (ø)
selfservice/strategy/code/strategy_verification.go 74.25% <93.54%> (-1.24%) ⬇️
driver/registry_default_hooks.go 91.83% <100.00%> (+1.13%) ⬆️
selfservice/flow/registration/flow.go 97.10% <100.00%> (+0.17%) ⬆️
selfservice/flow/registration/hook.go 82.53% <100.00%> (+0.42%) ⬆️
selfservice/flow/settings/flow.go 92.00% <100.00%> (+0.45%) ⬆️
... and 3 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@jonas-jonas
Copy link
Contributor Author

What other actions do we expect to be added?

For the recovery flow, we could use this and add settings_ui.

For the various expired type of errors, we are planning on also using this, so we would add these for all the flows recovery_ui, etc.

Then we will also have a special one for OIDC.

@jonas-jonas jonas-jonas force-pushed the jonas-jonas/fix/verificationIdAfterRegistration branch 2 times, most recently from d45195a to 4c7f9cf Compare March 10, 2023 11:02
// registration.
//
// required: false
// swagger:ignore
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since we aren't returning the registration flow itself, once the registration finishes, this is just used internally, and should not be sent to the client.

Copy link
Member

Choose a reason for hiding this comment

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

Remove the required field, and swagger ignore. json:"-" already omits it from swagger

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@jonas-jonas jonas-jonas force-pushed the jonas-jonas/fix/verificationIdAfterRegistration branch from 4c7f9cf to cf9c1d9 Compare March 10, 2023 15:33
{
"attributes": {
"disabled": false,
"name": "csrf_token",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure if re-ordering CSRF token "inputs" will be an issue?

Copy link
Member

Choose a reason for hiding this comment

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

It should not matter.

@jonas-jonas jonas-jonas force-pushed the jonas-jonas/fix/verificationIdAfterRegistration branch from cf9c1d9 to 22a143a Compare March 13, 2023 07:47
@jonas-jonas jonas-jonas force-pushed the jonas-jonas/fix/verificationIdAfterRegistration branch from e48561a to 9e986f3 Compare March 13, 2023 08:57
@jonas-jonas
Copy link
Contributor Author

As for E2E tests, right now they (should be) are passing, because the changes are not breaking. We are merely adding new fields to payloads.

I would propose, adding this feature to the reference implementations, once this is merged and adjusting the E2E tests, once that's done. That way we don't need to update the SDK from a branch, etc.

@jonas-jonas jonas-jonas self-assigned this Mar 13, 2023
@jonas-jonas jonas-jonas marked this pull request as ready for review March 13, 2023 16:28
zepatrik
zepatrik previously approved these changes Mar 13, 2023
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.

Nice 👍

selfservice/hook/session_issuer_test.go Outdated Show resolved Hide resolved
{
"attributes": {
"disabled": false,
"name": "csrf_token",
Copy link
Member

Choose a reason for hiding this comment

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

It should not matter.

Benehiko
Benehiko previously approved these changes Mar 14, 2023
Copy link
Contributor

@Benehiko Benehiko left a comment

Choose a reason for hiding this comment

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

Nice! This looks really good :)

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.

First sweep

selfservice/flow/continue_with.go Outdated Show resolved Hide resolved
selfservice/flow/continue_with.go Outdated Show resolved Hide resolved
// Flow contains the ID of the verification flow
//
// required: true
Flow struct {
Copy link
Member

Choose a reason for hiding this comment

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

Please use a dedicated struct for this and give it a swagger:model annotation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The names get quite long. Would've liked to avoid those.. But fine with me, done.

selfservice/flow/continue_with.go Outdated Show resolved Hide resolved
// registration.
//
// required: false
// swagger:ignore
Copy link
Member

Choose a reason for hiding this comment

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

Remove the required field, and swagger ignore. json:"-" already omits it from swagger

@jonas-jonas jonas-jonas force-pushed the jonas-jonas/fix/verificationIdAfterRegistration branch from add0917 to 468484a Compare March 20, 2023 11:43
@aeneasr
Copy link
Member

aeneasr commented Mar 20, 2023

Is this good to review?

@jonas-jonas
Copy link
Contributor Author

Is this good to review?

If CI is green, yes from my POV.

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.

This is looking grand! The only thing I'm missing is some proof that continue_with works as intended. Basically, this means an end to end test with registration + verification on mobile and/or SPA?

.schema/openapi/patches/schema.yaml Outdated Show resolved Hide resolved
.schema/openapi/patches/schema.yaml Outdated Show resolved Hide resolved
selfservice/flow/continue_with.go Outdated Show resolved Hide resolved
selfservice/hook/show_verification_ui.go Outdated Show resolved Hide resolved
@jonas-jonas jonas-jonas force-pushed the jonas-jonas/fix/verificationIdAfterRegistration branch from 468484a to d21afcb Compare March 20, 2023 13:15
@jonas-jonas
Copy link
Contributor Author

The only thing I'm missing is some proof that continue_with works as intended. Basically, this means an end to end test with registration + verification on mobile and/or SPA?

Yes, that's true. I wanted to merge this first and write some E2E tests then, to avoid the SDK release-dance needed to update both. But I can do that before we merge this PR.

@aeneasr
Copy link
Member

aeneasr commented Mar 20, 2023

Yes, that's true. I wanted to merge this first and write some E2E tests then, to avoid the SDK release-dance needed to update both. But I can do that before we merge this PR.

Yes please do that first :) For the SDK - do you know how this works?

@jonas-jonas
Copy link
Contributor Author

do you know how this works?

No :)

@aeneasr
Copy link
Member

aeneasr commented Mar 20, 2023

https://github.com/ory/kratos-selfservice-ui-node/blob/7a838e2a2900592817df07067f998c4d6325a7ff/Makefile#L27

Make sure to have the paths set correctly, and you'll also need access to the npm package - if you give me your ID i can add you

with:
repository: ory/kratos-selfservice-ui-react-nextjs
path: react-ui
ref: jonas-jonas/feat/showVerificationAfterRegistration
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TODO

@jonas-jonas jonas-jonas force-pushed the jonas-jonas/fix/verificationIdAfterRegistration branch 2 times, most recently from e9462d3 to 0037f09 Compare March 21, 2023 06:45
@jonas-jonas jonas-jonas force-pushed the jonas-jonas/fix/verificationIdAfterRegistration branch from 0037f09 to e87ddef Compare March 21, 2023 11:34
@jonas-jonas jonas-jonas force-pushed the jonas-jonas/fix/verificationIdAfterRegistration branch from e87ddef to 8169ac2 Compare March 21, 2023 15:29
aeneasr
aeneasr previously approved these changes Mar 22, 2023
selfservice/hook/verification.go Outdated Show resolved Hide resolved
selfservice/hook/verification.go Show resolved Hide resolved
assert.IsType(t, &flow.ContinueWithVerificationUI{}, vf)
fView := vf.(*flow.ContinueWithVerificationUI).Flow

expectedVerificationFlow, err := reg.VerificationFlowPersister().GetVerificationFlow(ctx, fView.ID)
Copy link
Member

Choose a reason for hiding this comment

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

This test assertion changed - previously we synthetically created a new verification URL and compared that with the assertion from the DB. Now we fetch both verification flows from the DB and compare them. Is this still a useful test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment on lines +124 to +134
switch k {
case "settings":
originalFlow = &settings.Flow{RequestURL: "http://foo.com/settings?after_verification_return_to=verification_callback"}
case "register":
originalFlow = &registration.Flow{RequestURL: "http://foo.com/registration?after_verification_return_to=verification_callback"}
default:
t.FailNow()
}
require.NoError(t, hf(h, i, originalFlow))
expectedVerificationFlow, err = verification.NewPostHookFlow(conf, conf.SelfServiceFlowVerificationRequestLifespan(ctx), "", u, s, originalFlow)

assert.Emptyf(t, originalFlow.ContinueWith(), "%+v", originalFlow.ContinueWith())
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if I understand what this is doing - you're creating a new original flow and then checking whether it has continue with. That of course will be true, because it's not added in the switch statement.

OR is hf() somehow setting that value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hf is executing the verification hook, which persists the verification flow, and since all verifiable addresses are now verified, we expect no continue_with items anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test could use some cleanup, for sure. But OOS of this PR IMO.

@jonas-jonas jonas-jonas force-pushed the jonas-jonas/fix/verificationIdAfterRegistration branch from 231ec43 to c6c26e3 Compare March 23, 2023 07:51
@aeneasr aeneasr merged commit eb854be into master Mar 23, 2023
24 checks passed
@aeneasr aeneasr deleted the jonas-jonas/fix/verificationIdAfterRegistration branch March 23, 2023 09:59
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.

Unable to get verification flow id after registration when using code method.
5 participants