Tag Archive for: Integration

Understanding Private Connect

Private Connect 101 and Value Proposition

What is Private Connect?

Private Connect provides customers a fully-managed, bi-directional, private connection between their Salesforce tenants and their Amazon Web Services (AWS) account. Customer can easily connect their Salesforce apps and processes to resources in their Virtual Private Clouds (VPCs) running on AWS using Amazon’s PrivateLink for more secure API integrations. All traffic is routed over a dedicated connection without any traffic or customer VPCs ever being exposed to the public internet.

Why (or when) would customers want to use Private Connect?

Regulated customers and partners building enterprise applications across multiple public clouds and data centers need to do so over a secure and dedicated connection to mitigate the risks associated with exposing their data to the public internet. Avoiding the public internet can reduce the compliance/audit burden on customers significantly.

Private networking allows customers to isolate sensitive resources on AWS—so they can’t be subject to a DDOS attack—while still providing a means for them to connect to Salesforce. Some customers have deployed complex, messy workarounds to keep traffic private; these can be decommissioned once Private Connect is in place.

Customers can place some of their computing resources or assets (i.e. data) within a Virtual Private Cloud (VPC) on AWS. This is analogous to keeping them isolated on an “island” for safety reasons. The “island” has no internet access, but Private Connect helps reach the resource by “digging a tunnel” and delivering a private connection.

With Private Connect, customers can leave their VPCs on a private subnet rather than expose them to the public internet. The setup assumes the AWS account already has the VPC (virtual private cloud) configured, including NLBs (network load balancers), private subnets, and required security groups. If that’s not in place, refer to the AWS documentation or engage the AWS account team (who can get a solution architect involved). Salesforce does not offer advice on AWS network architecture.

What are the top use cases for Private Connect?

  • Call out from Salesforce to a custom app/endpoint on AWS
    • Example: check that a given item is in stock before selling it to a customer by calling out to the inventory system on AWS
    • Call out to AWS endpoints to bridge to legacy infrastructure in banking or health care
  • Running jobs on AWS that load data in through Salesforce APIs, or retrieve data
    • Example: funneling Leads into Salesforce from third parties
  • Use Salesforce solutions like Data Cloud and CRM Analytics to process data hosted on AWS
    • Create dashboards in CRM Analytics using data in a Snowflake tenant hosted on AWS
    • Leverage data in Redshift or Snowflake in omni-channel marketing via Data Cloud
  • Integrating Salesforce with third-party apps running on the customer’s AWS account
    • Example: document management via FileNet
    • MuleSoft can also be deployed to a customer’s AWS account to solve integration use cases
  • Access to on-premise application systems such as IBM AS/400 via Amazon DirectConnect

Is Private Connect available now? If so, which geographies are supported?

Yes! Private Connect launched on July 2020, and is available for use connecting to more than a dozen AWS regions. In theory, customers can connect to other regions by “peering” traffic on the AWS side. We can’t provide detailed guidance on how to set this up, so we strongly recommend customers get help from AWS if they want to use an advanced approach like that.

The back-end infrastructure for Private Connect is part of Hyperforce itself, so Hyperforce has to be online in a given region for Private Connect to be available. If you’re curious when a given region will be available, contact the Hyperforce team. When Hyperforce becomes available in a given region (e.g. Ireland or Switzerland), then shortly afterwards the infrastructure for Private Connect becomes enabled in that location.

What types of companies or organizations will find Private Connect particularly appealing?

We see higher levels of interest from those in regulated industries like Financial Services and Health Care who need PCI or HIPAA compliant secure connections to carry their API traffic. Those in the public sector can also leverage Private Connect in GovCloud.

Broadly speaking, if a customer bought Shield, that indicates they value security and should consider Private Connect for their integrations.

What is the key value proposition for Private Connect?

  • Keep Communications Private and Secure: Private bidirectional connections between Salesforce and AWS make it such that valuable AWS resources aren’t exposed to the public internet can’t be attacked by DDOS.
  • Reduce the Compliance and Audit Burden: Integrations that avoid the public internet face less regulatory scrutiny.
  • Improve Productivity for Network Teams: Save time and effort in the setup, configuration and maintenance of private connections with the point-and-click setup UI. Decommission your legacy workarounds.

Product, Technical & Support

How does Private Connect work?

Salesforce has worked directly with Amazon to connect our network to theirs, powered in part by an AWS offering called PrivateLink. This connectivity enables API calls to go from Salesforce to AWS (and vice versa) without using the public internet.

Salesforce manages what we call a Transit VPC in each supported AWS Region. Customers create a PrivateLink from the Transit VPC to their target VPC, and everything “behind” the Transit VPC is managed and secured by Salesforce. This works whether your org is hosted in first-party data centers, or Hyperforce.

