1. Packages
  2. Keycloak Provider
  3. API Docs
  4. openid
  5. ClientAuthorizationClientScopePolicy
Keycloak v6.4.0 published on Wednesday, Apr 16, 2025 by Pulumi

keycloak.openid.ClientAuthorizationClientScopePolicy

Explore with Pulumi AI

keycloak logo
Keycloak v6.4.0 published on Wednesday, Apr 16, 2025 by Pulumi

    Allows you to manage openid Client Authorization Client Scope type Policies.

    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 test1 = new keycloak.openid.ClientScope("test1", {
        realmId: realm.id,
        name: "test1",
        description: "test1",
    });
    const test2 = new keycloak.openid.ClientScope("test2", {
        realmId: realm.id,
        name: "test2",
        description: "test2",
    });
    const testClientAuthorizationClientScopePolicy = new keycloak.openid.ClientAuthorizationClientScopePolicy("test", {
        resourceServerId: test.resourceServerId,
        realmId: realm.id,
        name: "test_policy_single",
        description: "test",
        decisionStrategy: "AFFIRMATIVE",
        logic: "POSITIVE",
        scopes: [{
            id: test1.id,
            required: false,
        }],
    });
    const testMultiple = new keycloak.openid.ClientAuthorizationClientScopePolicy("test_multiple", {
        resourceServerId: test.resourceServerId,
        realmId: realm.id,
        name: "test_policy_multiple",
        description: "test",
        decisionStrategy: "AFFIRMATIVE",
        logic: "POSITIVE",
        scopes: [
            {
                id: test1.id,
                required: false,
            },
            {
                id: test2.id,
                required: 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",
        })
    test1 = keycloak.openid.ClientScope("test1",
        realm_id=realm.id,
        name="test1",
        description="test1")
    test2 = keycloak.openid.ClientScope("test2",
        realm_id=realm.id,
        name="test2",
        description="test2")
    test_client_authorization_client_scope_policy = keycloak.openid.ClientAuthorizationClientScopePolicy("test",
        resource_server_id=test.resource_server_id,
        realm_id=realm.id,
        name="test_policy_single",
        description="test",
        decision_strategy="AFFIRMATIVE",
        logic="POSITIVE",
        scopes=[{
            "id": test1.id,
            "required": False,
        }])
    test_multiple = keycloak.openid.ClientAuthorizationClientScopePolicy("test_multiple",
        resource_server_id=test.resource_server_id,
        realm_id=realm.id,
        name="test_policy_multiple",
        description="test",
        decision_strategy="AFFIRMATIVE",
        logic="POSITIVE",
        scopes=[
            {
                "id": test1.id,
                "required": False,
            },
            {
                "id": test2.id,
                "required": 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
    		}
    		test1, err := openid.NewClientScope(ctx, "test1", &openid.ClientScopeArgs{
    			RealmId:     realm.ID(),
    			Name:        pulumi.String("test1"),
    			Description: pulumi.String("test1"),
    		})
    		if err != nil {
    			return err
    		}
    		test2, err := openid.NewClientScope(ctx, "test2", &openid.ClientScopeArgs{
    			RealmId:     realm.ID(),
    			Name:        pulumi.String("test2"),
    			Description: pulumi.String("test2"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = openid.NewClientAuthorizationClientScopePolicy(ctx, "test", &openid.ClientAuthorizationClientScopePolicyArgs{
    			ResourceServerId: test.ResourceServerId,
    			RealmId:          realm.ID(),
    			Name:             pulumi.String("test_policy_single"),
    			Description:      pulumi.String("test"),
    			DecisionStrategy: pulumi.String("AFFIRMATIVE"),
    			Logic:            pulumi.String("POSITIVE"),
    			Scopes: openid.ClientAuthorizationClientScopePolicyScopeArray{
    				&openid.ClientAuthorizationClientScopePolicyScopeArgs{
    					Id:       test1.ID(),
    					Required: pulumi.Bool(false),
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		_, err = openid.NewClientAuthorizationClientScopePolicy(ctx, "test_multiple", &openid.ClientAuthorizationClientScopePolicyArgs{
    			ResourceServerId: test.ResourceServerId,
    			RealmId:          realm.ID(),
    			Name:             pulumi.String("test_policy_multiple"),
    			Description:      pulumi.String("test"),
    			DecisionStrategy: pulumi.String("AFFIRMATIVE"),
    			Logic:            pulumi.String("POSITIVE"),
    			Scopes: openid.ClientAuthorizationClientScopePolicyScopeArray{
    				&openid.ClientAuthorizationClientScopePolicyScopeArgs{
    					Id:       test1.ID(),
    					Required: pulumi.Bool(false),
    				},
    				&openid.ClientAuthorizationClientScopePolicyScopeArgs{
    					Id:       test2.ID(),
    					Required: 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 test1 = new Keycloak.OpenId.ClientScope("test1", new()
        {
            RealmId = realm.Id,
            Name = "test1",
            Description = "test1",
        });
    
        var test2 = new Keycloak.OpenId.ClientScope("test2", new()
        {
            RealmId = realm.Id,
            Name = "test2",
            Description = "test2",
        });
    
        var testClientAuthorizationClientScopePolicy = new Keycloak.OpenId.ClientAuthorizationClientScopePolicy("test", new()
        {
            ResourceServerId = test.ResourceServerId,
            RealmId = realm.Id,
            Name = "test_policy_single",
            Description = "test",
            DecisionStrategy = "AFFIRMATIVE",
            Logic = "POSITIVE",
            Scopes = new[]
            {
                new Keycloak.OpenId.Inputs.ClientAuthorizationClientScopePolicyScopeArgs
                {
                    Id = test1.Id,
                    Required = false,
                },
            },
        });
    
        var testMultiple = new Keycloak.OpenId.ClientAuthorizationClientScopePolicy("test_multiple", new()
        {
            ResourceServerId = test.ResourceServerId,
            RealmId = realm.Id,
            Name = "test_policy_multiple",
            Description = "test",
            DecisionStrategy = "AFFIRMATIVE",
            Logic = "POSITIVE",
            Scopes = new[]
            {
                new Keycloak.OpenId.Inputs.ClientAuthorizationClientScopePolicyScopeArgs
                {
                    Id = test1.Id,
                    Required = false,
                },
                new Keycloak.OpenId.Inputs.ClientAuthorizationClientScopePolicyScopeArgs
                {
                    Id = test2.Id,
                    Required = 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.openid.ClientScope;
    import com.pulumi.keycloak.openid.ClientScopeArgs;
    import com.pulumi.keycloak.openid.ClientAuthorizationClientScopePolicy;
    import com.pulumi.keycloak.openid.ClientAuthorizationClientScopePolicyArgs;
    import com.pulumi.keycloak.openid.inputs.ClientAuthorizationClientScopePolicyScopeArgs;
    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 test1 = new ClientScope("test1", ClientScopeArgs.builder()
                .realmId(realm.id())
                .name("test1")
                .description("test1")
                .build());
    
            var test2 = new ClientScope("test2", ClientScopeArgs.builder()
                .realmId(realm.id())
                .name("test2")
                .description("test2")
                .build());
    
            var testClientAuthorizationClientScopePolicy = new ClientAuthorizationClientScopePolicy("testClientAuthorizationClientScopePolicy", ClientAuthorizationClientScopePolicyArgs.builder()
                .resourceServerId(test.resourceServerId())
                .realmId(realm.id())
                .name("test_policy_single")
                .description("test")
                .decisionStrategy("AFFIRMATIVE")
                .logic("POSITIVE")
                .scopes(ClientAuthorizationClientScopePolicyScopeArgs.builder()
                    .id(test1.id())
                    .required(false)
                    .build())
                .build());
    
            var testMultiple = new ClientAuthorizationClientScopePolicy("testMultiple", ClientAuthorizationClientScopePolicyArgs.builder()
                .resourceServerId(test.resourceServerId())
                .realmId(realm.id())
                .name("test_policy_multiple")
                .description("test")
                .decisionStrategy("AFFIRMATIVE")
                .logic("POSITIVE")
                .scopes(            
                    ClientAuthorizationClientScopePolicyScopeArgs.builder()
                        .id(test1.id())
                        .required(false)
                        .build(),
                    ClientAuthorizationClientScopePolicyScopeArgs.builder()
                        .id(test2.id())
                        .required(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
      test1:
        type: keycloak:openid:ClientScope
        properties:
          realmId: ${realm.id}
          name: test1
          description: test1
      test2:
        type: keycloak:openid:ClientScope
        properties:
          realmId: ${realm.id}
          name: test2
          description: test2
      testClientAuthorizationClientScopePolicy:
        type: keycloak:openid:ClientAuthorizationClientScopePolicy
        name: test
        properties:
          resourceServerId: ${test.resourceServerId}
          realmId: ${realm.id}
          name: test_policy_single
          description: test
          decisionStrategy: AFFIRMATIVE
          logic: POSITIVE
          scopes:
            - id: ${test1.id}
              required: false
      testMultiple:
        type: keycloak:openid:ClientAuthorizationClientScopePolicy
        name: test_multiple
        properties:
          resourceServerId: ${test.resourceServerId}
          realmId: ${realm.id}
          name: test_policy_multiple
          description: test
          decisionStrategy: AFFIRMATIVE
          logic: POSITIVE
          scopes:
            - id: ${test1.id}
              required: false
            - id: ${test2.id}
              required: true
    

    Argument Reference

    The following arguments are supported:

    • realm_id - (Required) The realm this group exists in.
    • resource_server_id - (Required) The ID of the resource server.
    • name - (Required) The name of the policy.
    • description - (Optional) A description for the authorization policy.
    • decision_strategy - (Optional) The decision strategy, can be one of UNANIMOUS, AFFIRMATIVE, or CONSENSUS. Defaults to UNANIMOUS.
    • logic - (Optional) The logic, can be one of POSITIVE or NEGATIVE. Defaults to POSITIVE.
    • scope - An client scope to add client scope. At least one should be defined.

    Scope Arguments

    • id - (Required) Id of client scope.
    • required - (Optional) When true, then this client scope will be set as required. Defaults to false.

    Attributes Reference

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

    • id - Policy ID representing the policy.

    Create ClientAuthorizationClientScopePolicy Resource

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

    Constructor syntax

    new ClientAuthorizationClientScopePolicy(name: string, args: ClientAuthorizationClientScopePolicyArgs, opts?: CustomResourceOptions);
    @overload
    def ClientAuthorizationClientScopePolicy(resource_name: str,
                                             args: ClientAuthorizationClientScopePolicyArgs,
                                             opts: Optional[ResourceOptions] = None)
    
    @overload
    def ClientAuthorizationClientScopePolicy(resource_name: str,
                                             opts: Optional[ResourceOptions] = None,
                                             realm_id: Optional[str] = None,
                                             resource_server_id: Optional[str] = None,
                                             scopes: Optional[Sequence[ClientAuthorizationClientScopePolicyScopeArgs]] = None,
                                             decision_strategy: Optional[str] = None,
                                             description: Optional[str] = None,
                                             logic: Optional[str] = None,
                                             name: Optional[str] = None)
    func NewClientAuthorizationClientScopePolicy(ctx *Context, name string, args ClientAuthorizationClientScopePolicyArgs, opts ...ResourceOption) (*ClientAuthorizationClientScopePolicy, error)
    public ClientAuthorizationClientScopePolicy(string name, ClientAuthorizationClientScopePolicyArgs args, CustomResourceOptions? opts = null)
    public ClientAuthorizationClientScopePolicy(String name, ClientAuthorizationClientScopePolicyArgs args)
    public ClientAuthorizationClientScopePolicy(String name, ClientAuthorizationClientScopePolicyArgs args, CustomResourceOptions options)
    
    type: keycloak:openid:ClientAuthorizationClientScopePolicy
    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 ClientAuthorizationClientScopePolicyArgs
    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 ClientAuthorizationClientScopePolicyArgs
    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 ClientAuthorizationClientScopePolicyArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args ClientAuthorizationClientScopePolicyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args ClientAuthorizationClientScopePolicyArgs
    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 clientAuthorizationClientScopePolicyResource = new Keycloak.OpenId.ClientAuthorizationClientScopePolicy("clientAuthorizationClientScopePolicyResource", new()
    {
        RealmId = "string",
        ResourceServerId = "string",
        Scopes = new[]
        {
            new Keycloak.OpenId.Inputs.ClientAuthorizationClientScopePolicyScopeArgs
            {
                Id = "string",
                Required = false,
            },
        },
        DecisionStrategy = "string",
        Description = "string",
        Logic = "string",
        Name = "string",
    });
    
    example, err := openid.NewClientAuthorizationClientScopePolicy(ctx, "clientAuthorizationClientScopePolicyResource", &openid.ClientAuthorizationClientScopePolicyArgs{
    	RealmId:          pulumi.String("string"),
    	ResourceServerId: pulumi.String("string"),
    	Scopes: openid.ClientAuthorizationClientScopePolicyScopeArray{
    		&openid.ClientAuthorizationClientScopePolicyScopeArgs{
    			Id:       pulumi.String("string"),
    			Required: pulumi.Bool(false),
    		},
    	},
    	DecisionStrategy: pulumi.String("string"),
    	Description:      pulumi.String("string"),
    	Logic:            pulumi.String("string"),
    	Name:             pulumi.String("string"),
    })
    
    var clientAuthorizationClientScopePolicyResource = new ClientAuthorizationClientScopePolicy("clientAuthorizationClientScopePolicyResource", ClientAuthorizationClientScopePolicyArgs.builder()
        .realmId("string")
        .resourceServerId("string")
        .scopes(ClientAuthorizationClientScopePolicyScopeArgs.builder()
            .id("string")
            .required(false)
            .build())
        .decisionStrategy("string")
        .description("string")
        .logic("string")
        .name("string")
        .build());
    
    client_authorization_client_scope_policy_resource = keycloak.openid.ClientAuthorizationClientScopePolicy("clientAuthorizationClientScopePolicyResource",
        realm_id="string",
        resource_server_id="string",
        scopes=[{
            "id": "string",
            "required": False,
        }],
        decision_strategy="string",
        description="string",
        logic="string",
        name="string")
    
    const clientAuthorizationClientScopePolicyResource = new keycloak.openid.ClientAuthorizationClientScopePolicy("clientAuthorizationClientScopePolicyResource", {
        realmId: "string",
        resourceServerId: "string",
        scopes: [{
            id: "string",
            required: false,
        }],
        decisionStrategy: "string",
        description: "string",
        logic: "string",
        name: "string",
    });
    
    type: keycloak:openid:ClientAuthorizationClientScopePolicy
    properties:
        decisionStrategy: string
        description: string
        logic: string
        name: string
        realmId: string
        resourceServerId: string
        scopes:
            - id: string
              required: false
    

    ClientAuthorizationClientScopePolicy 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 ClientAuthorizationClientScopePolicy resource accepts the following input properties:

    Outputs

    All input properties are implicitly available as output properties. Additionally, the ClientAuthorizationClientScopePolicy 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 ClientAuthorizationClientScopePolicy Resource

    Get an existing ClientAuthorizationClientScopePolicy 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?: ClientAuthorizationClientScopePolicyState, opts?: CustomResourceOptions): ClientAuthorizationClientScopePolicy
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            decision_strategy: Optional[str] = None,
            description: Optional[str] = None,
            logic: Optional[str] = None,
            name: Optional[str] = None,
            realm_id: Optional[str] = None,
            resource_server_id: Optional[str] = None,
            scopes: Optional[Sequence[ClientAuthorizationClientScopePolicyScopeArgs]] = None) -> ClientAuthorizationClientScopePolicy
    func GetClientAuthorizationClientScopePolicy(ctx *Context, name string, id IDInput, state *ClientAuthorizationClientScopePolicyState, opts ...ResourceOption) (*ClientAuthorizationClientScopePolicy, error)
    public static ClientAuthorizationClientScopePolicy Get(string name, Input<string> id, ClientAuthorizationClientScopePolicyState? state, CustomResourceOptions? opts = null)
    public static ClientAuthorizationClientScopePolicy get(String name, Output<String> id, ClientAuthorizationClientScopePolicyState state, CustomResourceOptions options)
    resources:  _:    type: keycloak:openid:ClientAuthorizationClientScopePolicy    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

    ClientAuthorizationClientScopePolicyScope, ClientAuthorizationClientScopePolicyScopeArgs

    Id string
    Required bool
    Id string
    Required bool
    id String
    required Boolean
    id string
    required boolean
    id str
    required bool
    id String
    required Boolean

    Import

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

    Example:

    bash

    $ pulumi import keycloak:openid/clientAuthorizationClientScopePolicy:ClientAuthorizationClientScopePolicy 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
    Keycloak v6.4.0 published on Wednesday, Apr 16, 2025 by Pulumi