All Products
Search
Document Center

Identity as a Service:Use federated credential expressions

Last Updated:Oct 22, 2026

This topic describes how to use advanced expressions for M2M federated credentials in the IDaaS built-in expression engine, and provides descriptions of the model fields and functions along with reference examples.

Basic information

The IDaaS built-in expression engine supports advanced expressions in M2M (Machine-to-Machine) scenarios. Use these expressions to write the trust conditions of a federated credential provider and the validation conditions of an application federated credential. When the target application must process additional parameters that require transformation, concatenation, or logical evaluation, expressions provide flexible configuration. An expression consists of two core components:

Component

Name

Description

Model

Client.

Client-related property data.

PKCS#7 federated credential model.

Processes credentials in PKCS#7 format.

PCA federated credential model.

Processes credentials in PCA format.

OIDC federated credential model.

Processes credentials related to the OIDC protocol.

Function

/

Represents an execution logic relationship.

Models

1. Client (client model)

In an IDaaS expression, access the properties of the Client model in the client.<fieldname> format. The following table lists the fields that the Client model supports:

Field

Data type

Description

clientId

String

The clientId of the application.

applicationFederatedCredentialId

String

The ID of the application federated credential.

activeSubjectUrn

String

A reserved property generated from the field mapping of applicationFederatedCredential. It cannot be called.

2. PKCS#7 Federated Credential (PKCS#7 federated credential model)

In the IDaaS PKCS#7 federated credential model, access the following fields in the pkcs7.<fieldname> format. This model applies to the trust condition expressions of PKCS#7 federated trust sources and the validation condition expressions of PKCS#7 federated credentials.

Field

Data type

Description

payload

object

/

data

String

The original Content extracted from PKCS#7.

jsonData

JSON object

signingTime

Long

The signature timestamp, in seconds. This field has a value only when the federated trust source is AWS.

certificates

List<CertificateObject>

The certificate chain included in the PKCS#7 signature. For the fields of the CertificateObject model, see the note at the end of this topic.

3. PCA Federated Credential (PCA federated credential model)

In the IDaaS PCA federated credential model, access the following fields through the cert object. For example, to obtain the CN (Common Name) field of the certificate issuer, use the expression cert.issuer.subject.CN. This model applies to the trust condition expressions of PCA federated trust sources and the validation condition expressions of PCA federated credentials.

Property

Data type

Description

serialNumber

String

The certificate serial number, in hexadecimal format (padded with 0 if the most significant bit is 1), all lowercase, without colons.

For example: 6d5a2816af467************f6e974f114a061e

00d******dc305a652

According to the ASN.1 DER encoding rules, the encoding of a certificate serial number must meet the following requirements:

If the most significant bit of the serial number (the most significant bit of the leftmost byte) is 1, a leading 0x00 byte must be prepended so that the value is correctly decoded as a positive integer.

  • Examples: The most significant bit of the hexadecimal value dd0ec2ccc305a652 is 1, so a leading 0x00 is required. The final encoding is:

    00dd0ec2ccc305a652

    The most significant bit of the hexadecimal value 6d5a2816af467f40d38be7280f6e974f114a061e is 0, so no leading 0x00 is required and the encoding remains unchanged:

    6d5a2816af467f40d38be7280f6e974f114a061e

  • Additional note (optional): This rule ensures the correctness of the INTEGER type in DER encoding. When the most significant bit of the first byte of an integer is 1, the integer is negative. To prevent a valid positive serial number from being misinterpreted as negative, add a leading 0x00 byte so that the value is parsed as a positive integer.

issuer

CertificateSubjectObject

The certificate issuer object: issuer.CN and issuer.C.

subject

CertificateSubjectObject

The certificate subject object: subject.C, subject.O, and subject.OU.

fingerprint

String

The certificate fingerprint, in SHA256 format, all lowercase, without colons.

certificateCaIssuerUrl

String

The issuer.

subjectKeyIdHex

String

The subject ID.

signatureOid

String

1.2.840.113549.1.1.11 (SHA256withRSA)

notBefore

Long

The start time of the certificate. Unix timestamp, in seconds.

notAfter

Long

The end time of the certificate. Unix timestamp, in seconds.

ca

Boolean

Indicates whether the certificate is a certification authority (CA) certificate. This field is an extension field of an X.509 v3 certificate, not a main certificate field.

4. OIDC Federated Credential (OIDC federated credential model)

In the IDaaS OIDC federated credential model, access the following fields in the jwt.<fieldname> format. This model applies to the trust condition expressions of OIDC federated trust sources and the validation condition expressions of OIDC federated credentials. The following table lists the main fields of the OIDC federated credential model:

Property

Data type

Description

iss

String

The issuer of the token, which is the URL of the authorization server. Access it through jwt.iss.

sub

String

The subject of the token, which is the unique identifier of the user. Access it through jwt.sub.

aud

List<String>