For security reasons, we cannot explain every detail of how the product’s infrastructure operates—but this gives you an overview. The rest of this guide provides certain additional details.

How do I set up connections? Do they go both ways?

The setup UI for Private Connect provides a point-n-click experience that creates and provisions the required PrivateLinks on the customer’s behalf. Setup allows you to create two kinds of private connections:

  • Outbound: traffic originates in Salesforce, goes out to AWS
    • Useful for Apex callouts, External Services, Flow Actions, External Objects…and more, as we expand our platform
  • Inbound: traffic originates in AWS, comes in to Salesforce
    • Make calls to any of our typical APIs (e.g. REST, Bulk) through the connection

The following diagrams illustrate the most common use cases. Outbound connections are typically used when Apex or Flow needs to reach out to a protected API endpoint isolated within a VPC.

Outbound connection in Private Connect

Outbound connection in Private Connect

Inbound connections are commonly used to allow services, apps or “jobs” running inside a VPC to access Salesforce’s APIs, either to load data or invoke actions on our platform.

Inbound connection in Private Connect

Inbound connection in Private Connect

Can I connect multiple VPCs to my org?

Yes, though that will require additional licenses of Private Connect. Each VPC requires a distinct connection, which incurs costs for Amazon, Salesforce, and the customer.

Can I connect multiple Orgs to a single VPC?

Yes, though that will require licenses for Private Connect in each org. Each org needs a provisioned connection to the VPC in question.

Can I connect to other AWS services outside my VPC?

You will be able to connect to any AWS service that works with over PrivateLink. Note that many—but not all—AWS services support PrivateLink. Some of the popular options include:

  • S3
  • Athena
  • SageMaker
  • Lambda
  • Textract
  • EC2
  • Redshift

Amazon continues to add to this list over time, both by adding new services and making existing services compatible with PrivateLink.

Private Connect creates a connection to a given VPC to avoid the public internet, and from there AWS can route the request/traffic to these services that they manage (on your behalf).

Outbound connection in Private Connect to services managed by AWS

Outbound connection in Private Connect to services managed by AWS

Does Private Connect make the connection between Salesforce and AWS faster?

Improving data transfer speeds is not the focus of Private Connect; refer to the value propositions listed immediately above. Private Connect can, however, lead to faster connections in the case where a customer has deployed complex, clunky workarounds on their own in an attempt to deliver equivalent security benefits. If they deploy Private Connect and decommission what they had before, they may see faster speeds when compared to their custom build.

Private Connect will not be faster than using the public internet, though. Both Salesforce and AWS have very fast pipes to the internet, and leveraging those is usually the best in terms of raw speed. That said, slowing things down slightly for better security is usually worth the trade-off, similar to how employees use a VPN to connect from their laptops to servers behind a firewall. A minor trade-off in performance for vastly increased security is a wise decision.

The public internet has slightly higher transfer speeds than Private Connect.

The public internet has slightly higher transfer speeds than Private Connect.

Does Private Connect support Heroku (since that runs on AWS)?

Customers can connect their own VPC to a Heroku Private Spaces (in this manner) using PrivateLink. Contact the Heroku team if you have further questions.

Does Private Connect support MuleSoft?

It depends how MuleSoft is hosted. MuleSoft CloudHub is MuleSoft’s managed SaaS offering, and unfortunately it does not support Private Connect as of this writing. Check with the MuleSoft team for updates on this.

MuleSoft has the ability to be deployed inside a customer’s VPC, however. In that scenario, connecting to it would be the same as any other connection.

Can I use Private Connect with Amazon AppFlow?

Yes! In fact, Amazon has built Private Connect support directly into AppFlow’s setup UI. If a customer has a license for Private Connect, AppFlow can provision a working connection on the customer’s behalf and use it to move data in and out of Salesforce. It’s great from an ease-of-use perspective, though if you have an issue with the AppFlow connection, you’ll need to get support primarily from Amazon. (Amazon manages the connections, and customers cannot manipulate them directly.)

Does Private Connect support Hyperforce?

Yes. Both Hyperforce and first-party hosted orgs can use Private Connect. Creating a private connection works the same in both. When an org is migrated to Hyperforce, the back-end architecture of Private Connect makes that transition seamless—there’s nothing to worry about!

You can contact the Hyperforce team if you have questions or concerns about what’ll happen when your customer’s org migrates to Hyperforce.

If an org is on Hyperforce, can you explain why Private Connect is still needed? Why can’t they just use AWS PrivateLink?

It’s true that if a customer’s org is on Hyperforce, API integration traffic between their org and their own AWS resources will not leave AWS’s network. But if the AWS resources are isolated in a VPC (to prevent DDOS), Private Connect is still needed to establish private connectivity to the VPC that contains the Salesforce org.

