For a SFDC connected app (and potentially elsewhere), you can use a 3rd-party JSON Web Token for user authentication. Similarly to SAML, there is no need for hard coded per-user credentials, instead a system-to-system trust relation is established using signed tokens.
Configuring the Trust Relationship
The configuration is stored in a per-partition configuration in an advanced configuration option with the name externalJWTConfiguration. You can do the configuration in the Pricefx UI (see JWT Configuration) or you can configure the option manually as described in this section.
The value must be valid JSON: every key and string value in double quotes. The configuration has the following structure:
{
"entries": {
"<externalSystemName>": {
"publicKey": "<RSA public key in PEM format, as one line with \n line breaks>",
"permissions": ["<permission name>", "..."]
}
}
}
Where:
-
externalSystemNameis a JSON compatible name of the external system (i.e., only [A-Za-z0-9], no whitespaces, etc). This name is also used in the bearer auth header (see below). You can add as many external systems as you like, each with an individual name. -
publicKeyis the RSA public key of the external system as a JSON string. Only RSA keys in the-----BEGIN PUBLIC KEY-----format (X.509 SubjectPublicKeyInfo) are accepted. Replace each line break in the key with\nso that the key is one line in the JSON (see Prepare the Public Key). -
permissionscan be null (or omitted) – in that case the trust does not further restrict permissions (= allow all). If there is a list defined, then any API call using that token/config will only be allowed if the endpoint’s permission requirement matches the permissions listed here.
Important: This list is just an additional filter. I.e., the authenticated user as such needs to have the required permission to begin with. This setting will not add or allow anything the user could do using regular authentication. It can be used to restrict the trust relation to specific API calls only.
Example of a public key:
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0E9Zp0JNbDaOMqhZd1C+
/FdBTCjza0qXcjTYCbDUeY89qPpwN19QovmehCVGBSFzLOkltx0YmlCkaKLtzqfS
...
... (edited for security reasons)
...
fXr4+6SBmEOVa7RSzoXr3whpdMdKsIvnDCCmT++aJvHBw63ZKGKb8+ZTAXv0z3sm
LDRyhifUmEoJPGWHV6/oxZQiVRapEFe7SiVTbr2IW7OfrdE3DVrioJmATEKgVr5i
zwIDAQAB
-----END PUBLIC KEY-----
Prepare the Public Key
Pricefx accepts only a public key that starts with -----BEGIN PUBLIC KEY-----. Other formats cause every login to fail. If your key is in another format, convert it first:
|
Your key starts with |
Convert it with |
|---|---|
|
|
No conversion needed. |
|
|
|
|
|
|
|
|
|
|
|
|
Then convert the key to one line with \n line breaks:
awk 'NF {sub(/\r/, ""); printf "%s\\n",$0;}' key.pem
Example of a complete configuration value:
{
"entries": {
"SFDC": {
"publicKey": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0E9Zp0JNbDaOMqhZd1C+\n...\nzwIDAQAB\n-----END PUBLIC KEY-----\n",
"permissions": ["PRICINGFORMULA_EXECUTE"]
}
}
}
The JWT Configuration page in the Pricefx UI writes this JSON for you, so you do not need to quote or escape anything by hand.
Authenticating
Once the trust relationship is configured, you can use it to authenticate API calls. This is done by sending the signed (by the external system possessing the private key part) and compacted JWT token returned by the server in the standard Authorization HTTP header in the following form:
Authorization: BEARER <externalSystemName>;<signed JWT token>
The external system name in the header must match the name in the configuration exactly, including case. If the configuration contains only one external system, you can omit the name and the semicolon: Authorization: Bearer <signed JWT token>.
The JWT token follows standard RFC rules in terms of structure, signature, etc. Please note that only RS256 signature method is supported.
The content of the token consists of three parts with a certain structure:
Header:
{
"alg": "RS256"
}
-
algidentifies the algorithm used to generate the signature. It must always be set to RS256 – other algorithms are not supported.
Payload:
{
"sub": "root",
"iss": "AllowAll",
"aud": "integration-test",
"partition": "system"
}
-
subis the standard subject field of the JWT token. It must contain the loginName of the user. -
issis the standard issuer field of the JWT token. It must contain the external system name value (i.e., the same name as in the trust config and in the HTTP header). -
audis the standard audience field of the JWT token. It must contain the Pricefx cluster name (for example,e2e-gcp-staging). If you do not know the cluster name, ask Pricefx Support. -
partitionmust be the partition in the request URL, and the user given insubmust exist in it. -
exp(optional, recommended) is the standard expiration time. Pricefx rejects tokens after this time without any clock-skew tolerance, so keep the clocks of both systems synchronized.
Signature
The signature part is a combination of the encoded header, the encoded payload, a secret, the algorithm specified in the header – all that signed.
Troubleshooting
Every failed external JWT login returns the same response: HTTP status 401 with the error message Login failure. The response does not say which check failed. The reason is written only to the Pricefx server log. If the checks below do not reveal the problem, contact Pricefx Support with the time of the request and the partition name.
Pricefx checks the request in the following order. Go through the list until you find the cause:
-
Configuration exists and is valid JSON: The partition has an Advanced Configuration Option named
externalJWTConfigurationand its value is valid JSON with all keys in double quotes. -
Header format: The
Authorizationheader isBearer <externalSystemName>;<token>, orBearer <token>if there is only one external system. -
External system name: The name in the header matches an entry under
entriesexactly, including case. -
Public key format: The
publicKeystarts with-----BEGIN PUBLIC KEY-----and is an RSA key (see Prepare the Public Key). SSH2, OpenSSH,BEGIN RSA PUBLIC KEYand certificate formats are rejected. -
Signature: The token is signed with RS256 by the private key that belongs to the configured public key.
-
Expiration: The token has not expired (
exp). -
Audience:
audcontains the Pricefx cluster name. -
Subject:
subis present and contains the user's login name. -
Partition: The
partitionclaim matches the partition in the request URL. -
Issuer:
issmatches the external system name. -
User: The user exists in the partition and is active.
In versions earlier than 17.2, a missing or invalid externalJWTConfiguration returns a server error instead of Login failure, for example jakarta.servlet.ServletException: ... UncheckedExecutionException ... deserialization error. Check items 1 and 4 first if you see this error.
This page covers tokens issued by an external system. If you authenticate with the Pricefx token (X-PriceFx-jwt) from /login/extended or /accountmanager.getjsonwebtoken, you do not need this configuration. See Authentication.