Skip to content

Add custom attributes support to organization invitations#48842

Open
kota65535 wants to merge 1 commit intokeycloak:mainfrom
kota65535:vk/e990-invitation-attri
Open

Add custom attributes support to organization invitations#48842
kota65535 wants to merge 1 commit intokeycloak:mainfrom
kota65535:vk/e990-invitation-attri

Conversation

@kota65535
Copy link
Copy Markdown
Contributor

@kota65535 kota65535 commented May 8, 2026

Closes: #48837

Summary

  • Add key-value custom attributes to organization invitations
  • Add application/json request body support to invite-user and invite-existing-user endpoints
  • Preserve attributes on invitation resend
  • Add Admin UI for managing invitation attributes with a 2-step modal flow

Changes

Backend

  • New ORG_INVITATION_ATTRIBUTE table (jpa-changelog-26.7.0.xml) with FK cascade delete
  • New OrganizationInvitationAttributeEntity JPA entity
  • Extend OrganizationInvitationModel SPI with getAttributes() / setAttribute() / removeAttribute()
  • Extend InvitationManager.createInvitation() with optional attributes parameter (backward-compatible default method)
  • Add JSON @Consumes variants for invite-user and invite-existing-user endpoints alongside existing application/x-www-form-urlencoded endpoints
  • New request types: OrganizationInvitationUserRequest, OrganizationInvitationExistingUserRequest
  • Add attributes field to OrganizationInvitationRepresentation

Admin UI

  • InviteMemberModal: switch from FormData to JSON body, add key-value attributes input (single-step flow for email invitations)
  • InvitationAttributesModal: reusable attributes modal shared across all invite flows
  • Invitations.tsx: 2-step flow using MemberModal (user selection) → InvitationAttributesModal (attributes) for existing user invitations
  • Organizations.tsx (user detail page): 2-step flow using OrganizationModal (org selection) → InvitationAttributesModal (attributes)
  • Invitations: show attributes count with tooltip displaying key-value details on hover

Organization details → Invite new user

Using InviteMemberModal:

image

Organization details → Invite existing user

Using OrganizationModal and InvitationAttributesModal (2-step flow):

image


スクリーンショット 2026-05-09 3 27 28

User details → Send invitation

Using MemberModal and InvitationAttributesModal (2-step flow):

image


スクリーンショット 2026-05-09 3 27 28

Attributes in an invitation list

Showing the number of the attributes:

image

Showing the attribute in a tooltip on hover:
image

Admin Client (JS)

  • Add InviteUserRequest / InviteExistingUserRequest type definitions
  • Add inviteUserJson / inviteExistingUserJson methods to organizations resource

Tests

  • Invitation creation and retrieval with attributes
  • Invitation resend preserves attributes
  • Backward compatibility without attributes
  • Existing user invitation with attributes
  • Tests written using the new test framework (tests/base/)

API

POST /admin/realms/{realm}/organizations/{id}/members/invite-user
Content-Type: application/json

{
  "email": "user@example.com",
  "firstName": "John",
  "lastName": "Doe",
  "attributes": {
    "department": ["engineering"],
    "role": ["developer", "reviewer"]
  }
}
POST /admin/realms/{realm}/organizations/{id}/members/invite-existing-user
Content-Type: application/json

{
  "id": "<user-id>",
  "attributes": {
    "department": ["engineering"]
  }
}

Migration

  • New ORG_INVITATION_ATTRIBUTE table added in jpa-changelog-26.7.0.xml
  • No impact on existing data

Backward Compatibility

  • Existing application/x-www-form-urlencoded endpoints remain unchanged
  • InvitationManager SPI maintains existing method signatures via default methods
  • Invitations without attributes continue to work as before

@kota65535 kota65535 force-pushed the vk/e990-invitation-attri branch 2 times, most recently from 9691030 to c00970f Compare May 8, 2026 15:52
@kota65535 kota65535 changed the title Add custom attributes support to organization invitations feat: add custom attributes support to organization invitations May 8, 2026
@kota65535 kota65535 force-pushed the vk/e990-invitation-attri branch 3 times, most recently from 0114152 to 5c0f2b1 Compare May 8, 2026 17:59
Signed-off-by: Tomohiko Ozawa <kota65535@gmail.com>
@kota65535 kota65535 force-pushed the vk/e990-invitation-attri branch from 5c0f2b1 to c51e773 Compare May 8, 2026 18:24
@kota65535 kota65535 marked this pull request as ready for review May 8, 2026 19:46
@kota65535 kota65535 requested review from a team as code owners May 8, 2026 19:46
@kota65535 kota65535 changed the title feat: add custom attributes support to organization invitations Add custom attributes support to organization invitations May 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add attributes support for Organization Invitations

1 participant