Customers can, in theory, deploy other protections for services or data exposed to the public internet. That said, the use of such protections create a non-trivial maintenance burden for the customer, and their effectiveness is debatable. Private Connect is designed to avoid this maintenance burden.

Advantages of Private Connect on Hyperforce

Advantages of Private Connect on Hyperforce

Some people inquire about the ability to use AWS PrivateLink to connect “directly” to the VPC containing their Hyperforce org. Salesforce has always delivered fully managed SaaS offerings, and there no plans to allow customers wire into our network infrastructure at such a low level. That would introduce significant security concerns, and would not support org migration.

Private Connect handles all the network management behind the scenes, in the same way that Salesforce manages the data and file storage underpinning customer orgs.

Does Private Connect support sandbox orgs?

Full and Partial Copy sandboxes are supported with Private Connect, but not Developer or Developer Pro sandboxes. By using the “Match Production Licenses” feature in their sandbox, the customer is able to get the same number of connections in their sandbox as in their production org. That means sandbox testing is typically free of charge.

You may be wondering what you can do with Private Connect in a Developer or Developer Pro sandbox, knowing that working connections can’t be provisioned and established. Here’s the answer: Dev and DevPro environments can be used to create an (inactive) placeholder connection which can be pushed to production via packaging or other means. This benefits organizations that look to minimize making configuration changes directly in a production org.

Note: Sandbox copies will not copy over existing connections from the parent production org.

What’s the best way to test Private Connect in a sandbox?

Whenever possible, customers should validate their connectivity approach in a sandbox before working in production. That implies that the Salesforce sandbox is connected to a non-production environment in AWS e.g. an “integration” or “staging” environment.

Does this support the EU Zone (restricted operating region)?

Yes, it’s been tested and confirmed as of March 2023.

What are the limitations of Private Connect?

Check out the Considerations public help document for more info. You’ll need to make sure Private Connect works in the geographical region you’re targeting.

Outside that, there is one notable limit relating to outbound connections (described in the next section).

Hard limit in outbound connections

Salesforce limits the amount of outbound traffic we will process through a private connection. In this context, “outbound” refers to data sent or fetched by Apex code, Flow, or External Services as part of an outbound call to a customer’s AWS account. Our code will not process more than 56.48 GB of data per hour in this manner.

When the limit is reached, the code does not pull through any more data, and throws an error. To avoid problems, use the Limits API and query the PrivateConnectOutboundCalloutHourlyLimitMB value to keep an eye on how much data has been used.

There is no “grace period,” so no other outbound traffic will pass through until the top of the hour when the counter is reset. Purchase additional data add-on packs to cover the usage required by your applications and use cases.

Note: Bear in mind that outbound traffic in Private Connect typically boils down to using Apex to either “push” data out to another endpoint, or “pull” it into CRM from the outside. It’s likely some other platform limit (e.g. Apex governor limit) would be reached long before an Apex method loads more than 50 GB of data into CRM in a single hour. Consider a different architecture less reliant on Apex code if you’re planning on moving that much data in or out of CRM with such high frequency.

Contractual limit for inbound connections

If the customer pulls data out of Salesforce via our APIs or tools like Amazon AppFlow, that is not affected by the outbound limit described above. When we say “outbound,” we’re referring to requests that originate in Salesforce and go out to another system.

What we consider “inbound” traffic also has a limit of 56.48 GB per hour, but that is enforced by the contract the customer enters into with Salesforce. It is not a “hard” technical limit; processing would continue if, in theory, this limit was exceeded. That said, Salesforce reserve the right to change the technology and put “hard” limits in place in the future.

Customers pay for API usage, so that offsets the costs borne by Salesforce. More to the point, our APIs can handle extremely high volumes of traffic, so we don’t need a limit like this to protect this aspect of our infrastructure.

What notable offerings are not supported by Private Connect?

  • Tableau
  • Marketing Cloud
  • Commerce Cloud
  • Event Relay (integration with AWS EventBridge)
    • Workaround: Amazon AppFlow can be used for eventing, and it supports Private Connect
  • Apex Continuations
  • Provisioning of connections in Developer Sandboxes, Developer Pro Sandboxes, Scratch Orgs, Developer Edition orgs

What compliance certifications is available with Private Connect?

Private Connect is included in our latest PCI Attestation of Compliance (AOC) and compliant in the following:

  • ISO 27001, 27017, 27018
  • SOC 2 Type II
  • ASIP Sante HDS
  • NEN 7510
  • PCI DSS

Check our compliance web site for the latest information. Additionally, Private Connect is now also certified for public sector (GovCloud) use.

Is Private Connect a VPN?

