Skip to main content

Hardcoded Claim Protocol Mapper API

The HardcodedClaimProtocolMapperHandle class extends the ProtocolMapperHandle class and provides a specialized API for managing hardcoded claim protocol mappers in Keycloak. These mappers add a hardcoded claim to tokens issued by Keycloak.

Class: HardcodedClaimProtocolMapperHandle

Constructor

constructor(core: KeycloakAdminClient, clientHandle: ClientHandle, mapperName: string)
  • Parameters:
    • core: An instance of KeycloakAdminClient.
    • clientHandle: A handle to the client where the protocol mapper resides.
    • mapperName: The name of the hardcoded claim protocol mapper to manage.

Instance Methods

create(data: HardcodedClaimProtocolMapperInputData)

Creates a new hardcoded claim protocol mapper.

public async create(data: HardcodedClaimProtocolMapperInputData)
  • Parameters:
    • data: The data for the new hardcoded claim protocol mapper.
  • Throws: An error if the protocol mapper already exists.

update(data: HardcodedClaimProtocolMapperInputData)

Updates the hardcoded claim protocol mapper's details.

public async update(data: HardcodedClaimProtocolMapperInputData)
  • Parameters:
    • data: The updated data for the hardcoded claim protocol mapper.
  • Throws: An error if the protocol mapper does not exist.

ensure(data: HardcodedClaimProtocolMapperInputData)

Ensures the hardcoded claim protocol mapper exists. If it does, updates it; otherwise, creates it.

public async ensure(data: HardcodedClaimProtocolMapperInputData)
  • Parameters:
    • data: The data for the hardcoded claim protocol mapper.

Types

HardcodedClaimProtocolMapperInputData

The input data type for creating or updating a hardcoded claim protocol mapper.

export interface HardcodedClaimProtocolMapperInputData extends ProtocolMapperInputData {
claimName: string;
claimValue: string;
}

This API provides a specialized interface for managing hardcoded claim protocol mappers in Keycloak, ensuring they are configured with the appropriate defaults for adding static claims to tokens.