1. Packages
  2. Keycloak
  3. API Docs
  4. GenericClientRoleMapper
Keycloak v5.3.1 published on Monday, Mar 11, 2024 by Pulumi

keycloak.GenericClientRoleMapper

Explore with Pulumi AI

keycloak logo
Keycloak v5.3.1 published on Monday, Mar 11, 2024 by Pulumi

    !> WARNING: This resource is deprecated and will be removed in the next major version. Please use keycloak.GenericRoleMapper instead.

    Allow for creating and managing a client’s scope mappings within Keycloak.

    By default, all the user role mappings of the user are added as claims within the token (OIDC) or assertion (SAML). When full_scope_allowed is set to false for a client, role scope mapping allows you to limit the roles that get declared inside an access token for a client.

    Example Usage

    Realm Role To Client)

    import * as pulumi from "@pulumi/pulumi";
    import * as keycloak from "@pulumi/keycloak";
    
    const realm = new keycloak.Realm("realm", {
        realm: "my-realm",
        enabled: true,
    });
    const client = new keycloak.openid.Client("client", {
        realmId: realm.id,
        clientId: "client",
        enabled: true,
        accessType: "BEARER-ONLY",
    });
    const realmRole = new keycloak.Role("realmRole", {
        realmId: realm.id,
        description: "My Realm Role",
    });
    const clientRoleMapper = new keycloak.GenericClientRoleMapper("clientRoleMapper", {
        realmId: realm.id,
        clientId: client.id,
        roleId: realmRole.id,
    });
    
    import pulumi
    import pulumi_keycloak as keycloak
    
    realm = keycloak.Realm("realm",
        realm="my-realm",
        enabled=True)
    client = keycloak.openid.Client("client",
        realm_id=realm.id,
        client_id="client",
        enabled=True,
        access_type="BEARER-ONLY")
    realm_role = keycloak.Role("realmRole",
        realm_id=realm.id,
        description="My Realm Role")
    client_role_mapper = keycloak.GenericClientRoleMapper("clientRoleMapper",
        realm_id=realm.id,
        client_id=client.id,
        role_id=realm_role.id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-keycloak/sdk/v5/go/keycloak"
    	"github.com/pulumi/pulumi-keycloak/sdk/v5/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
    		}
    		client, err := openid.NewClient(ctx, "client", &openid.ClientArgs{
    			RealmId:    realm.ID(),
    			ClientId:   pulumi.String("client"),
    			Enabled:    pulumi.Bool(true),
    			AccessType: pulumi.String("BEARER-ONLY"),
    		})
    		if err != nil {
    			return err
    		}
    		realmRole, err := keycloak.NewRole(ctx, "realmRole", &keycloak.RoleArgs{
    			RealmId:     realm.ID(),
    			Description: pulumi.String("My Realm Role"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = keycloak.NewGenericClientRoleMapper(ctx, "clientRoleMapper", &keycloak.GenericClientRoleMapperArgs{
    			RealmId:  realm.ID(),
    			ClientId: client.ID(),
    			RoleId:   realmRole.ID(),
    		})
    		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 client = new Keycloak.OpenId.Client("client", new()
        {
            RealmId = realm.Id,
            ClientId = "client",
            Enabled = true,
            AccessType = "BEARER-ONLY",
        });
    
        var realmRole = new Keycloak.Role("realmRole", new()
        {
            RealmId = realm.Id,
            Description = "My Realm Role",
        });
    
        var clientRoleMapper = new Keycloak.GenericClientRoleMapper("clientRoleMapper", new()
        {
            RealmId = realm.Id,
            ClientId = client.Id,
            RoleId = realmRole.Id,
        });
    
    });
    
    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.Role;
    import com.pulumi.keycloak.RoleArgs;
    import com.pulumi.keycloak.GenericClientRoleMapper;
    import com.pulumi.keycloak.GenericClientRoleMapperArgs;
    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 client = new Client("client", ClientArgs.builder()        
                .realmId(realm.id())
                .clientId("client")
                .enabled(true)
                .accessType("BEARER-ONLY")
                .build());
    
            var realmRole = new Role("realmRole", RoleArgs.builder()        
                .realmId(realm.id())
                .description("My Realm Role")
                .build());
    
            var clientRoleMapper = new GenericClientRoleMapper("clientRoleMapper", GenericClientRoleMapperArgs.builder()        
                .realmId(realm.id())
                .clientId(client.id())
                .roleId(realmRole.id())
                .build());
    
        }
    }
    
    resources:
      realm:
        type: keycloak:Realm
        properties:
          realm: my-realm
          enabled: true
      client:
        type: keycloak:openid:Client
        properties:
          realmId: ${realm.id}
          clientId: client
          enabled: true
          accessType: BEARER-ONLY
      realmRole:
        type: keycloak:Role
        properties:
          realmId: ${realm.id}
          description: My Realm Role
      clientRoleMapper:
        type: keycloak:GenericClientRoleMapper
        properties:
          realmId: ${realm.id}
          clientId: ${client.id}
          roleId: ${realmRole.id}
    

    Client Role To Client)

    import * as pulumi from "@pulumi/pulumi";
    import * as keycloak from "@pulumi/keycloak";
    
    const realm = new keycloak.Realm("realm", {
        realm: "my-realm",
        enabled: true,
    });
    const clientA = new keycloak.openid.Client("clientA", {
        realmId: realm.id,
        clientId: "client-a",
        enabled: true,
        accessType: "BEARER-ONLY",
        fullScopeAllowed: false,
    });
    const clientRoleA = new keycloak.Role("clientRoleA", {
        realmId: realm.id,
        clientId: clientA.id,
        description: "My Client Role",
    });
    const clientB = new keycloak.openid.Client("clientB", {
        realmId: realm.id,
        clientId: "client-b",
        enabled: true,
        accessType: "BEARER-ONLY",
    });
    const clientRoleB = new keycloak.Role("clientRoleB", {
        realmId: realm.id,
        clientId: clientB.id,
        description: "My Client Role",
    });
    const clientBRoleMapper = new keycloak.GenericClientRoleMapper("clientBRoleMapper", {
        realmId: realm.id,
        clientId: clientB.id,
        roleId: clientRoleA.id,
    });
    
    import pulumi
    import pulumi_keycloak as keycloak
    
    realm = keycloak.Realm("realm",
        realm="my-realm",
        enabled=True)
    client_a = keycloak.openid.Client("clientA",
        realm_id=realm.id,
        client_id="client-a",
        enabled=True,
        access_type="BEARER-ONLY",
        full_scope_allowed=False)
    client_role_a = keycloak.Role("clientRoleA",
        realm_id=realm.id,
        client_id=client_a.id,
        description="My Client Role")
    client_b = keycloak.openid.Client("clientB",
        realm_id=realm.id,
        client_id="client-b",
        enabled=True,
        access_type="BEARER-ONLY")
    client_role_b = keycloak.Role("clientRoleB",
        realm_id=realm.id,
        client_id=client_b.id,
        description="My Client Role")
    client_b_role_mapper = keycloak.GenericClientRoleMapper("clientBRoleMapper",
        realm_id=realm.id,
        client_id=client_b.id,
        role_id=client_role_a.id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-keycloak/sdk/v5/go/keycloak"
    	"github.com/pulumi/pulumi-keycloak/sdk/v5/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
    		}
    		clientA, err := openid.NewClient(ctx, "clientA", &openid.ClientArgs{
    			RealmId:          realm.ID(),
    			ClientId:         pulumi.String("client-a"),
    			Enabled:          pulumi.Bool(true),
    			AccessType:       pulumi.String("BEARER-ONLY"),
    			FullScopeAllowed: pulumi.Bool(false),
    		})
    		if err != nil {
    			return err
    		}
    		clientRoleA, err := keycloak.NewRole(ctx, "clientRoleA", &keycloak.RoleArgs{
    			RealmId:     realm.ID(),
    			ClientId:    clientA.ID(),
    			Description: pulumi.String("My Client Role"),
    		})
    		if err != nil {
    			return err
    		}
    		clientB, err := openid.NewClient(ctx, "clientB", &openid.ClientArgs{
    			RealmId:    realm.ID(),
    			ClientId:   pulumi.String("client-b"),
    			Enabled:    pulumi.Bool(true),
    			AccessType: pulumi.String("BEARER-ONLY"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = keycloak.NewRole(ctx, "clientRoleB", &keycloak.RoleArgs{
    			RealmId:     realm.ID(),
    			ClientId:    clientB.ID(),
    			Description: pulumi.String("My Client Role"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = keycloak.NewGenericClientRoleMapper(ctx, "clientBRoleMapper", &keycloak.GenericClientRoleMapperArgs{
    			RealmId:  realm.ID(),
    			ClientId: clientB.ID(),
    			RoleId:   clientRoleA.ID(),
    		})
    		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 clientA = new Keycloak.OpenId.Client("clientA", new()
        {
            RealmId = realm.Id,
            ClientId = "client-a",
            Enabled = true,
            AccessType = "BEARER-ONLY",
            FullScopeAllowed = false,
        });
    
        var clientRoleA = new Keycloak.Role("clientRoleA", new()
        {
            RealmId = realm.Id,
            ClientId = clientA.Id,
            Description = "My Client Role",
        });
    
        var clientB = new Keycloak.OpenId.Client("clientB", new()
        {
            RealmId = realm.Id,
            ClientId = "client-b",
            Enabled = true,
            AccessType = "BEARER-ONLY",
        });
    
        var clientRoleB = new Keycloak.Role("clientRoleB", new()
        {
            RealmId = realm.Id,
            ClientId = clientB.Id,
            Description = "My Client Role",
        });
    
        var clientBRoleMapper = new Keycloak.GenericClientRoleMapper("clientBRoleMapper", new()
        {
            RealmId = realm.Id,
            ClientId = clientB.Id,
            RoleId = clientRoleA.Id,
        });
    
    });
    
    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.Role;
    import com.pulumi.keycloak.RoleArgs;
    import com.pulumi.keycloak.GenericClientRoleMapper;
    import com.pulumi.keycloak.GenericClientRoleMapperArgs;
    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 clientA = new Client("clientA", ClientArgs.builder()        
                .realmId(realm.id())
                .clientId("client-a")
                .enabled(true)
                .accessType("BEARER-ONLY")
                .fullScopeAllowed(false)
                .build());
    
            var clientRoleA = new Role("clientRoleA", RoleArgs.builder()        
                .realmId(realm.id())
                .clientId(clientA.id())
                .description("My Client Role")
                .build());
    
            var clientB = new Client("clientB", ClientArgs.builder()        
                .realmId(realm.id())
                .clientId("client-b")
                .enabled(true)
                .accessType("BEARER-ONLY")
                .build());
    
            var clientRoleB = new Role("clientRoleB", RoleArgs.builder()        
                .realmId(realm.id())
                .clientId(clientB.id())
                .description("My Client Role")
                .build());
    
            var clientBRoleMapper = new GenericClientRoleMapper("clientBRoleMapper", GenericClientRoleMapperArgs.builder()        
                .realmId(realm.id())
                .clientId(clientB.id())
                .roleId(clientRoleA.id())
                .build());
    
        }
    }
    
    resources:
      realm:
        type: keycloak:Realm
        properties:
          realm: my-realm
          enabled: true
      clientA:
        type: keycloak:openid:Client
        properties:
          realmId: ${realm.id}
          clientId: client-a
          enabled: true
          accessType: BEARER-ONLY
          # disable full scope, roles are assigned via keycloak_generic_client_role_mapper
          fullScopeAllowed: false
      clientRoleA:
        type: keycloak:Role
        properties:
          realmId: ${realm.id}
          clientId: ${clientA.id}
          description: My Client Role
      clientB:
        type: keycloak:openid:Client
        properties:
          realmId: ${realm.id}
          clientId: client-b
          enabled: true
          accessType: BEARER-ONLY
      clientRoleB:
        type: keycloak:Role
        properties:
          realmId: ${realm.id}
          clientId: ${clientB.id}
          description: My Client Role
      clientBRoleMapper:
        type: keycloak:GenericClientRoleMapper
        properties:
          realmId: ${realm.id}
          clientId: ${clientB.id}
          roleId: ${clientRoleA.id}
    

    Realm Role To Client Scope)

    import * as pulumi from "@pulumi/pulumi";
    import * as keycloak from "@pulumi/keycloak";
    
    const realm = new keycloak.Realm("realm", {
        realm: "my-realm",
        enabled: true,
    });
    const clientScope = new keycloak.openid.ClientScope("clientScope", {realmId: realm.id});
    const realmRole = new keycloak.Role("realmRole", {
        realmId: realm.id,
        description: "My Realm Role",
    });
    const clientRoleMapper = new keycloak.GenericClientRoleMapper("clientRoleMapper", {
        realmId: realm.id,
        clientScopeId: clientScope.id,
        roleId: realmRole.id,
    });
    
    import pulumi
    import pulumi_keycloak as keycloak
    
    realm = keycloak.Realm("realm",
        realm="my-realm",
        enabled=True)
    client_scope = keycloak.openid.ClientScope("clientScope", realm_id=realm.id)
    realm_role = keycloak.Role("realmRole",
        realm_id=realm.id,
        description="My Realm Role")
    client_role_mapper = keycloak.GenericClientRoleMapper("clientRoleMapper",
        realm_id=realm.id,
        client_scope_id=client_scope.id,
        role_id=realm_role.id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-keycloak/sdk/v5/go/keycloak"
    	"github.com/pulumi/pulumi-keycloak/sdk/v5/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
    		}
    		clientScope, err := openid.NewClientScope(ctx, "clientScope", &openid.ClientScopeArgs{
    			RealmId: realm.ID(),
    		})
    		if err != nil {
    			return err
    		}
    		realmRole, err := keycloak.NewRole(ctx, "realmRole", &keycloak.RoleArgs{
    			RealmId:     realm.ID(),
    			Description: pulumi.String("My Realm Role"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = keycloak.NewGenericClientRoleMapper(ctx, "clientRoleMapper", &keycloak.GenericClientRoleMapperArgs{
    			RealmId:       realm.ID(),
    			ClientScopeId: clientScope.ID(),
    			RoleId:        realmRole.ID(),
    		})
    		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 clientScope = new Keycloak.OpenId.ClientScope("clientScope", new()
        {
            RealmId = realm.Id,
        });
    
        var realmRole = new Keycloak.Role("realmRole", new()
        {
            RealmId = realm.Id,
            Description = "My Realm Role",
        });
    
        var clientRoleMapper = new Keycloak.GenericClientRoleMapper("clientRoleMapper", new()
        {
            RealmId = realm.Id,
            ClientScopeId = clientScope.Id,
            RoleId = realmRole.Id,
        });
    
    });
    
    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.ClientScope;
    import com.pulumi.keycloak.openid.ClientScopeArgs;
    import com.pulumi.keycloak.Role;
    import com.pulumi.keycloak.RoleArgs;
    import com.pulumi.keycloak.GenericClientRoleMapper;
    import com.pulumi.keycloak.GenericClientRoleMapperArgs;
    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 clientScope = new ClientScope("clientScope", ClientScopeArgs.builder()        
                .realmId(realm.id())
                .build());
    
            var realmRole = new Role("realmRole", RoleArgs.builder()        
                .realmId(realm.id())
                .description("My Realm Role")
                .build());
    
            var clientRoleMapper = new GenericClientRoleMapper("clientRoleMapper", GenericClientRoleMapperArgs.builder()        
                .realmId(realm.id())
                .clientScopeId(clientScope.id())
                .roleId(realmRole.id())
                .build());
    
        }
    }
    
    resources:
      realm:
        type: keycloak:Realm
        properties:
          realm: my-realm
          enabled: true
      clientScope:
        type: keycloak:openid:ClientScope
        properties:
          realmId: ${realm.id}
      realmRole:
        type: keycloak:Role
        properties:
          realmId: ${realm.id}
          description: My Realm Role
      clientRoleMapper:
        type: keycloak:GenericClientRoleMapper
        properties:
          realmId: ${realm.id}
          clientScopeId: ${clientScope.id}
          roleId: ${realmRole.id}
    

    Client Role To Client Scope)

    import * as pulumi from "@pulumi/pulumi";
    import * as keycloak from "@pulumi/keycloak";
    
    const realm = new keycloak.Realm("realm", {
        realm: "my-realm",
        enabled: true,
    });
    const client = new keycloak.openid.Client("client", {
        realmId: realm.id,
        clientId: "client",
        enabled: true,
        accessType: "BEARER-ONLY",
    });
    const clientRole = new keycloak.Role("clientRole", {
        realmId: realm.id,
        clientId: client.id,
        description: "My Client Role",
    });
    const clientScope = new keycloak.openid.ClientScope("clientScope", {realmId: realm.id});
    const clientBRoleMapper = new keycloak.GenericClientRoleMapper("clientBRoleMapper", {
        realmId: realm.id,
        clientScopeId: clientScope.id,
        roleId: clientRole.id,
    });
    
    import pulumi
    import pulumi_keycloak as keycloak
    
    realm = keycloak.Realm("realm",
        realm="my-realm",
        enabled=True)
    client = keycloak.openid.Client("client",
        realm_id=realm.id,
        client_id="client",
        enabled=True,
        access_type="BEARER-ONLY")
    client_role = keycloak.Role("clientRole",
        realm_id=realm.id,
        client_id=client.id,
        description="My Client Role")
    client_scope = keycloak.openid.ClientScope("clientScope", realm_id=realm.id)
    client_b_role_mapper = keycloak.GenericClientRoleMapper("clientBRoleMapper",
        realm_id=realm.id,
        client_scope_id=client_scope.id,
        role_id=client_role.id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-keycloak/sdk/v5/go/keycloak"
    	"github.com/pulumi/pulumi-keycloak/sdk/v5/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
    		}
    		client, err := openid.NewClient(ctx, "client", &openid.ClientArgs{
    			RealmId:    realm.ID(),
    			ClientId:   pulumi.String("client"),
    			Enabled:    pulumi.Bool(true),
    			AccessType: pulumi.String("BEARER-ONLY"),
    		})
    		if err != nil {
    			return err
    		}
    		clientRole, err := keycloak.NewRole(ctx, "clientRole", &keycloak.RoleArgs{
    			RealmId:     realm.ID(),
    			ClientId:    client.ID(),
    			Description: pulumi.String("My Client Role"),
    		})
    		if err != nil {
    			return err
    		}
    		clientScope, err := openid.NewClientScope(ctx, "clientScope", &openid.ClientScopeArgs{
    			RealmId: realm.ID(),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = keycloak.NewGenericClientRoleMapper(ctx, "clientBRoleMapper", &keycloak.GenericClientRoleMapperArgs{
    			RealmId:       realm.ID(),
    			ClientScopeId: clientScope.ID(),
    			RoleId:        clientRole.ID(),
    		})
    		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 client = new Keycloak.OpenId.Client("client", new()
        {
            RealmId = realm.Id,
            ClientId = "client",
            Enabled = true,
            AccessType = "BEARER-ONLY",
        });
    
        var clientRole = new Keycloak.Role("clientRole", new()
        {
            RealmId = realm.Id,
            ClientId = client.Id,
            Description = "My Client Role",
        });
    
        var clientScope = new Keycloak.OpenId.ClientScope("clientScope", new()
        {
            RealmId = realm.Id,
        });
    
        var clientBRoleMapper = new Keycloak.GenericClientRoleMapper("clientBRoleMapper", new()
        {
            RealmId = realm.Id,
            ClientScopeId = clientScope.Id,
            RoleId = clientRole.Id,
        });
    
    });
    
    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.Role;
    import com.pulumi.keycloak.RoleArgs;
    import com.pulumi.keycloak.openid.ClientScope;
    import com.pulumi.keycloak.openid.ClientScopeArgs;
    import com.pulumi.keycloak.GenericClientRoleMapper;
    import com.pulumi.keycloak.GenericClientRoleMapperArgs;
    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 client = new Client("client", ClientArgs.builder()        
                .realmId(realm.id())
                .clientId("client")
                .enabled(true)
                .accessType("BEARER-ONLY")
                .build());
    
            var clientRole = new Role("clientRole", RoleArgs.builder()        
                .realmId(realm.id())
                .clientId(client.id())
                .description("My Client Role")
                .build());
    
            var clientScope = new ClientScope("clientScope", ClientScopeArgs.builder()        
                .realmId(realm.id())
                .build());
    
            var clientBRoleMapper = new GenericClientRoleMapper("clientBRoleMapper", GenericClientRoleMapperArgs.builder()        
                .realmId(realm.id())
                .clientScopeId(clientScope.id())
                .roleId(clientRole.id())
                .build());
    
        }
    }
    
    resources:
      realm:
        type: keycloak:Realm
        properties:
          realm: my-realm
          enabled: true
      client:
        type: keycloak:openid:Client
        properties:
          realmId: ${realm.id}
          clientId: client
          enabled: true
          accessType: BEARER-ONLY
      clientRole:
        type: keycloak:Role
        properties:
          realmId: ${realm.id}
          clientId: ${client.id}
          description: My Client Role
      clientScope:
        type: keycloak:openid:ClientScope
        properties:
          realmId: ${realm.id}
      clientBRoleMapper:
        type: keycloak:GenericClientRoleMapper
        properties:
          realmId: ${realm.id}
          clientScopeId: ${clientScope.id}
          roleId: ${clientRole.id}
    

    Create GenericClientRoleMapper Resource

    new GenericClientRoleMapper(name: string, args: GenericClientRoleMapperArgs, opts?: CustomResourceOptions);
    @overload
    def GenericClientRoleMapper(resource_name: str,
                                opts: Optional[ResourceOptions] = None,
                                client_id: Optional[str] = None,
                                client_scope_id: Optional[str] = None,
                                realm_id: Optional[str] = None,
                                role_id: Optional[str] = None)
    @overload
    def GenericClientRoleMapper(resource_name: str,
                                args: GenericClientRoleMapperArgs,
                                opts: Optional[ResourceOptions] = None)
    func NewGenericClientRoleMapper(ctx *Context, name string, args GenericClientRoleMapperArgs, opts ...ResourceOption) (*GenericClientRoleMapper, error)
    public GenericClientRoleMapper(string name, GenericClientRoleMapperArgs args, CustomResourceOptions? opts = null)
    public GenericClientRoleMapper(String name, GenericClientRoleMapperArgs args)
    public GenericClientRoleMapper(String name, GenericClientRoleMapperArgs args, CustomResourceOptions options)
    
    type: keycloak:GenericClientRoleMapper
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    name string
    The unique name of the resource.
    args GenericClientRoleMapperArgs
    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 GenericClientRoleMapperArgs
    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 GenericClientRoleMapperArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args GenericClientRoleMapperArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args GenericClientRoleMapperArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    GenericClientRoleMapper Resource Properties

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

    Inputs

    The GenericClientRoleMapper resource accepts the following input properties:

    RealmId string
    The realm this role mapper exists within.
    RoleId string
    The ID of the role to be added to this role mapper.
    ClientId string
    The ID of the client this role mapper should be added to. Conflicts with client_scope_id. This argument is required if client_scope_id is not set.
    ClientScopeId string
    The ID of the client scope this role mapper should be added to. Conflicts with client_id. This argument is required if client_id is not set.
    RealmId string
    The realm this role mapper exists within.
    RoleId string
    The ID of the role to be added to this role mapper.
    ClientId string
    The ID of the client this role mapper should be added to. Conflicts with client_scope_id. This argument is required if client_scope_id is not set.
    ClientScopeId string
    The ID of the client scope this role mapper should be added to. Conflicts with client_id. This argument is required if client_id is not set.
    realmId String
    The realm this role mapper exists within.
    roleId String
    The ID of the role to be added to this role mapper.
    clientId String
    The ID of the client this role mapper should be added to. Conflicts with client_scope_id. This argument is required if client_scope_id is not set.
    clientScopeId String
    The ID of the client scope this role mapper should be added to. Conflicts with client_id. This argument is required if client_id is not set.
    realmId string
    The realm this role mapper exists within.
    roleId string
    The ID of the role to be added to this role mapper.
    clientId string
    The ID of the client this role mapper should be added to. Conflicts with client_scope_id. This argument is required if client_scope_id is not set.
    clientScopeId string
    The ID of the client scope this role mapper should be added to. Conflicts with client_id. This argument is required if client_id is not set.
    realm_id str
    The realm this role mapper exists within.
    role_id str
    The ID of the role to be added to this role mapper.
    client_id str
    The ID of the client this role mapper should be added to. Conflicts with client_scope_id. This argument is required if client_scope_id is not set.
    client_scope_id str
    The ID of the client scope this role mapper should be added to. Conflicts with client_id. This argument is required if client_id is not set.
    realmId String
    The realm this role mapper exists within.
    roleId String
    The ID of the role to be added to this role mapper.
    clientId String
    The ID of the client this role mapper should be added to. Conflicts with client_scope_id. This argument is required if client_scope_id is not set.
    clientScopeId String
    The ID of the client scope this role mapper should be added to. Conflicts with client_id. This argument is required if client_id is not set.

    Outputs

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

    Get an existing GenericClientRoleMapper 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?: GenericClientRoleMapperState, opts?: CustomResourceOptions): GenericClientRoleMapper
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            client_id: Optional[str] = None,
            client_scope_id: Optional[str] = None,
            realm_id: Optional[str] = None,
            role_id: Optional[str] = None) -> GenericClientRoleMapper
    func GetGenericClientRoleMapper(ctx *Context, name string, id IDInput, state *GenericClientRoleMapperState, opts ...ResourceOption) (*GenericClientRoleMapper, error)
    public static GenericClientRoleMapper Get(string name, Input<string> id, GenericClientRoleMapperState? state, CustomResourceOptions? opts = null)
    public static GenericClientRoleMapper get(String name, Output<String> id, GenericClientRoleMapperState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    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 this role mapper should be added to. Conflicts with client_scope_id. This argument is required if client_scope_id is not set.
    ClientScopeId string
    The ID of the client scope this role mapper should be added to. Conflicts with client_id. This argument is required if client_id is not set.
    RealmId string
    The realm this role mapper exists within.
    RoleId string
    The ID of the role to be added to this role mapper.
    ClientId string
    The ID of the client this role mapper should be added to. Conflicts with client_scope_id. This argument is required if client_scope_id is not set.
    ClientScopeId string
    The ID of the client scope this role mapper should be added to. Conflicts with client_id. This argument is required if client_id is not set.
    RealmId string
    The realm this role mapper exists within.
    RoleId string
    The ID of the role to be added to this role mapper.
    clientId String
    The ID of the client this role mapper should be added to. Conflicts with client_scope_id. This argument is required if client_scope_id is not set.
    clientScopeId String
    The ID of the client scope this role mapper should be added to. Conflicts with client_id. This argument is required if client_id is not set.
    realmId String
    The realm this role mapper exists within.
    roleId String
    The ID of the role to be added to this role mapper.
    clientId string
    The ID of the client this role mapper should be added to. Conflicts with client_scope_id. This argument is required if client_scope_id is not set.
    clientScopeId string
    The ID of the client scope this role mapper should be added to. Conflicts with client_id. This argument is required if client_id is not set.
    realmId string
    The realm this role mapper exists within.
    roleId string
    The ID of the role to be added to this role mapper.
    client_id str
    The ID of the client this role mapper should be added to. Conflicts with client_scope_id. This argument is required if client_scope_id is not set.
    client_scope_id str
    The ID of the client scope this role mapper should be added to. Conflicts with client_id. This argument is required if client_id is not set.
    realm_id str
    The realm this role mapper exists within.
    role_id str
    The ID of the role to be added to this role mapper.
    clientId String
    The ID of the client this role mapper should be added to. Conflicts with client_scope_id. This argument is required if client_scope_id is not set.
    clientScopeId String
    The ID of the client scope this role mapper should be added to. Conflicts with client_id. This argument is required if client_id is not set.
    realmId String
    The realm this role mapper exists within.
    roleId String
    The ID of the role to be added to this role mapper.

    Import

    Generic client role mappers can be imported using one of the following two formats:

    • When mapping a role to a client, use the format {{realmId}}/client/{{clientId}}/scope-mappings/{{roleClientId}}/{{roleId}}

    • When mapping a role to a client scope, use the format {{realmId}}/client-scope/{{clientScopeId}}/scope-mappings/{{roleClientId}}/{{roleId}}

    Example:

    bash

    $ pulumi import keycloak:index/genericClientRoleMapper:GenericClientRoleMapper client_role_mapper my-realm/client/23888550-5dcd-41f6-85ba-554233021e9c/scope-mappings/ce51f004-bdfb-4dd5-a963-c4487d2dec5b/ff3aa49f-bc07-4030-8783-41918c3614a3
    

    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 v5.3.1 published on Monday, Mar 11, 2024 by Pulumi