Private Connect is not a VPN, though, behind the scenes, Private Connect sets up VPN-like secured tunnels to ensure that the traffic is kept private, secure and compliant. A key advantage of Private Connect is how it handles all the complexities around security controls and enables our customers to set up the secured connectivity through a point-and-click UI.

Does Private Connect use IPSec?

Yes, Private Connect uses IPSec tunnels between the transit VPC and Salesforce org.

What type of encryption does Private Connect Support for the IPSec tunnel?

In addition to encryption at the TLS layer, Private Connect support IPSEC encryption for traffic between transit VPC and Salesforce orgs (at layer 3). We use Advanced Encryption Standard (AES) in Galois/Counter Mode (GCM) to encrypt traffic.

How does disaster recovery (DR) work?

Private Connect implements a 3 AZ (Availability Zone) design and uses redundant IPSec tunnels to connect between sites. Also, if the customer org migrates to a new DC for DR, the traffic is automatically routed to the new site.

Does Private Connect move data between a Salesforce org and AWS, like MuleSoft, AppFlow, Glue, or other ETL tools?

No. Private Connect only establishes the tunnel; running integration traffic through the tunnel needs to be handled by some other product or feature set.

Since Salesforce is multi-tenant, how do you keep traffic separate on the Salesforce side so that Org/customer A and Org/customer B don’t overlap inappropriately?

It’s true that the Transit VPC is shared, but it has dedicated Private Link endpoints per customer that resulted from creation actions by that customer in their org. Subsequently, only a Private Link created for the org can be associated with a Named Credential for the org. When the named credential is used in an outbound callout, it will result in the outgoing HTTP request only traversing the associated PrivateLink created by the customer at the Transit VPC.

Are user sessions supported over Private Connect?

No, currently they are not supported. The intended use case for Private Connect is API integrations.

How can a customer connect from on-prem to their Hyperforce org using Private Connect?

Customers can build connections from their on-prem infra to their own VPC in AWS via AWS Direct Connect and then use Private Connect to reach their Salesforce org. Refer to this article for more details.

Is there another option besides Private Connect for private communication from a customer VPC to a Salesforce org?

As of this writing, there is no other offering, feature or SKU that delivers private connections to our infrastructure besides Private Connect. Customers may be able to keep other network traffic private using other AWS network tools, but there’s no other way to bridge into the infrastructure that Salesforce manages.

Does Private Connect use certificates or authentication?

Private Connect uses Advanced Encryption Standard (AES) in Galois/Counter Mode (GCM) (AES-GCM, in short) to encrypt traffic between sites and the certificates are rotated periodically.

That said, it is not required that customers use certificates to take advantage of Private Connect. Private Connect only provides the network route, and many types of authentication can be applied to API traffic through the tunnel.

For example, When calling out from Salesforce to a service managed by Amazon (e.g. Athena or Redshift), the AWS Signature V4 protocol would be used. If the callout is to a custom service (e.g. Lambda or EC2), customers might leverage OAuth, API keys, or other authentication methods.

Since the route is private, customers can, in theory, avoid implementing authentication on custom endpoints. However, this is not recommended.

Can I use Private Connect with CRM Analytics?

Yes! Refer to this section of the CRM Analytics documentation for details.

Can I use Private Connect with Data Cloud?

Yes! Refer to this section of the Data Cloud documentation for details. Note that Data Cloud has a different implementation and approach to pricing, so the information below on Pricing & Limits does not apply.

Pricing & Limits

What is the pricing model?

It’s useful to imagine a cell phone as an analogy. There’s a cost for the “line” (connection), and that includes a default allotment of data. Additional data can be purchased as well. Contact your account rep for specific price quotes.

Each license includes both 1 outbound and 1 for inbound connection, as well as a data transfer allocation of 5GB per day (shared by all connections in the org). Each add-on data pack adds an extra 5GB per day.

What are the limits?

Refer to the section above for a discussion of inbound and outbound limits.

Links and Resources

Understanding Named Credentials

Synopsis

Named Credentials allow Salesforce developers and administrators to specify the URL of an outbound HTTP call and its required authentication parameters in one definition. By capturing this in a declarative manner, you don’t have to worry about the authentication protocol implementation, endpoint allowlisting, or token storage. Trailblazers can focus on their Flows or Apex code and let the Salesforce platform handle the rest.

The remainder of this article goes into additional detail on the different aspects of this feature set and deepen your understanding. Think of it like a director’s commentary to a movie; not strictly required, but available for those that want a deep dive.

Origin

The Apex programming language has had HTTP callout capability for quite a while, and, in the early years, administrators needed to specify which endpoints can be referenced in callouts by defining Remote Site Settings. This is an allowlisting construct which forced administrators to explicitly take action before code in their org could call out to a remote system. (That notion of explicit action persists to this day, but in a different form.)

