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.

Its structure is in the JSON format with the following details:

{
  entries : {
    <externalSystemName> : {
      publicKey : <public key used by external system for signing in PEM format>
      permissions: <null or JSON list of Strings with permissions names>
    }
  }
}

Where:

Example of a public key:

-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0E9Zp0JNbDaOMqhZd1C+
/FdBTCjza0qXcjTYCbDUeY89qPpwN19QovmehCVGBSFzLOkltx0YmlCkaKLtzqfS
...
... (edited for security reasons)
...
fXr4+6SBmEOVa7RSzoXr3whpdMdKsIvnDCCmT++aJvHBw63ZKGKb8+ZTAXv0z3sm
LDRyhifUmEoJPGWHV6/oxZQiVRapEFe7SiVTbr2IW7OfrdE3DVrioJmATEKgVr5i
zwIDAQAB
-----END PUBLIC KEY-----

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 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"
}

Payload:

{
 "sub": "root",
 "iss": "AllowAll",
 "aud": "integration-test",
 "partition": "system"
}

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.