HardcodedRoleProtocolMapper

# keycloak.openid.HardcodedRoleProtocolMapper

Allows for creating and managing hardcoded role protocol mappers within Keycloak.

Hardcoded role protocol mappers allow you to specify a single role to always map to an access token for a client. Protocol mappers can be defined for a single client, or they can be defined for a client scope which can be shared between multiple different clients.

Example Usage (Client)

import * as pulumi from "@pulumi/pulumi";
import * as keycloak from "@pulumi/keycloak";

const realm = new keycloak.Realm("realm", {
    enabled: true,
    realm: "my-realm",
});
const role = new keycloak.Role("role", {
    realmId: realm.id,
});
const openidClient = new keycloak.openid.Client("openid_client", {
    accessType: "CONFIDENTIAL",
    clientId: "test-client",
    enabled: true,
    realmId: realm.id,
    validRedirectUris: ["http://localhost:8080/openid-callback"],
});
const hardcodedRoleMapper = new keycloak.openid.HardcodedRoleProtocolMapper("hardcoded_role_mapper", {
    clientId: openidClient.id,
    realmId: realm.id,
    roleId: role.id,
});
import pulumi
import pulumi_keycloak as keycloak

realm = keycloak.Realm("realm",
    enabled=True,
    realm="my-realm")
role = keycloak.Role("role", realm_id=realm.id)
openid_client = keycloak.openid.Client("openidClient",
    access_type="CONFIDENTIAL",
    client_id="test-client",
    enabled=True,
    realm_id=realm.id,
    valid_redirect_uris=["http://localhost:8080/openid-callback"])
hardcoded_role_mapper = keycloak.openid.HardcodedRoleProtocolMapper("hardcodedRoleMapper",
    client_id=openid_client.id,
    realm_id=realm.id,
    role_id=role.id)
using Pulumi;
using Keycloak = Pulumi.Keycloak;

class MyStack : Stack
{
    public MyStack()
    {
        var realm = new Keycloak.Realm("realm", new Keycloak.RealmArgs
        {
            Enabled = true,
            Realm = "my-realm",
        });
        var role = new Keycloak.Role("role", new Keycloak.RoleArgs
        {
            RealmId = realm.Id,
        });
        var openidClient = new Keycloak.OpenId.Client("openidClient", new Keycloak.OpenId.ClientArgs
        {
            AccessType = "CONFIDENTIAL",
            ClientId = "test-client",
            Enabled = true,
            RealmId = realm.Id,
            ValidRedirectUris = 
            {
                "http://localhost:8080/openid-callback",
            },
        });
        var hardcodedRoleMapper = new Keycloak.OpenId.HardcodedRoleProtocolMapper("hardcodedRoleMapper", new Keycloak.OpenId.HardcodedRoleProtocolMapperArgs
        {
            ClientId = openidClient.Id,
            RealmId = realm.Id,
            RoleId = role.Id,
        });
    }

}

Example Usage (Client Scope)

import * as pulumi from "@pulumi/pulumi";
import * as keycloak from "@pulumi/keycloak";

const realm = new keycloak.Realm("realm", {
    enabled: true,
    realm: "my-realm",
});
const role = new keycloak.Role("role", {
    realmId: realm.id,
});
const clientScope = new keycloak.openid.ClientScope("client_scope", {
    realmId: realm.id,
});
const hardcodedRoleMapper = new keycloak.openid.HardcodedRoleProtocolMapper("hardcoded_role_mapper", {
    clientScopeId: clientScope.id,
    realmId: realm.id,
    roleId: role.id,
});
import pulumi
import pulumi_keycloak as keycloak

realm = keycloak.Realm("realm",
    enabled=True,
    realm="my-realm")
role = keycloak.Role("role", realm_id=realm.id)
client_scope = keycloak.openid.ClientScope("clientScope", realm_id=realm.id)
hardcoded_role_mapper = keycloak.openid.HardcodedRoleProtocolMapper("hardcodedRoleMapper",
    client_scope_id=client_scope.id,
    realm_id=realm.id,
    role_id=role.id)
using Pulumi;
using Keycloak = Pulumi.Keycloak;

class MyStack : Stack
{
    public MyStack()
    {
        var realm = new Keycloak.Realm("realm", new Keycloak.RealmArgs
        {
            Enabled = true,
            Realm = "my-realm",
        });
        var role = new Keycloak.Role("role", new Keycloak.RoleArgs
        {
            RealmId = realm.Id,
        });
        var clientScope = new Keycloak.OpenId.ClientScope("clientScope", new Keycloak.OpenId.ClientScopeArgs
        {
            RealmId = realm.Id,
        });
        var hardcodedRoleMapper = new Keycloak.OpenId.HardcodedRoleProtocolMapper("hardcodedRoleMapper", new Keycloak.OpenId.HardcodedRoleProtocolMapperArgs
        {
            ClientScopeId = clientScope.Id,
            RealmId = realm.Id,
            RoleId = role.Id,
        });
    }

}