The popularity of OAuth caused us to reevaluate this problem space, since OAuth’s browser flow is a multi-step process that is difficult to manage in Apex with a high degree of trust. This combination of factors prompted the team to combine the endpoint definition with built-in authentication protocol support—and thus, Named Credentials was born.

Capabilities

Named Credentials includes many capabilities; what follows is a description of each one.

Auth Protocol and Token Management

Named Credentials handles the handshaking between Salesforce and the remote identity provider or token endpoint. This is more than just a single OAuth implementation; there are multiple variants under the OAuth standard, as well as completely different auth approaches like AWS’s Signature V4, API keys, JWT, and Basic Auth. We keep up with these specs, as well as the ways in which major vendors have chosen to implement them.

We also handle encrypted token storage and refreshing, so your application can wash its hands of that concern and never touch a sensitive value. It’s wise to consider these tokens as “radioactive” and not handle them any more than necessary.

Endpoint Definition and Allowlisting

By defining the target endpoint in a Named Credential, you can allow administrators to adjust it by keeping it out of your code. This gives you more flexibility when it comes to production deployments, keeping your code cleaner and less likely to fail audits.

Furthermore, Salesforce administrators can control which remote endpoints their orgs are allowed to call; this has always been an element of trust supported by the Salesforce platform. But when the endpoint is defined in a Named Credential, this is handled automatically.

Private Routing

Highly regulated industries like financial services and health care often prefer to route network traffic privately so that it doesn’t traverse the public internet. Named Credentials supports this by leveraging Private Connect, which allows integration traffic between a Salesforce org and an AWS account to avoid the internet. Salesforce and AWS have worked together to bridge our networks together to deliver this capability.

Bear in mind there’s no other way to achieve private routing in your callouts besides using a combination of Named Credentials and Private Connect. You define the target endpoint in a Named Credential, and also specify the Outbound Network Connection that should be used to route that call. If you make the callout in “raw” Apex code, it will be routed over the public internet.

Configuration API

While Named Credentials support the Metadata API, this can only be used to move some configurations between orgs. Unfortunately, you can’t use it move any shared secrets like API keys between your orgs, because that would involve retrieving the secret value from the org in clear text (before deploying it to the target org). You also can’t package these secrets, for the same basic reason.

To close this gap, we have a configuration API, available in both Apex and via REST (as a Connect API). You can use this API as a control plane to create and manage credentials, enabling what you might call infrastructure-as-code or policy-as-code. This new API gives you different options to solve these issues, as well as others we haven’t foreseen regarding setup. You can write code against this new API and blend it into your CI/CD pipeline.

Refer to our packaging guide for details on what you can package, and where you’ll need to use the API to close any remaining gaps.

ISV Support

It’s worth reiterating that the configuration API supports creating Named Credentials from Apex code, which is useful for ISVs that want to build a custom setup experience for administrators installing their managed package. We have a developer guide with Apex samples devoted to this topic.

Note that credentials created in this manner are attributed to the namespace of the managed package that created them, but are disabled by default. An administrator needs to explicitly enable them for callouts using a toggle switch.

As of this writing, Apex can only be used to create Named Credentials—not edit or delete them. We plan to address this soon, but when we do, any updated credentials will be left in a disabled state that requires administrators to turn them back on manually. This prevents a nefarious ISV from redirecting their endpoints from a trusted one to one that an administrator hasn’t seen.

Granular Principals and Permissions

Named Credentials supports robust security in multiple ways. First, explicit access is required to use the Principal in a credential—the identity of the caller in the external system—for a given callout. (AWS also uses the term Principal to represent the same idea.) Many times, this identity is an “integration user” or “service account” that does not correspond to an individual human being. Principals like that typically hold an API key or other secret, for example. The permissions make it explicit that a given User has been granted access to that key/secret—not in its raw form, but usable within the context of a callout. The callout will be blocked if the calling user hasn’t been granted permissions to the Principal.

Users need permissions to make callouts using a certain Principal. It’s similar to how we added the requirement a few years ago that users need explicit permission to run an Apex class. (A key principle for us at Salesforce is that everything is secure by default.)

Additionally, we allow multiple Principals to be associated with a given credential. Service Cloud agents, for example, might have read access to data in a remote system, whereas Service Cloud managers also have the ability to delete records in that external app. If a single User is granted access to multiple Principals for the same credential, there’s a precedence that can be applied to decide which one to use. Essentially, admins set a numerical order using the Sequence Number.

Approximating Record Sharing

The use of different Principals opens the door to external data with different levels of access, almost like record sharing in Salesforce. If a given endpoint can return different results with different user context, we want to enable access that’s as fine-grained as the endpoint allows.

