8000 Analyse how to make Client Policies independent from Client API Representations · Issue #47576 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Analyse how to make Client Policies independent from Client API Representations #47576

Open

Description

@mabartos

Description

At this moment, some contexts used for client policies evaluation includes field proposedRepresentation that just passes the Representation/DTO object to the client policy executor and then tries to determine whether the policy applies or not.

You can check the AdminClientRegisterContext or AdminClientUpdateContext contexts.

The issue here is that it's not usable for the Client V2 as we don't have any old ClientRepresentation objects available, and we have only the representation/DTO objects for the Client V2.

For that case, we just temporarily create the old representation from the ClientModel, and pass it there to comply with the current client policies implementations and executors.

However, these contexts should not contain the DTO as it may change, and it should rather use some abstract object, like ClientModel?

Activity

  1. added this to the 26.7.0 milestone on Mar 30, 2026
  2. added theissue type on Mar 30, 2026
  3. bkoragan commented on Apr 20, 2026

    @bkoragan
    Contributor

    @mabartos I dig into this. Here's what I see:

    Current State
    ClientCRUDContext.getProposedClientRepresentation() returns a v1 ClientRepresentation and is consumed by 15 executors (e.g., SecureRedirectUrisEnforcerExecutor, PKCEEnforcerExecutor, SecureClientAuthenticatorExecutor) and 2 conditions (ClientProtocolCondition, ClientAccessTypeCondition).

    The v2 DefaultClientService.createOrUpdate() works around this by delegating to v1's ClientsResource.createClientModel() with a minimal ClientRepresentation (only clientId, protocol, auth). Policies evaluate against incomplete data — the full v2 config is applied after policy evaluation.

    Key Observation
    Every property these executors/conditions read (redirect URIs, protocol, authenticator type, grant types, attributes, etc.) is also available on ClientModel. They don't need the incoming DTO — they need the proposed state of the client.

    I could think of below options -
    Option A: Replace with ClientModel — Change getProposedClientRepresentation() to return ClientModel. V2 would apply its representation to a transient model first, then pass it to policy evaluation. Clean and DTO-agnostic, but requires updating all 17 consumers and handling transient model construction.

    Option B: Build a full v1 ClientRepresentation from v2 — Map the complete v2 representation before triggering policies. Zero executor changes, but perpetuates the v1 dependency.

    Option A aligns with the direction you suggested and seems to the right long-term approach. Option B could serve as a short-term unblock if needed.

    Happy to hear your thoughts on the preferred direction. Once aligned, I can help create follow-up implementation issues or a proof-of-concept PR. Thanks!

  4. added
    area/admin/api-v2Admin REST API v2 — next-generation admin endpoints and kcadm.sh --v2
    on Jun 8, 2026
  5. modified the milestones: 26.7.0, 26.8.0 on Jun 8, 2026
  6. vmuzikar commented on Nov 5, 2026

    @vmuzikar
    Contributor

    As this is more affecting Client Policies rather than Client v2, we'll not be doing this for now. Client Policies should use something else than Representations which are considered a public (now versioned) API and not an internal DTO. But this refactoring will be a bigger task...

  7. changed the title [-]Analyse how to provide V2 representation for client policies[/-] [+]Analyse how to make Client Policies independent from Client API Representations[/+] on Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/admin/apiAdmin REST API (v1) — managing realms, users, clients, roles, groupsarea/admin/api-v2Admin REST API v2 — next-generation admin endpoints and kcadm.sh --v2kind/spiketeam/cloud-native

    Type

    Fields

    No fields configured for spike.

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0