1. Packages
  2. Keycloak Provider
  3. API Docs
  4. openid
  5. ClientGroupPolicy
Viewing docs for Keycloak v6.10.0
published on Saturday, Feb 21, 2026 by Pulumi
keycloak logo
Viewing docs for Keycloak v6.10.0
published on Saturday, Feb 21, 2026 by Pulumi

    Allows you to manage group policies.

    Group policies allow you to define conditions based on group membership. You can specify whether child groups should be included in the evaluation.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as keycloak from "@pulumi/keycloak";
    
    const realm = new keycloak.Realm("realm", {
        realm: "my-realm",
        enabled: true,
    });
    const test = new keycloak.openid.Client("test", {
        clientId: "client_id",
        realmId: realm.id,
        accessType: "CONFIDENTIAL",
        serviceAccountsEnabled: true,
        authorization: {
            policyEnforcementMode: "ENFORCING",
        },
    });
    const group1 = new keycloak.Group("group1", {
        realmId: realm.id,
        name: "group1",
    });
    const group2 = new keycloak.Group("group2", {
        realmId: realm.id,
        name: "group2",
    });
    const testClientGroupPolicy = new keycloak.openid.ClientGroupPolicy("test", {
        resourceServerId: test.resourceServerId,
        realmId: realm.id,
        name: "group_policy",
        decisionStrategy: "UNANIMOUS",
        logic: "POSITIVE",
        groups: [
            {
                id: group1.id,
                path: group1.path,
                extendChildren: false,
            },
            {
                id: group2.id,
                path: group2.path,
                extendChildren: true,
            },
        ],
    });
    
    import pulumi
    import pulumi_keycloak as keycloak
    
    realm = keycloak.Realm("realm",
        realm="my-realm",
        enabled=True)
    test = keycloak.openid.Client("test",
        client_id="client_id",
        realm_id=realm.id,
        access_type="CONFIDENTIAL",
        service_accounts_enabled=True,
        authorization={
            "policy_enforcement_mode": "ENFORCING",
        })
    group1 = keycloak.Group("group1",
        realm_id=realm.id,
        name="group1")
    group2 = keycloak.Group("group2",
        realm_id=realm.id,
        name="group2")
    test_client_group_policy = keycloak.openid.ClientGroupPolicy("test",
        resource_server_id=test.resource_server_id,
        realm_id=realm.id,
        name="group_policy",
        decision_strategy="UNANIMOUS",
        logic="POSITIVE",
        groups=[
            {
                "id": group1.id,
                "path": group1.path,
                "extend_children": False,
            },
            {
                "id": group2.id,
                "path": group2.path,
                "extend_children": True,
            },
        ])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-keycloak/sdk/v6/go/keycloak"
    	"github.com/pulumi/pulumi-keycloak/sdk/v6/go/keycloak/openid"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		realm, err := keycloak.NewRealm(ctx, "realm", &keycloak.RealmArgs{
    			Realm:   pulumi.String("my-realm"),
    			Enabled: pulumi.Bool(true),
    		})
    		if err != nil {
    			return err
    		}
    		test, err := openid.NewClient(ctx, "test", &openid.ClientArgs{
    			ClientId:               pulumi.String("client_id"),
    			RealmId:                realm.ID(),
    			AccessType:             pulumi.String("CONFIDENTIAL"),
    			ServiceAccountsEnabled: pulumi.Bool(true),
    			Authorization: &openid.ClientAuthorizationArgs{
    				PolicyEnforcementMode: pulumi.String("ENFORCING"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		group1, err := keycloak.NewGroup(ctx, "group1", &keycloak.GroupArgs{
    			RealmId: realm.ID(),
    			Name:    pulumi.String("group1"),
    		})
    		if err != nil {
    			return err
    		}
    		group2, err := keycloak.NewGroup(ctx, "group2", &keycloak.GroupArgs{
    			RealmId: realm.ID(),
    			Name:    pulumi.String("group2"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = openid.NewClientGroupPolicy(ctx, "test", &openid.ClientGroupPolicyArgs{
    			ResourceServerId: test.ResourceServerId,
    			RealmId:          realm.ID(),
    			Name:             pulumi.String("group_policy"),
    			DecisionStrategy: pulumi.String("UNANIMOUS"),
    			Logic:            pulumi.String("POSITIVE"),
    			Groups: openid.ClientGroupPolicyGroupArray{
    				&openid.ClientGroupPolicyGroupArgs{
    					Id:             group1.ID(),
    					Path:           group1.Path,
    					ExtendChildren: pulumi.Bool(false),
    				},
    				&openid.ClientGroupPolicyGroupArgs{
    					Id:             group2.ID(),
    					Path:           group2.Path,
    					ExtendChildren: pulumi.Bool(true),
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Keycloak = Pulumi.Keycloak;
    
    return await Deployment.RunAsync(() => 
    {
        var realm = new Keycloak.Realm("realm", new()
        {
            RealmName = "my-realm",
            Enabled = true,
        });
    
        var test = new Keycloak.OpenId.Client("test", new()
        {
            ClientId = "client_id",
            RealmId = realm.Id,
            AccessType = "CONFIDENTIAL",
            ServiceAccountsEnabled = true,
            Authorization = new Keycloak.OpenId.Inputs.ClientAuthorizationArgs
            {
                PolicyEnforcementMode = "ENFORCING",
            },
        });
    
        var group1 = new Keycloak.Group("group1", new()
        {
            RealmId = realm.Id,
            Name = "group1",
        });
    
        var group2 = new Keycloak.Group("group2", new()
        {
            RealmId = realm.Id,
            Name = "group2",
        });
    
        var testClientGroupPolicy = new Keycloak.OpenId.ClientGroupPolicy("test", new()
        {
            ResourceServerId = test.ResourceServerId,
            RealmId = realm.Id,
            Name = "group_policy",
            DecisionStrategy = "UNANIMOUS",
            Logic = "POSITIVE",
            Groups = new[]
            {
                new Keycloak.OpenId.Inputs.ClientGroupPolicyGroupArgs
                {
                    Id = group1.Id,
                    Path = group1.Path,
                    ExtendChildren = false,
                },
                new Keycloak.OpenId.Inputs.ClientGroupPolicyGroupArgs
                {
                    Id = group2.Id,
                    Path = group2.Path,
                    ExtendChildren = true,
                },
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.keycloak.Realm;
    import com.pulumi.keycloak.RealmArgs;
    import com.pulumi.keycloak.openid.Client;
    import com.pulumi.keycloak.openid.ClientArgs;
    import com.pulumi.keycloak.openid.inputs.ClientAuthorizationArgs;
    import com.pulumi.keycloak.Group;
    import com.pulumi.keycloak.GroupArgs;
    import com.pulumi.keycloak.openid.ClientGroupPolicy;
    import com.pulumi.keycloak.openid.ClientGroupPolicyArgs;
    import com.pulumi.keycloak.openid.inputs.ClientGroupPolicyGroupArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            var realm = new Realm("realm", RealmArgs.builder()
                .realm("my-realm")
                .enabled(true)
                .build());
    
            var test = new Client("test", ClientArgs.builder()
                .clientId("client_id")
                .realmId(realm.id())
                .accessType("CONFIDENTIAL")
                .serviceAccountsEnabled(true)
                .authorization(ClientAuthorizationArgs.builder()
                    .policyEnforcementMode("ENFORCING")
                    .build())
                .build());
    
            var group1 = new Group("group1", GroupArgs.builder()
                .realmId(realm.id())
                .name("group1")
                .build());
    
            var group2 = new Group("group2", GroupArgs.builder()
                .realmId(realm.id())
                .name("group2")
                .build());
    
            var testClientGroupPolicy = new ClientGroupPolicy("testClientGroupPolicy", ClientGroupPolicyArgs.builder()
                .resourceServerId(test.resourceServerId())
                .realmId(realm.id())
                .name("group_policy")
                .decisionStrategy("UNANIMOUS")
                .logic("POSITIVE")
                .groups(            
                    ClientGroupPolicyGroupArgs.builder()
                        .id(group1.id())
                        .path(group1.path())
                        .extendChildren(false)
                        .build(),
                    ClientGroupPolicyGroupArgs.builder()
                        .id(group2.id())
                        .path(group2.path())
                        .extendChildren(true)
                        .build())
                .build());
    
        }
    }
    
    resources:
      realm:
        type: keycloak:Realm
        properties:
          realm: my-realm
          enabled: true
      test:
        type: keycloak:openid:Client
        properties:
          clientId: client_id
          realmId: ${realm.id}
          accessType: CONFIDENTIAL
          serviceAccountsEnabled: true
          authorization:
            policyEnforcementMode: ENFORCING
      group1:
        type: keycloak:Group
        properties:
          realmId: ${realm.id}
          name: group1
      group2:
        type: keycloak:Group
        properties:
          realmId: ${realm.id}
          name: group2
      testClientGroupPolicy:
        type: keycloak:openid:ClientGroupPolicy
        name: test
        properties:
          resourceServerId: ${test.resourceServerId}
          realmId: ${realm.id}
          name: group_policy
          decisionStrategy: UNANIMOUS
          logic: POSITIVE
          groups:
            - id: ${group1.id}
              path: ${group1.path}
              extendChildren: false
            - id: ${group2.id}
              path: ${group2.path}
              extendChildren: true
    

    Argument Reference

    The following arguments are supported:

    • realm_id - (Required) The realm this policy exists in.
    • resource_server_id - (Required) The ID of the resource server.
    • name - (Required) The name of the policy.
    • decision_strategy - (Required) The decision strategy, can be one of UNANIMOUS, AFFIRMATIVE, or CONSENSUS.
    • logic - (Optional) The logic, can be one of POSITIVE or NEGATIVE. Defaults to POSITIVE.
    • groups - (Required) A list of groups group. At least one group must be defined.
    • groups_claim - (Optional) The name of the claim in the token that contains the group information.
    • description - (Optional) A description for the authorization policy.

    Group Arguments

    • id - (Required) The ID of the group.
    • path - (Required) The path of the group.
    • extend_children - (Required) When true, the policy will also apply to all child groups of this group.

    Attributes Reference

    In addition to the arguments listed above, the following computed attributes are exported:

    • id - Policy ID representing the group policy.

    Create ClientGroupPolicy Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new ClientGroupPolicy(name: string, args: ClientGroupPolicyArgs, opts?: CustomResourceOptions);
    @overload
    def ClientGroupPolicy(resource_name: str,
                          args: ClientGroupPolicyArgs,
                          opts: Optional[ResourceOptions] = None)
    
    @overload
    def ClientGroupPolicy(resource_name: str,
                          opts: Optional[ResourceOptions] = None,
                          decision_strategy: Optional[str] = None,
                          groups: Optional[Sequence[ClientGroupPolicyGroupArgs]] = None,
                          realm_id: Optional[str] = None,
                          resource_server_id: Optional[str] = None,
                          description: Optional[str] = None,
                          groups_claim: Optional[str] = None,
                          logic: Optional[str] = None,
                          name: Optional[str] = None)
    func NewClientGroupPolicy(ctx *Context, name string, args ClientGroupPolicyArgs, opts ...ResourceOption) (*ClientGroupPolicy, error)
    public ClientGroupPolicy(string name, ClientGroupPolicyArgs args, CustomResourceOptions? opts = null)
    public ClientGroupPolicy(String name, ClientGroupPolicyArgs args)
    public ClientGroupPolicy(String name, ClientGroupPolicyArgs args, CustomResourceOptions options)
    
    type: keycloak:openid:ClientGroupPolicy
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args ClientGroupPolicyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args ClientGroupPolicyArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args ClientGroupPolicyArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args ClientGroupPolicyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args ClientGroupPolicyArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var clientGroupPolicyResource = new Keycloak.OpenId.ClientGroupPolicy("clientGroupPolicyResource", new()
    {
        DecisionStrategy = "string",
        Groups = new[]
        {
            new Keycloak.OpenId.Inputs.ClientGroupPolicyGroupArgs
            {
                ExtendChildren = false,
                Id = "string",
                Path = "string",
            },
        },
        RealmId = "string",
        ResourceServerId = "string",
        Description = "string",
        GroupsClaim = "string",
        Logic = "string",
        Name = "string",
    });
    
    example, err := openid.NewClientGroupPolicy(ctx, "clientGroupPolicyResource", &openid.ClientGroupPolicyArgs{
    	DecisionStrategy: pulumi.String("string"),
    	Groups: openid.ClientGroupPolicyGroupArray{
    		&openid.ClientGroupPolicyGroupArgs{
    			ExtendChildren: pulumi.Bool(false),
    			Id:             pulumi.String("string"),
    			Path:           pulumi.String("string"),
    		},
    	},
    	RealmId:          pulumi.String("string"),
    	ResourceServerId: pulumi.String("string"),
    	Description:      pulumi.String("string"),
    	GroupsClaim:      pulumi.String("string"),
    	Logic:            pulumi.String("string"),
    	Name:             pulumi.String("string"),
    })
    
    var clientGroupPolicyResource = new ClientGroupPolicy("clientGroupPolicyResource", ClientGroupPolicyArgs.builder()
        .decisionStrategy("string")
        .groups(ClientGroupPolicyGroupArgs.builder()
            .extendChildren(false)
            .id("string")
            .path("string")
            .build())
        .realmId("string")
        .resourceServerId("string")
        .description("string")
        .groupsClaim("string")
        .logic("string")
        .name("string")
        .build());
    
    client_group_policy_resource = keycloak.openid.ClientGroupPolicy("clientGroupPolicyResource",
        decision_strategy="string",
        groups=[{
            "extend_children": False,
            "id": "string",
            "path": "string",
        }],
        realm_id="string",
        resource_server_id="string",
        description="string",
        groups_claim="string",
        logic="string",
        name="string")
    
    const clientGroupPolicyResource = new keycloak.openid.ClientGroupPolicy("clientGroupPolicyResource", {
        decisionStrategy: "string",
        groups: [{
            extendChildren: false,
            id: "string",
            path: "string",
        }],
        realmId: "string",
        resourceServerId: "string",
        description: "string",
        groupsClaim: "string",
        logic: "string",
        name: "string",
    });
    
    type: keycloak:openid:ClientGroupPolicy
    properties:
        decisionStrategy: string
        description: string
        groups:
            - extendChildren: false
              id: string
              path: string
        groupsClaim: string
        logic: string
        name: string
        realmId: string
        resourceServerId: string
    

    ClientGroupPolicy Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

    The ClientGroupPolicy resource accepts the following input properties:

    Outputs

    All input properties are implicitly available as output properties. Additionally, the ClientGroupPolicy resource produces the following output properties:

    Id string
    The provider-assigned unique ID for this managed resource.
    Id string
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.
    id string
    The provider-assigned unique ID for this managed resource.
    id str
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing ClientGroupPolicy Resource

    Get an existing ClientGroupPolicy resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: ClientGroupPolicyState, opts?: CustomResourceOptions): ClientGroupPolicy
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            decision_strategy: Optional[str] = None,
            description: Optional[str] = None,
            groups: Optional[Sequence[ClientGroupPolicyGroupArgs]] = None,
            groups_claim: Optional[str] = None,
            logic: Optional[str] = None,
            name: Optional[str] = None,
            realm_id: Optional[str] = None,
            resource_server_id: Optional[str] = None) -> ClientGroupPolicy
    func GetClientGroupPolicy(ctx *Context, name string, id IDInput, state *ClientGroupPolicyState, opts ...ResourceOption) (*ClientGroupPolicy, error)
    public static ClientGroupPolicy Get(string name, Input<string> id, ClientGroupPolicyState? state, CustomResourceOptions? opts = null)
    public static ClientGroupPolicy get(String name, Output<String> id, ClientGroupPolicyState state, CustomResourceOptions options)
    resources:  _:    type: keycloak:openid:ClientGroupPolicy    get:      id: ${id}
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:

    Supporting Types

    ClientGroupPolicyGroup, ClientGroupPolicyGroupArgs

    ExtendChildren bool
    Id string
    Path string
    ExtendChildren bool
    Id string
    Path string
    extendChildren Boolean
    id String
    path String
    extendChildren boolean
    id string
    path string
    extendChildren Boolean
    id String
    path String

    Import

    Group policies can be imported using the format: {{realmId}}/{{resourceServerId}}/{{policyId}}.

    Example:

    $ terraform import keycloak_openid_client_group_policy.test my-realm/3bd4a686-1062-4b59-97b8-e4e3f10b99da/63b3cde8-987d-4cd9-9306-1955579281d9
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    Keycloak pulumi/pulumi-keycloak
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the keycloak Terraform Provider.
    keycloak logo
    Viewing docs for Keycloak v6.10.0
    published on Saturday, Feb 21, 2026 by Pulumi
      Try Pulumi Cloud free. Your team will thank you.