Even though most remote systems only support broader “roles” like “Sales” vs. “Marketing,” major vendors like AWS do in fact offer very fine-grained access controls, and we encourage customers to take advantage of them to the fullest extent possible. That way, the Salesforce “client app” has minimal, optimized access to the remote system. We enable this via support for AWS’s IAM Roles Anywhere, dynamic scopes in OAuth, and more.

Extensible Architecture

This is a robust subsystem with a lot of “headroom” for future growth. We are committed to solving for as many different variations of authentication challenges as we can reasonably support across our many thousands of customers.

Rationale: Why not “roll my own?”

It’s possible for you to write your own Apex code to handle authentication handshakes, but it’s a bad idea. From the security perspective, you’d need to figure out where to store the various tokens securely—but pass it to different user contexts at the right time to perform the callout successfully. It’s easy to mishandle this and create a vulnerability. Other major vendors like Google also encourage developers to use well-debugged libraries to tackle this task.

From the productivity perspective, the less code you have to write and maintain, the better. Let us handle it and stay focused on what’s unique about your application. Why do undifferentiated work?

Expanded architecture: why the change?

In recent years, we’ve expanded the architecture to prepare for future growth and deepened support for other protocols like AWS SigV4, API keys, and JWT with custom claims. We’ve also added a configuration API to make it easier to automate the deployment of credentials across environments.

As we built support for this myriad of options, we came to a point where we could no longer squeeze all the configuration settings for the entire subsystem into one database table. We would’ve needed something like Record Types, but unfortunately that doesn’t exist for metadata objects. Hence, there are multiple objects under Setup you’ll need to configure. Read on for an explanation of the different parts.

Understanding Named Credentials vs. External Credentials, Permissions, and more

One change we made as part of the recent architecture expansion is to capture the endpoint and the authentication details via separate (but related) objects under the Setup menu: a Named Credential, and an External Credential. In the case of OAuth’s common browser flow, you’ll also need an External Auth Identity Provider to specify additional configuration parameters. (More on that below.)

The endpoint is still defined in the Named Credential, which now has a lookup to what we call an External Credential. We moved the authentication configuration to this new object; it holds settings for which protocol you’re using (OAuth, JWT, etc.) and the parameters required to make that callout successfully on your behalf. Separating the two objects allows the same auth config to be used for multiple endpoints. For example, you might authenticate against Google’s OAuth service, and then make calls to both the Google Drive API and the Google Calendar API with the same token.

Aside: External Auth Identity Providers

Developers and system administrators often face hassles when integrating enterprise systems due to those systems exhibiting non-standard behaviors. This is extremely common; many major vendors deviate from the OAuth spec in one way or another. To cope with this issue, we’ve split out OAuth configuration even further into an External Auth Identity Provider with a set of Custom Request Parameters. This allows you to add headers, query string parameters, and more to the handshake with the identity provider.

It’s worth lingering on this point for additional clarity. One reason many widely-used systems do not conform strictly to the OAuth specification is that they’re SaaS apps with an element of multi-tenancy; many customers share the same API and infrastructure. So when an application connects to that API, the API demands that clients specify which tenant they are acting on behalf of—and there any many different ways to do this. Some apps have a Salesforce-style My Domain URL, but others might simply expect a string value in a special header. Unfortunately, the OAuth spec does not cover this, so many vendors handle it in slightly different ways.

Due to this divergence of behavior, you’ll often find that you need to add a custom parameter to the query string or as a specially-named header. This is where Custom Request Parameters are useful; you can add parameters to query, HTTP header, or request body for the token request or refresh request. (Typically, the token request and the refresh request will have matching parameters—but you never know!) You can also add query parameters to the authorize request, which tacks them onto the URL users visit to log into the external system.

You may also need to add headers that are part of the HTTP spec to ensure that the IDP’s endpoint is returning information in the format Salesforce expects (JSON). This end-to-end example uses GitHub to show this in action; you can see all the different parts of the Named Credentials stack working together.

So, to recap: because OAuth is both commonly used but requires non-standard configuration, an External Auth Identity Provider is required to capture the additional configuration. An External Credential has a Lookup to an External Auth Identity Provider to reflect this. If the external system deviates from standards so wildly that configuration parameters aren’t enough to get authentication working, you can still use an Auth Provider along with a custom plugin written in Apex. External Credentials can look up to either an External Auth Identity Provider or an Auth Provider, thus providing the fullest range of solutions.

Generally speaking, we recommend using an External Auth Identity Provider along with Named Credentials to achieve integration via OAuth. External Auth Identity Providers are friendlier when it comes to packaging, and offer slightly stronger security by way of PKCE support and suppressed display of the client secret.

