AudienceProtocolMapper

# keycloak.openid.AudienceProtocolMapper

Allows for creating and managing audience protocol mappers within Keycloak. This mapper was added in Keycloak v4.6.0.Final.

Audience protocol mappers allow you add audiences to the aud claim within issued tokens. The audience can be a custom string, or it can be mapped to the ID of a pre-existing client.

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 openidClient = new keycloak.openid.Client("openid_client", {
    accessType: "CONFIDENTIAL",
    clientId: "test-client",
    enabled: true,
    realmId: realm.id,
    validRedirectUris: ["http://localhost:8080/openid-callback"],
});
const audienceMapper = new keycloak.openid.AudienceProtocolMapper("audience_mapper", {
    clientId: openidClient.id,
    includedCustomAudience: "foo",
    realmId: realm.id,
});
import pulumi
import pulumi_keycloak as keycloak

realm = keycloak.Realm("realm",
    enabled=True,
    realm="my-realm")
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"])
audience_mapper = keycloak.openid.AudienceProtocolMapper("audienceMapper",
    client_id=openid_client.id,
    included_custom_audience="foo",
    realm_id=realm.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 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 audienceMapper = new Keycloak.OpenId.AudienceProtocolMapper("audienceMapper", new Keycloak.OpenId.AudienceProtocolMapperArgs
        {
            ClientId = openidClient.Id,
            IncludedCustomAudience = "foo",
            RealmId = realm.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 clientScope = new keycloak.openid.ClientScope("client_scope", {
    realmId: realm.id,
});
const audienceMapper = new keycloak.openid.AudienceProtocolMapper("audience_mapper", {
    clientScopeId: clientScope.id,
    includedCustomAudience: "foo",
    realmId: realm.id,
});
import pulumi
import pulumi_keycloak as keycloak

realm = keycloak.Realm("realm",
    enabled=True,
    realm="my-realm")
client_scope = keycloak.openid.ClientScope("clientScope", realm_id=realm.id)
audience_mapper = keycloak.openid.AudienceProtocolMapper("audienceMapper",
    client_scope_id=client_scope.id,
    included_custom_audience="foo",
    realm_id=realm.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 clientScope = new Keycloak.OpenId.ClientScope("clientScope", new Keycloak.OpenId.ClientScopeArgs
        {
            RealmId = realm.Id,
        });
        var audienceMapper = new Keycloak.OpenId.AudienceProtocolMapper("audienceMapper", new Keycloak.OpenId.AudienceProtocolMapperArgs
        {
            ClientScopeId = clientScope.Id,
            IncludedCustomAudience = "foo",
            RealmId = realm.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.
  • included_client_audience - (Required if included_custom_audience is not specified) A client ID to include within the token’s aud claim.
  • included_custom_audience - (Required if included_client_audience is not specified) A custom audience to include within the token’s aud claim.
  • add_to_id_token - (Optional) Indicates if the audience should be included in the aud claim for the id token. Defaults to true.
  • add_to_access_token - (Optional) Indicates if the audience should be included in the aud claim for the id token. Defaults to true.

Create a AudienceProtocolMapper Resource

def AudienceProtocolMapper(resource_name, opts=None, add_to_access_token=None, add_to_id_token=None, client_id=None, client_scope_id=None, included_client_audience=None, included_custom_audience=None, name=None, realm_id=None, __props__=None);
name string
The unique name of the resource.
args AudienceProtocolMapperArgs
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 AudienceProtocolMapperArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args AudienceProtocolMapperArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

AudienceProtocolMapper Resource Properties

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

Inputs

The AudienceProtocolMapper resource accepts the following input properties:

RealmId string

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

AddToAccessToken bool

Indicates if this claim should be added to the access token.

AddToIdToken bool

Indicates if this claim should be added to the id token.

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.

IncludedClientAudience string

A client ID to include within the token’s aud claim. Cannot be used with included_custom_audience

IncludedCustomAudience string

A custom audience to include within the token’s aud claim. Cannot be used with included_custom_audience

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.

AddToAccessToken bool

Indicates if this claim should be added to the access token.

AddToIdToken bool

Indicates if this claim should be added to the id token.

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.

IncludedClientAudience string

A client ID to include within the token’s aud claim. Cannot be used with included_custom_audience

IncludedCustomAudience string

A custom audience to include within the token’s aud claim. Cannot be used with included_custom_audience

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.

addToAccessToken boolean

Indicates if this claim should be added to the access token.

addToIdToken boolean

Indicates if this claim should be added to the id token.

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.

includedClientAudience string

A client ID to include within the token’s aud claim. Cannot be used with included_custom_audience

includedCustomAudience string

A custom audience to include within the token’s aud claim. Cannot be used with included_custom_audience

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.

add_to_access_token bool

Indicates if this claim should be added to the access token.

add_to_id_token bool

Indicates if this claim should be added to the id token.

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.

included_client_audience str

A client ID to include within the token’s aud claim. Cannot be used with included_custom_audience

included_custom_audience str

A custom audience to include within the token’s aud claim. Cannot be used with included_custom_audience

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 AudienceProtocolMapper 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 AudienceProtocolMapper Resource

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

static get(resource_name, id, opts=None, add_to_access_token=None, add_to_id_token=None, client_id=None, client_scope_id=None, included_client_audience=None, included_custom_audience=None, name=None, realm_id=None, __props__=None);
func GetAudienceProtocolMapper(ctx *Context, name string, id IDInput, state *AudienceProtocolMapperState, opts ...ResourceOption) (*AudienceProtocolMapper, 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:

AddToAccessToken bool

Indicates if this claim should be added to the access token.

AddToIdToken bool

Indicates if this claim should be added to the id token.

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.

IncludedClientAudience string

A client ID to include within the token’s aud claim. Cannot be used with included_custom_audience

IncludedCustomAudience string

A custom audience to include within the token’s aud claim. Cannot be used with included_custom_audience

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.

AddToAccessToken bool

Indicates if this claim should be added to the access token.

AddToIdToken bool

Indicates if this claim should be added to the id token.

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.

IncludedClientAudience string

A client ID to include within the token’s aud claim. Cannot be used with included_custom_audience

IncludedCustomAudience string

A custom audience to include within the token’s aud claim. Cannot be used with included_custom_audience

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.

addToAccessToken boolean

Indicates if this claim should be added to the access token.

addToIdToken boolean

Indicates if this claim should be added to the id token.

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.

includedClientAudience string

A client ID to include within the token’s aud claim. Cannot be used with included_custom_audience

includedCustomAudience string

A custom audience to include within the token’s aud claim. Cannot be used with included_custom_audience

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.

add_to_access_token bool

Indicates if this claim should be added to the access token.

add_to_id_token bool

Indicates if this claim should be added to the id token.

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.

included_client_audience str

A client ID to include within the token’s aud claim. Cannot be used with included_custom_audience

included_custom_audience str

A custom audience to include within the token’s aud claim. Cannot be used with included_custom_audience

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.

Package Details

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