The intended audience of the token, usually a resource server identifier or a client ID.

Note

The aud claim supports the array format. To validate aud, write the expression as follows:

Equals(jwt.aud[0], "example_aud"), where jwt.aud[0] retrieves the first element of aud for comparison. If aud contains multiple values, such as:

{
  "aud": [
    "https://example.com",
    "https://example2.com"
  ]
}

You can use the Or( ) function for comparison, which passes the validation if any one value is equal. The expression is as follows:Or(Equals(jwt.aud[0], "https://example.com"), Equals(jwt.aud[1], "https://example2.com"))

jti

String

The unique identifier of the token, used to prevent replay.

exp

Long

The expiration time (Unix timestamp, in seconds).

nbf

Long

The effective time (Unix timestamp, in seconds).

iat

Long

The issue time (Unix timestamp, in seconds).

claims

Map

All properties.

5. CertificateObject model

The CertificateObject model is used for certificate-related validation scenarios and provides access to each certificate field. Access the following fields in the cert.<fieldname> format. This model applies to scenarios such as certificate chain validation, certificate property validation, and certificate validity period checks.

Property

Data type

Description

serialNumber

String

The certificate serial number, in hexadecimal format, all lowercase, without colons.

issuer

CertificateSubjectObject

The certificate issuer: issuer.CN, issuer.C, and more.

subject

CertificateSubjectObject

The certificate subject: subject.C, subject.O, subject.OU, and more.

fingerprint

String

The certificate fingerprint, in SHA256 format, all lowercase, without colons.

certificateCaIssuerUrl

String

The issuer.

subjectKeyIdHex

String

The subject ID.

signatureOid

String

1.2.840.113549.1.1.11 (SHA256withRSA).

notBefore

Long

The start time of the certificate (Unix timestamp, in seconds).

notAfter

Long

The end time of the certificate (Unix timestamp, in seconds).

ca

Boolean

This field is an X.509 v3 extension field. It indicates whether the certificate belongs to a certification authority (CA). The value is a Boolean (true or false).

The fields of the CertificateSubjectObject model are as follows:

Property

Data type

Description

country(C)

String

The name of the country or region, usually a two-letter ISO code. For example, "US" indicates the United States and "CN" indicates China. Multiple C values are supported, separated by forward slashes.

organization(O)

String

The name of the organization, such as the full name of a company or institution. Multiple O values are supported, separated by forward slashes.

organizationalUnit(OU)

String

The department or unit within the organization, such as "IT Department" or "Security Team". Multiple OU values are supported, separated by forward slashes: IT/fiance/HR.

commonName(CN)

String

The common name of the certificate issuer, usually used to identify a specific server or individual.

distinguishedNameQualifier

String

Used to distinguish entities that have the same name.

state(ST)

String

The state or province. Multiple values are supported, separated by forward slashes.

serialNumber

String

A unique identifier within the organization.

locality(L)

String

The name of the city or region. Multiple values are supported, separated by forward slashes.

title(T)

String

The job title or position, such as "Manager".

surname

String

The surname or name, such as "John" or "Doe".

givenName

String

The name displayed to the user, such as "J. Doe" or "John Doe".

initials

String

The initials of the name displayed to the user, such as "J" or "J.D.".

pseudonym

String

The alias.

generationQualifier

String

The generation qualifier, such as "Jr." (Junior) or "III" (the third).

domainComponent(DC)

String

The domain name component, such as "example.com". Multiple values are supported, separated by forward slashes

oidMap

Map<String,Object>

The OID map object.

Functions

For commonly used functions, see Functions.

Expression examples

To use any of the preceding models in an expression, retrieve values in accordance with JSON semantics. If a JSON key contains special characters such as ".", "-", or "_", enclose the key in single quotation marks.

Trust conditions for federated trust sources

  1. PCA

    // Get the CN field of the issuer of the certificate uploaded to PCA and compare it
    // For example, the certificate issuer is: C=cn, ST=sichuan, L=chengdu, O=example, OU=test, CN=test
    Equals(cert.issuer.CN, "test")
    
    // Check whether the certificate is a certification authority (that is, it can issue other certificates)
    Equals(cert.ca, true)
    
  2. OIDC

    // Check whether the subject in the serviceaccount OIDC token of the Kubernetes cluster is correct
    Equals(jwt.sub, "test")
    
    // Check both the issuer and the audience
    And(Equals(jwt.iss, "https://example.com"), Equals(jwt.aud, "test_aud"))
  3. PKCS#7

    If you select a PKCS#7 federated trust source, you do not need to enter a trust condition expression.

Validation conditions for federated credentials

