1. Packages
  2. Keycloak Provider
  3. API Docs
  4. saml
  5. ClientDefaultScope
Keycloak v6.8.0 published on Saturday, Nov 15, 2025 by Pulumi
keycloak logo
Keycloak v6.8.0 published on Saturday, Nov 15, 2025 by Pulumi

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as keycloak from "@pulumi/keycloak";
    import * as std from "@pulumi/std";
    
    const realm = new keycloak.Realm("realm", {
        realm: "my-realm",
        enabled: true,
    });
    const samlClient = new keycloak.saml.Client("saml_client", {
        realmId: realm.id,
        clientId: "saml-client",
        name: "saml-client",
        signDocuments: false,
        signAssertions: true,
        includeAuthnStatement: true,
        signingCertificate: std.index.file({
            input: "saml-cert.pem",
        }).result,
        signingPrivateKey: std.index.file({
            input: "saml-key.pem",
        }).result,
    });
    const clientScope = new keycloak.saml.ClientScope("client_scope", {
        realmId: realm.id,
        name: "client-scope",
    });
    const clientDefaultScopes = new keycloak.saml.ClientDefaultScope("client_default_scopes", {
        realmId: realm.id,
        clientId: client.id,
        defaultScopes: [
            "role_list",
            clientScope.name,
        ],
    });
    
    import pulumi
    import pulumi_keycloak as keycloak
    import pulumi_std as std
    
    realm = keycloak.Realm("realm",
        realm="my-realm",
        enabled=True)
    saml_client = keycloak.saml.Client("saml_client",
        realm_id=realm.id,
        client_id="saml-client",
        name="saml-client",
        sign_documents=False,
        sign_assertions=True,
        include_authn_statement=True,
        signing_certificate=std.index.file(input="saml-cert.pem")["result"],
        signing_private_key=std.index.file(input="saml-key.pem")["result"])
    client_scope = keycloak.saml.ClientScope("client_scope",
        realm_id=realm.id,
        name="client-scope")
    client_default_scopes = keycloak.saml.ClientDefaultScope("client_default_scopes",
        realm_id=realm.id,
        client_id=client["id"],
        default_scopes=[
            "role_list",
            client_scope.name,
        ])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-keycloak/sdk/v6/go/keycloak"
    	"github.com/pulumi/pulumi-keycloak/sdk/v6/go/keycloak/saml"
    	"github.com/pulumi/pulumi-std/sdk/go/std"
    	"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
    		}
    		invokeFile, err := std.File(ctx, map[string]interface{}{
    			"input": "saml-cert.pem",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		invokeFile1, err := std.File(ctx, map[string]interface{}{
    			"input": "saml-key.pem",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = saml.NewClient(ctx, "saml_client", &saml.ClientArgs{
    			RealmId:               realm.ID(),
    			ClientId:              pulumi.String("saml-client"),
    			Name:                  pulumi.String("saml-client"),
    			SignDocuments:         pulumi.Bool(false),
    			SignAssertions:        pulumi.Bool(true),
    			IncludeAuthnStatement: pulumi.Bool(true),
    			SigningCertificate:    invokeFile.Result,
    			SigningPrivateKey:     invokeFile1.Result,
    		})
    		if err != nil {
    			return err
    		}
    		clientScope, err := saml.NewClientScope(ctx, "client_scope", &saml.ClientScopeArgs{
    			RealmId: realm.ID(),
    			Name:    pulumi.String("client-scope"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = saml.NewClientDefaultScope(ctx, "client_default_scopes", &saml.ClientDefaultScopeArgs{
    			RealmId:  realm.ID(),
    			ClientId: pulumi.Any(client.Id),
    			DefaultScopes: pulumi.StringArray{
    				pulumi.String("role_list"),
    				clientScope.Name,
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Keycloak = Pulumi.Keycloak;
    using Std = Pulumi.Std;
    
    return await Deployment.RunAsync(() => 
    {
        var realm = new Keycloak.Realm("realm", new()
        {
            RealmName = "my-realm",
            Enabled = true,
        });
    
        var samlClient = new Keycloak.Saml.Client("saml_client", new()
        {
            RealmId = realm.Id,
            ClientId = "saml-client",
            Name = "saml-client",
            SignDocuments = false,
            SignAssertions = true,
            IncludeAuthnStatement = true,
            SigningCertificate = Std.Index.File.Invoke(new()
            {
                Input = "saml-cert.pem",
            }).Result,
            SigningPrivateKey = Std.Index.File.Invoke(new()
            {
                Input = "saml-key.pem",
            }).Result,
        });
    
        var clientScope = new Keycloak.Saml.ClientScope("client_scope", new()
        {
            RealmId = realm.Id,
            Name = "client-scope",
        });
    
        var clientDefaultScopes = new Keycloak.Saml.ClientDefaultScope("client_default_scopes", new()
        {
            RealmId = realm.Id,
            ClientId = client.Id,
            DefaultScopes = new[]
            {
                "role_list",
                clientScope.Name,
            },
        });
    
    });
    
    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.saml.Client;
    import com.pulumi.keycloak.saml.ClientArgs;
    import com.pulumi.std.StdFunctions;
    import com.pulumi.keycloak.saml.ClientScope;
    import com.pulumi.keycloak.saml.ClientScopeArgs;
    import com.pulumi.keycloak.saml.ClientDefaultScope;
    import com.pulumi.keycloak.saml.ClientDefaultScopeArgs;
    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 samlClient = new Client("samlClient", ClientArgs.builder()
                .realmId(realm.id())
                .clientId("saml-client")
                .name("saml-client")
                .signDocuments(false)
                .signAssertions(true)
                .includeAuthnStatement(true)
                .signingCertificate(StdFunctions.file(Map.of("input", "saml-cert.pem")).result())
                .signingPrivateKey(StdFunctions.file(Map.of("input", "saml-key.pem")).result())
                .build());
    
            var clientScope = new ClientScope("clientScope", ClientScopeArgs.builder()
                .realmId(realm.id())
                .name("client-scope")
                .build());
    
            var clientDefaultScopes = new ClientDefaultScope("clientDefaultScopes", ClientDefaultScopeArgs.builder()
                .realmId(realm.id())
                .clientId(client.id())
                .defaultScopes(            
                    "role_list",
                    clientScope.name())
                .build());
    
        }
    }
    
    resources:
      realm:
        type: keycloak:Realm
        properties:
          realm: my-realm
          enabled: true
      samlClient:
        type: keycloak:saml:Client
        name: saml_client
        properties:
          realmId: ${realm.id}
          clientId: saml-client
          name: saml-client
          signDocuments: false
          signAssertions: true
          includeAuthnStatement: true
          signingCertificate:
            fn::invoke:
              function: std:file
              arguments:
                input: saml-cert.pem
              return: result
          signingPrivateKey:
            fn::invoke:
              function: std:file
              arguments:
                input: saml-key.pem
              return: result
      clientScope:
        type: keycloak:saml:ClientScope
        name: client_scope
        properties:
          realmId: ${realm.id}
          name: client-scope
      clientDefaultScopes:
        type: keycloak:saml:ClientDefaultScope
        name: client_default_scopes
        properties:
          realmId: ${realm.id}
          clientId: ${client.id}
          defaultScopes:
            - role_list
            - ${clientScope.name}
    

    Create ClientDefaultScope Resource

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

    Constructor syntax

    new ClientDefaultScope(name: string, args: ClientDefaultScopeArgs, opts?: CustomResourceOptions);
    @overload
    def ClientDefaultScope(resource_name: str,
                           args: ClientDefaultScopeArgs,
                           opts: Optional[ResourceOptions] = None)
    
    @overload
    def ClientDefaultScope(resource_name: str,
                           opts: Optional[ResourceOptions] = None,
                           client_id: Optional[str] = None,
                           default_scopes: Optional[Sequence[str]] = None,
                           realm_id: Optional[str] = None)
    func NewClientDefaultScope(ctx *Context, name string, args ClientDefaultScopeArgs, opts ...ResourceOption) (*ClientDefaultScope, error)
    public ClientDefaultScope(string name, ClientDefaultScopeArgs args, CustomResourceOptions? opts = null)
    public ClientDefaultScope(String name, ClientDefaultScopeArgs args)
    public ClientDefaultScope(String name, ClientDefaultScopeArgs args, CustomResourceOptions options)
    
    type: keycloak:saml:ClientDefaultScope
    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 ClientDefaultScopeArgs
    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 ClientDefaultScopeArgs
    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 ClientDefaultScopeArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args ClientDefaultScopeArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args ClientDefaultScopeArgs
    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 clientDefaultScopeResource = new Keycloak.Saml.ClientDefaultScope("clientDefaultScopeResource", new()
    {
        ClientId = "string",
        DefaultScopes = new[]
        {
            "string",
        },
        RealmId = "string",
    });
    
    example, err := saml.NewClientDefaultScope(ctx, "clientDefaultScopeResource", &saml.ClientDefaultScopeArgs{
    	ClientId: pulumi.String("string"),
    	DefaultScopes: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    	RealmId: pulumi.String("string"),
    })
    
    var clientDefaultScopeResource = new ClientDefaultScope("clientDefaultScopeResource", ClientDefaultScopeArgs.builder()
        .clientId("string")
        .defaultScopes("string")
        .realmId("string")
        .build());
    
    client_default_scope_resource = keycloak.saml.ClientDefaultScope("clientDefaultScopeResource",
        client_id="string",
        default_scopes=["string"],
        realm_id="string")
    
    const clientDefaultScopeResource = new keycloak.saml.ClientDefaultScope("clientDefaultScopeResource", {
        clientId: "string",
        defaultScopes: ["string"],
        realmId: "string",
    });
    
    type: keycloak:saml:ClientDefaultScope
    properties:
        clientId: string
        defaultScopes:
            - string
        realmId: string
    

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

    ClientId string
    The ID of the client to attach default scopes to. Note that this is the unique ID of the client generated by Keycloak.
    DefaultScopes List<string>
    An array of client scope names to attach to this client.
    RealmId string
    The realm this client and scopes exists in.
    ClientId string
    The ID of the client to attach default scopes to. Note that this is the unique ID of the client generated by Keycloak.
    DefaultScopes []string
    An array of client scope names to attach to this client.
    RealmId string
    The realm this client and scopes exists in.
    clientId String
    The ID of the client to attach default scopes to. Note that this is the unique ID of the client generated by Keycloak.
    defaultScopes List<String>
    An array of client scope names to attach to this client.
    realmId String
    The realm this client and scopes exists in.
    clientId string
    The ID of the client to attach default scopes to. Note that this is the unique ID of the client generated by Keycloak.
    defaultScopes string[]
    An array of client scope names to attach to this client.
    realmId string
    The realm this client and scopes exists in.
    client_id str
    The ID of the client to attach default scopes to. Note that this is the unique ID of the client generated by Keycloak.
    default_scopes Sequence[str]
    An array of client scope names to attach to this client.
    realm_id str
    The realm this client and scopes exists in.
    clientId String
    The ID of the client to attach default scopes to. Note that this is the unique ID of the client generated by Keycloak.
    defaultScopes List<String>
    An array of client scope names to attach to this client.
    realmId String
    The realm this client and scopes exists in.

    Outputs

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

    Get an existing ClientDefaultScope 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?: ClientDefaultScopeState, opts?: CustomResourceOptions): ClientDefaultScope
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            client_id: Optional[str] = None,
            default_scopes: Optional[Sequence[str]] = None,
            realm_id: Optional[str] = None) -> ClientDefaultScope
    func GetClientDefaultScope(ctx *Context, name string, id IDInput, state *ClientDefaultScopeState, opts ...ResourceOption) (*ClientDefaultScope, error)
    public static ClientDefaultScope Get(string name, Input<string> id, ClientDefaultScopeState? state, CustomResourceOptions? opts = null)
    public static ClientDefaultScope get(String name, Output<String> id, ClientDefaultScopeState state, CustomResourceOptions options)
    resources:  _:    type: keycloak:saml:ClientDefaultScope    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:
    ClientId string
    The ID of the client to attach default scopes to. Note that this is the unique ID of the client generated by Keycloak.
    DefaultScopes List<string>
    An array of client scope names to attach to this client.
    RealmId string
    The realm this client and scopes exists in.
    ClientId string
    The ID of the client to attach default scopes to. Note that this is the unique ID of the client generated by Keycloak.
    DefaultScopes []string
    An array of client scope names to attach to this client.
    RealmId string
    The realm this client and scopes exists in.
    clientId String
    The ID of the client to attach default scopes to. Note that this is the unique ID of the client generated by Keycloak.
    defaultScopes List<String>
    An array of client scope names to attach to this client.
    realmId String
    The realm this client and scopes exists in.
    clientId string
    The ID of the client to attach default scopes to. Note that this is the unique ID of the client generated by Keycloak.
    defaultScopes string[]
    An array of client scope names to attach to this client.
    realmId string
    The realm this client and scopes exists in.
    client_id str
    The ID of the client to attach default scopes to. Note that this is the unique ID of the client generated by Keycloak.
    default_scopes Sequence[str]
    An array of client scope names to attach to this client.
    realm_id str
    The realm this client and scopes exists in.
    clientId String
    The ID of the client to attach default scopes to. Note that this is the unique ID of the client generated by Keycloak.
    defaultScopes List<String>
    An array of client scope names to attach to this client.
    realmId String
    The realm this client and scopes exists in.

    Import

    This resource does not support import. Instead of importing, feel free to create this resource as if it did not already exist

    on the server.

    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.8.0 published on Saturday, Nov 15, 2025 by Pulumi
      Meet Neo: Your AI Platform Teammate