Argument Reference

The following arguments are supported:

  • realm_id - (Required) The realm this protocol mapper exists within.
  • client_id - (Required if client_scope_id is not specified) The client this protocol mapper is attached to.
  • client_scope_id - (Required if client_id is not specified) The client scope this protocol mapper is attached to.
  • name - (Required) The display name of this protocol mapper in the GUI.
  • role_id - (Required) The ID of the role to map to an access token.

Create a HardcodedRoleProtocolMapper Resource

def HardcodedRoleProtocolMapper(resource_name, opts=None, client_id=None, client_scope_id=None, name=None, realm_id=None, role_id=None, __props__=None);
name string
The unique name of the resource.
args HardcodedRoleProtocolMapperArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
opts ResourceOptions
A bag of options that control this resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args HardcodedRoleProtocolMapperArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args HardcodedRoleProtocolMapperArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

HardcodedRoleProtocolMapper Resource Properties

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

Inputs

The HardcodedRoleProtocolMapper resource accepts the following input properties:

RealmId string

The realm id where the associated client or client scope exists.

RoleId string
ClientId string

The mapper’s associated client. Cannot be used at the same time as client_scope_id.

ClientScopeId string

The mapper’s associated client scope. Cannot be used at the same time as client_id.

Name string

A human-friendly name that will appear in the Keycloak console.

RealmId string

The realm id where the associated client or client scope exists.

RoleId string
ClientId string

The mapper’s associated client. Cannot be used at the same time as client_scope_id.

ClientScopeId string

The mapper’s associated client scope. Cannot be used at the same time as client_id.

Name string

A human-friendly name that will appear in the Keycloak console.

realmId string

The realm id where the associated client or client scope exists.

roleId string
clientId string

The mapper’s associated client. Cannot be used at the same time as client_scope_id.

clientScopeId string

The mapper’s associated client scope. Cannot be used at the same time as client_id.

name string

A human-friendly name that will appear in the Keycloak console.

realm_id str

The realm id where the associated client or client scope exists.

role_id str
client_id str

The mapper’s associated client. Cannot be used at the same time as client_scope_id.

client_scope_id str

The mapper’s associated client scope. Cannot be used at the same time as client_id.

name str

A human-friendly name that will appear in the Keycloak console.

Outputs

All input properties are implicitly available as output properties. Additionally, the HardcodedRoleProtocolMapper 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 str
The provider-assigned unique ID for this managed resource.

Look up an Existing HardcodedRoleProtocolMapper Resource

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

static get(resource_name, id, opts=None, client_id=None, client_scope_id=None, name=None, realm_id=None, role_id=None, __props__=None);
func GetHardcodedRoleProtocolMapper(ctx *Context, name string, id IDInput, state *HardcodedRoleProtocolMapperState, opts ...ResourceOption) (*HardcodedRoleProtocolMapper, error)
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.

The following state arguments are supported:

ClientId string

The mapper’s associated client. Cannot be used at the same time as client_scope_id.

ClientScopeId string

The mapper’s associated client scope. Cannot be used at the same time as client_id.

Name string

A human-friendly name that will appear in the Keycloak console.

RealmId string

The realm id where the associated client or client scope exists.

RoleId string
ClientId string

The mapper’s associated client. Cannot be used at the same time as client_scope_id.

ClientScopeId string

The mapper’s associated client scope. Cannot be used at the same time as client_id.

Name string

A human-friendly name that will appear in the Keycloak console.

RealmId string

The realm id where the associated client or client scope exists.

RoleId string
clientId string

The mapper’s associated client. Cannot be used at the same time as client_scope_id.

clientScopeId string

The mapper’s associated client scope. Cannot be used at the same time as client_id.

name string

A human-friendly name that will appear in the Keycloak console.

realmId string

The realm id where the associated client or client scope exists.

roleId string
client_id str

The mapper’s associated client. Cannot be used at the same time as client_scope_id.

client_scope_id str

The mapper’s associated client scope. Cannot be used at the same time as client_id.

name str

A human-friendly name that will appear in the Keycloak console.

realm_id str

The realm id where the associated client or client scope exists.

role_id str

Package Details

Repository
https://github.com/pulumi/pulumi-keycloak
License
Apache-2.0
Notes
This Pulumi package is based on the keycloak Terraform Provider.