Write the validation condition expression of a federated credential in the same way as the trust condition of a federated trust source: both retrieve the corresponding fields from the data model for validation. IDaaS provides quick configuration modes that automatically generate basic validation expressions and simplify configuration.

  1. PCA

    // When the validation condition mode is Certificate Mode and the common name (CN) entered is example, the generated expression is:
    Equals(cert.subject.CN, "example")
    
    // To use a custom expression to validate other conditions, select Client Certificate Field Expression Validation Mode
    // For example, to validate the following fields in the client certificate issuer: country, location, and province
    // For example, the certificate issuer is: C=cn, ST=sichuan, L=chengdu, O=example, OU=test, CN=test
    And(Equals(cert.issuer.C, "cn"), Equals(cert.issuer.L, "chengdu"), Equals(cert.issuer.ST, "sichuan"))
    
    // Validate the serial number of the certificate. Note: the serial number is in hexadecimal format, all lowercase, without colons. You can use functions to convert it
    // For example, the serial number shown in the certificate is 6d:5a:28:16:af:46:7f:40:d3:8b:e7:28:0f:6e:97:4f:11:4a:06:1e. Use the StringReplace() function to remove the colons. The expression is:
    // StringReplace("original string","characters to be replaced","replacement characters")
    Equals(cert.serialNumber, StringReplace("6d:5a:28:16:af:46:7f:40:d3:8b:e7:28:0f:6e:97:4f:11:4a:06:1e",":",""))
    
    // If the serial number is all uppercase, such as 6D:5A:28:16:AF:46:7F:40:D3:8B:E7:28:0F:6E:97:4F:11:4A:06:1E
    // Use the ToLower() function to convert the string to lowercase, and then use the StringReplace() function to remove the colons
    Equals(cert.serialNumber, StringReplace(ToLower("6D:5A:28:16:AF:46:7F:40:D3:8B:E7:28:0F:6E:97:4F:11:4A:06:1E"),":",""))
  2. OIDC

    // When Kubernetes Mode is used, the namespace entered is test and the service account entered is test
    // The automatically generated expression is:
    And(Equals(jwt.claims.'kubernetes.io'.namespace, "test"), Equals(jwt.claims.'kubernetes.io'.serviceaccount.name, "test"), Equals(jwt.sub, "system:serviceaccount:test:test"))
    
    // When Subject Identity Mode is used, the subject identity entered is https://sub.example.com
    // The automatically generated expression is:
    Equals(jwt.sub, "https://sub.example.com")
    
    // To use a custom expression to validate other conditions, select Claims Field Expression Validation Mode
    // To validate the jti field of the current OIDC token, the expression is:
    Equals(jwt.jti, "test_XXX")
    
    // If the user defines a custom field named customValue in the claims of the OIDC token and wants to validate that field, the expression is:
    Equals(jwt.claims.customValue, "XXX")
    
    // To compare whether aud is correct: aud is in array format, so you must obtain the corresponding aud value by array index for comparison.
    // (Recommended) Validate aud through the aud field of the OIDC federated trust source instead of in the validation conditions of the federated credential.
    // When aud has only one value, the expression is:
    Equals(jwt.aud[0], "example_aud")
    // When aud has multiple values, you can use the Or() function for comparison, which passes the validation if any one aud matches. The expression is:
    Or(Equals(jwt.aud[0], "https://example.com"), Equals(jwt.aud[1], "https://example2.com"))
  3. PKCS#7

    // If the current federated trust source is Alibaba Cloud PKCS#7, the selected validation condition mode is Specify Cloud Server Instance Mode, and the cloud server instance IDs entered are i-123 and i-456, the generated expression is:
    Or(Equals(pkcs7.payload.jsonData.'instance-id', "i-123"),Equals(pkcs7.payload.jsonData.'instance-id', "i-456"))
    
    // If the federated trust source is AWS PKCS#7, the selected validation condition mode is Specify Cloud Server Instance Mode, and the cloud server instance IDs entered are i-123 and i-456, the generated expression is:
    Or(Equals(pkcs7.payload.jsonData.instanceId, "i-123"),Equals(pkcs7.payload.jsonData.instanceId, "i-456"))
    
    // To use a custom expression to validate other conditions, select Signature Value Expression Validation Mode
    // For example, to validate the region-id field in the Alibaba Cloud PKCS#7 signature value, the expression is:
    Equals(pkcs7.payload.jsonData.'region-id', "cn-hangzhou")

Appendix

Available fields for Alibaba Cloud PKCS#7

Property

Type

Description

instance-id

String

The ECS instance ID.

region-id

String

The region ID.

owner-account-id

String

The Alibaba Cloud account ID.

audience

object

/

aud

String

A custom input parameter provided when the user obtains an Alibaba Cloud PKCS#7 signature. Currently, the value supports only the IDaaS instance ID, such as idaas_XXX.

signingTime

Long

The signature time (Unix timestamp, in seconds). This field is used to validate the signature time of the current PKCS#7 payload.

Available fields for AWS PKCS#7

Property

Type

Description

instanceId

String

The EC2 instance ID.

region

String

The region ID.

accountId

String

The AWS account ID.

References