Note: the means by which developers and administrators make callouts has not changed. For example, the syntax used in Apex to refer to a Named Credential is the same—even though we have expanded the underlying architecture.

These objects work together to deliver the benefits of Named Credentials, while also supporting new use cases. We’ll use an extended analogy to explain the different pieces.

Analogy: Driver’s License and Passport at the Airport

In the United States, most adults present their Driver’s License when asked to verify their identity. This single ID card enables you to access many different resources and services. You include this with your paperwork when opening a bank account. You submit this when registering to vote. And you can use it when checking into a flight at an airport.

Each one of those different resources or services would map to a Named Credential, and you only need one External Credential to access them all. We allow External Credentials to be reused so they don’t have to be duplicated, since doing so is not a best practice from a security standpoint.

Not everyone has a Driver’s License, of course. Only those who’ve passed the test and meet other criteria re: age and physical capability have permission to drive. In Salesforce, this is represented by Permission Sets, and External Credentials are tied to Permission Sets to signal that a given User is allowed to utilize them. (We’ll take a break from the analogy to clarify that this permission check happens at runtime, right before Salesforce makes the HTTP callout on the User’s behalf.)

The convenience of a single ID card is obvious, but we also see potential issues. What does being a safe driver have to do to with traveling by plane—or voting, for that matter? For air travel, it’s better to have a passport. With that form of identification, you can fly to foreign countries and (optionally) save time via programs like Global Entry and TSA PreCheck.

A driver’s license and passport are both state-issued IDs, and there are others like military IDs. So for the sake of this discussion, we might say that U.S. airports have a “State-Issued ID protocol” with its own processes, enforcement, and evolution. This is analogous to an authentication protocol like OAuth 2.0 or AWS’s Signature Version 4. The protocol has an interrelated set of rules and processes that dictate how the verification will work—and they change over time. In the case of U.S. airports, we’re in the middle of a transition from driver’s licenses to the Real ID program (as of this writing). You can think of this as an upgrade to the State-Issued ID security protocol, which deprecates support for simpler forms of identification.

For the time being, travelers can bring either a passport or a driver’s license to the airport to get through security. In Salesforce, we represent this by allowing multiple Principals for a given External Credential, one of which provides more access than the other. (A driver’s license can’t get you into a foreign country, but a passport can.)

Diagram showing key terms used in Named Credentials
Diagram showing key terms used in Named Credentials

Here’s how we might depict this in the example of the airport and other services:

Diagram showing key terms used in Named Credentials, using airport security as an analogy
Diagram showing key terms used in Named Credentials, using airport security as an analogy

The Moment of Authentication

As you approach the airport, a passport or driver’s license isn’t enough to get you into your seat on the plane: you need a boarding pass. For this discussion, let’s assume you walk up to the counter and check in with an agent. When you give the agent your ID, they authenticate you, checking that the ID is valid (not expired or forged) and represents you (versus someone else). Inherent in this transaction is a request to access a certain resource (a seat on the plane). If all that goes well, they hand you the boarding pass, which will get you access to the desired resource when you’re at the gate.

This critical moment is worth more examination. Most integrations require a two-step process (like the airport) wherein Salesforce presents the credentials (ID card), and in exchange we receive an access token we’ll use down the line. This initial exchange might fail, and the most common reason is that the credentials are invalid or expired. If your ID or passport is expired, the agent check-in desk can’t trust that you are who you say you are—and they won’t give you a boarding pass.

Sidebar: HTTP Error Codes and Token Refreshes

When the callout from Salesforce can’t be authenticated due to invalid or expired credentials, the external system should return an error with a status code of 401. Some systems don’t follow the standards and return a different status code like 400 or 403, which is not correct. A 403 should be reserved to communicate that the identity of the caller is valid, but the external system knows that the caller in question should not be given access to the requested resource.

Interestingly, this is how the Salesforce API works; you may have established your identity correctly, but if you attempt to read a record that you’re not authorized to access, you’ll get a 403 returned. In our airport analogy, I can present a valid ID, but if I purchased a seat in Coach, I won’t be allowed to access the First Class cabin. My identity has noting to do with it; identity is not access. I’m also not allowed to access the cockpit and fly the plane.

When Salesforce receives a 401, we return to the correct endpoint to “refresh” the token by presenting the credentials again—yielding a new token. The Named Credentials subsystem will then attempt the callout again, with an updated token. If Salesforce receives a 403, some other security setting should change in the external system to grant the principal the correct access to the target resource. Until that happens, API callers won’t be able to tell the difference between insufficient access rights and expired authentication.

We recognize that Salesforce administrators often have no control over how external APIs work. Hence, we’ve added a setting to External Credentials called Additional Status Codes for Token Refresh to allow status codes besides 401 to trigger Salesforce to obtain a fresh token. If, for example, the system in question returns a 403, you can simply enter 403 in the text box for that configuration. You can also enter a comma-separated list of multiple response codes; check the documentation on External Credentials for details.

