Hardcoded Attribute Identity Provider Mapper
Allows for creating and managing hardcoded attribute mappers for Keycloak identity provider. The identity provider hardcoded attribute mapper will set the specified value to the IDP attribute.
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 oidc = new keycloak.oidc.IdentityProvider("oidc", {
realm: realm.id,
alias: "my-idp",
authorizationUrl: "https://authorizationurl.com",
clientId: "clientID",
clientSecret: "clientSecret",
tokenUrl: "https://tokenurl.com",
});
const oidcHardcodedAttributeIdentityProviderMapper = new keycloak.HardcodedAttributeIdentityProviderMapper("oidc", {
realm: realm.id,
name: "hardcodedUserSessionAttribute",
identityProviderAlias: oidc.alias,
attributeName: "attribute",
attributeValue: "value",
userSession: true,
extraConfig: {
syncMode: "INHERIT",
},
});
Content copied to clipboard
import pulumi
import pulumi_keycloak as keycloak
realm = keycloak.Realm("realm",
realm="my-realm",
enabled=True)
oidc = keycloak.oidc.IdentityProvider("oidc",
realm=realm.id,
alias="my-idp",
authorization_url="https://authorizationurl.com",
client_id="clientID",
client_secret="clientSecret",
token_url="https://tokenurl.com")
oidc_hardcoded_attribute_identity_provider_mapper = keycloak.HardcodedAttributeIdentityProviderMapper("oidc",
realm=realm.id,
name="hardcodedUserSessionAttribute",
identity_provider_alias=oidc.alias,
attribute_name="attribute",
attribute_value="value",
user_session=True,
extra_config={
"syncMode": "INHERIT",
})
Content copied to clipboard
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 oidc = new Keycloak.Oidc.IdentityProvider("oidc", new()
{
Realm = realm.Id,
Alias = "my-idp",
AuthorizationUrl = "https://authorizationurl.com",
ClientId = "clientID",
ClientSecret = "clientSecret",
TokenUrl = "https://tokenurl.com",
});
var oidcHardcodedAttributeIdentityProviderMapper = new Keycloak.HardcodedAttributeIdentityProviderMapper("oidc", new()
{
Realm = realm.Id,
Name = "hardcodedUserSessionAttribute",
IdentityProviderAlias = oidc.Alias,
AttributeName = "attribute",
AttributeValue = "value",
UserSession = true,
ExtraConfig =
{
{ "syncMode", "INHERIT" },
},
});
});
Content copied to clipboard
package main
import (
"github.com/pulumi/pulumi-keycloak/sdk/v5/go/keycloak"
"github.com/pulumi/pulumi-keycloak/sdk/v5/go/keycloak/oidc"
"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
}
oidc, err := oidc.NewIdentityProvider(ctx, "oidc", &oidc.IdentityProviderArgs{
Realm: realm.ID(),
Alias: pulumi.String("my-idp"),
AuthorizationUrl: pulumi.String("https://authorizationurl.com"),
ClientId: pulumi.String("clientID"),
ClientSecret: pulumi.String("clientSecret"),
TokenUrl: pulumi.String("https://tokenurl.com"),
})
if err != nil {
return err
}
_, err = keycloak.NewHardcodedAttributeIdentityProviderMapper(ctx, "oidc", &keycloak.HardcodedAttributeIdentityProviderMapperArgs{
Realm: realm.ID(),
Name: pulumi.String("hardcodedUserSessionAttribute"),
IdentityProviderAlias: oidc.Alias,
AttributeName: pulumi.String("attribute"),
AttributeValue: pulumi.String("value"),
UserSession: pulumi.Bool(true),
ExtraConfig: pulumi.StringMap{
"syncMode": pulumi.String("INHERIT"),
},
})
if err != nil {
return err
}
return nil
})
}
Content copied to clipboard
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.oidc.IdentityProvider;
import com.pulumi.keycloak.oidc.IdentityProviderArgs;
import com.pulumi.keycloak.HardcodedAttributeIdentityProviderMapper;
import com.pulumi.keycloak.HardcodedAttributeIdentityProviderMapperArgs;
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 oidc = new IdentityProvider("oidc", IdentityProviderArgs.builder()
.realm(realm.id())
.alias("my-idp")
.authorizationUrl("https://authorizationurl.com")
.clientId("clientID")
.clientSecret("clientSecret")
.tokenUrl("https://tokenurl.com")
.build());
var oidcHardcodedAttributeIdentityProviderMapper = new HardcodedAttributeIdentityProviderMapper("oidcHardcodedAttributeIdentityProviderMapper", HardcodedAttributeIdentityProviderMapperArgs.builder()
.realm(realm.id())
.name("hardcodedUserSessionAttribute")
.identityProviderAlias(oidc.alias())
.attributeName("attribute")
.attributeValue("value")
.userSession(true)
.extraConfig(Map.of("syncMode", "INHERIT"))
.build());
}
}
Content copied to clipboard
resources:
realm:
type: keycloak:Realm
properties:
realm: my-realm
enabled: true
oidc:
type: keycloak:oidc:IdentityProvider
properties:
realm: ${realm.id}
alias: my-idp
authorizationUrl: https://authorizationurl.com
clientId: clientID
clientSecret: clientSecret
tokenUrl: https://tokenurl.com
oidcHardcodedAttributeIdentityProviderMapper:
type: keycloak:HardcodedAttributeIdentityProviderMapper
name: oidc
properties:
realm: ${realm.id}
name: hardcodedUserSessionAttribute
identityProviderAlias: ${oidc.alias}
attributeName: attribute
attributeValue: value
userSession: true
extraConfig:
syncMode: INHERIT
Content copied to clipboard
Properties
Link copied to clipboard
The name of the IDP attribute to set.
Link copied to clipboard
The value to set to the attribute. You can hardcode any value like 'foo'.
Link copied to clipboard
Link copied to clipboard
The IDP alias of the attribute to set.
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Is Attribute related to a User Session.