Fix/create identity identity id decode - #58
Conversation
- Implemented GetAuthURLWithInvitation method to include invitation_code and is_invitation parameters in the authentication URL. - Updated UseKindeAuth function to utilize the new method for redirecting users with invitation codes. - Added comprehensive tests for invitation code handling in authorization code flow. This enhancement allows for better user onboarding through invitation codes.
When creating an identity with an existing enterprise identity, the Kinde API returns identity_id instead of id in the response. Add a post-generation patch script so CreateIdentityResponseIdentity.Decode() accepts identity_id and maps it to ID for compatibility. - Add fix_create_identity_identity.go to run after ogen (generate.go) - Patch targets only CreateIdentityResponseIdentity.Decode via unique block - Add unit tests for id and identity_id decode paths
WalkthroughAdds invitation-code-aware auth URL generation and wiring: new AuthorizationCodeFlow API and option, Gin handler uses the invitation_code query parameter for redirects, tests for auth URL behavior, and a small code-generation patch tool plus tests to map Changes
Sequence Diagram(s)sequenceDiagram
participant User as "User (browser)"
participant Gin as "Gin Handler\n(`gin_kinde`)"
participant Flow as "AuthorizationCodeFlow\n(GetAuthURLWithInvitation)"
participant OAuth as "Authorization Server"
User->>Gin: Request protected resource (may include ?invitation_code=ABC)
Gin->>Gin: detect unauthenticated, read `invitation_code`
Gin->>Flow: GetAuthURLWithInvitation("ABC")
Flow->>Flow: build auth URL (include PKCE + invitation_code + is_invitation)
Flow-->>Gin: auth URL
Gin-->>User: 302 Redirect -> auth URL
User->>OAuth: Follow redirect (auth request includes invitation params)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ❌ 3❌ Failed checks (1 warning, 2 inconclusive)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@kinde/management_api/create_identity_response_test.go`:
- Around line 53-63: The decoder generation for CreateIdentityResponse is
missing handling for the "identity_id" JSON field, causing response.Decode in
create_identity_response_test.go to not set identity.ID; update and commit the
patched oas_json_gen.go output (or add a CI go generate step) so the generated
decoder in the function/method that decodes CreateIdentityResponse handles both
"id" and "identity_id" into response.Identity.ID (ensure the decoding logic in
the generated decoder for Identity.ID recognizes the "identity_id" key and sets
Identity.ID.IsSet()/Get() accordingly), then run tests to verify
response.Decode, response.Identity.IsSet(), and identity.ID are correctly
populated.
In `@kinde/management_api/fix_create_identity_identity.go`:
- Around line 89-94: The current check for bytes.Count(content, oldBlock) treats
a missing pattern as a non-error (os.Exit(0)), hiding generator drift and
leaving CreateIdentityResponseIdentity.Decode unpatched; change the behavior in
the count == 0 branch to fail hard (e.g., replace os.Exit(0) with a non-zero
exit or use log.Fatalf/log.Panicf) so the process returns an error and surfaces
the issue immediately when oldBlock is not found in content; ensure the message
includes context about CreateIdentityResponseIdentity.Decode and the pattern
lookup so CI/tests will fail loudly.
|
Good Morning @BrandtKruger, Just finished taking a look at this. A couple things I'd like to note The current PR patches only in CI, so the shipped SDK would probably still remain broken then or am I missing somehting? Would it not be better to have the openAPI spec updated and regenerate it? If that is not possible perhaps we should just patch locally, what do you think? I also wanted to check why the invitation code change is included in this set of changes relating to the identity id decode. |
Hi, let me have a look. Thank you. |
Explain your changes
create identity identity id decode
Checklist
🛟 If you need help, consider asking for advice over in the Kinde community.