Understanding User External Credentials

Now that you’ve authenticated, you’ve got your boarding pass—which will be critical for the future moment at the gate. In a system integration, Salesforce stores the returned access token securely in the User External Credential object. These tokens expire, and the Named Credentials subsystem handles the refresh process automatically. If Salesforce needs access to the same resource again, we’ll overwrite the old token with the new one.

Note that User External Credential is a data object, not a metadata object. End users who make callouts at runtime will need some access to this object via their Profile or Permission Sets. If you create a new Permission Set, it will have access to this object by default; that’s a convenience we have put in place to save administrators some time and hassle. That said, you can turn that off and grant access in your own way, if you prefer. Our recommendation is to create new, fine-grain Permission Sets for specific external systems that can be bundled into Permission Set Groups. Granting broad access at the Profile level makes it easy to open up “too much” access.

Since User External Credentials are data, they can’t be packaged; this is benefit that avoids the security risks inherent in moving it between environments. To be clear, these sensitive values like access tokens and API keys will not be moved from production environments to sandboxes during a sandbox refresh.

It’s also useful to bear in mind that an in an org with thousands of users, Salesforce may need to store tens of thousands of access tokens. There generally aren’t tens of thousands of metadata records in an org—you’re not likely to have >10,000 Flows or Apex Classes—so we store this as data to make internal operations more efficient.

Diagram showing key terms used in Named Credentials, including User External Credentials
Diagram showing key terms used in Named Credentials, including User External Credentials

Using our airport analogy, User External Credential would be analogous to a purse or wallet that holds your boarding pass: don’t forget it! You may need to manage access to this object carefully; this article explains when different levels of access to that object are needed.

Diagram showing key terms used in Named Credentials, with User External Credentials as a purse or wallet
Diagram showing key terms used in Named Credentials, with User External Credentials as a purse or wallet

Note: If your configuration includes Guest Users, bear in mind they have a unique Profile. If unauthenticated Guest Users are using functionality that makes callouts, you’ll need to grant explicit access to the User External Credential object as part of that Profile. This article in the documentation describes what level of access is needed, depending on the authentication protocol.

Accessing the Resource (Finally!)

You’ve made it to the gate and are ready to board. You present your boarding pass, walk onto the plane, and take your assigned seat. Hooray! You finally made it!

Diagram: using a passport to board a commercial flight successfully
Diagram: using a passport to board a commercial flight successfully

In terms of Named Credentials, Salesforce makes the callout to the target endpoint, and presents the access token along with the request to read a given piece of data or invoke an operation. Access is granted, and we receive the appropriate response.

Certificates

In the analogy above re: a driver’s license or passport, those IDs are similar to a certificate in Named Credentials. A certificate asserts the caller’s identity, but is issued by a trusted, neutral authority separate from both Salesforce and the target external system. Contrast this with a password, which comes with no such additional assurance. My driver’s license was issued by the state of Illinois. A certificate in a system integration might be issued by a company like DigiCert or GlobalSign.

The external system dictates whether or not certificates need to be used, and Named Credentials supports their use when calling the target endpoint. For better or worse, certificates can’t be packaged (as of this writing). This is likely due to the sensitivity in widely distributing a trusted identity. Factor this in when you’re configuring Named Credentials in your org.

Having Trouble with Permissions?

The legacy iteration of Named Credentials did not have any access controls, and we wanted to improve this when we revamped the architecture. In particular, here are some things you should watch out for:

  1. Callouts will fail if the calling user doesn’t have permissions to the appropriate Principal defined as part of an External Credential. Refer to this Help & Training article for details on how to grant such permissions.
  2. Callouts will also run into trouble if the calling user does not have access to the User External Credential object, since that object holds the actual access token used with the target endpoint. The section above explains this in more detail, and there’s a special Help & Training article with a complete rundown of how much access is needed based on which authentication protocol is used.
    • When a new Permission Set is created, it receives access to the User External Credential object by default. This makes it easier to grant access without worrying about User External Credentials. The object access can, however, be disabled if you prefer to manage your permissions another way.
    • Guest Users will always need explicit access to the User External Credential object.
  3. If a managed package requires you as an administrator to create a particular Named Credential for its use, note that you will need to allowlist the namespace of the package before it can make a callout. Refer to this Help & Training article.

Links and Resources

Configuration info for administrators

Code samples and APIs for developers

Debugging tools

  • Send calls to webhook.site to see the headers and request in complete detail. (We can’t log in a highly verbose manner due to compliance concerns.)
  • Try Beeceptor to send back mock responses with fake data.