Spark Linky

Salesforce JWT and OAuth Authentication

6 branches · 72 ideas

Identity Roles01Salesforce as ProviderSalesforce as authorization serverExternal application as OAuth clientSalesforce APIs as resource serverSalesforce as ClientSalesforce as OAuth clientExternal provider as authorization serverExternal API as resource serverAssertion IdentityJWT assertion: client-created credentialAssertion presented to authorization serverAssertion not an issued access tokenIssued Token IdentityAccess token: authorization-server-issuedcredentialToken represents API authorizationToken issuer differs from assertion creatorFlow Selection02JWT BearerNon-interactive, user-specific API callsCertificate-backed server integrationsNo browser login during executionAuthorization Code PKCEInteractive web or mobile applicationsBrowser-based user authorizationPublic clients without client secretsClient CredentialsMachine-to-machine API callsNo browser redirectNo signed JWT assertion requiredOther Supported FlowsDevice flow for limited-input devicesSAML bearer for federated integrationsUsername-password flow for legacyintegrationsApplicationSetup03Client RegistrationApp Manager: New Connected AppExternal Client App registrationUpload X.509 signing certificateOAuth SettingsEnable OAuth SettingsCopy Consumer Key (client_id)Register callback URLScopes and Endpointsapi OAuth scoperefresh_token OAuth scope/services/oauth2/token endpointOutbound CredentialsConfigure OAuth External CredentialSet Named Credential target URLEnter Auth Provider client ID and secretJWTAssertions04Required Claimsiss: connected app Consumer Keysub: Salesforce usernameaud: Salesforce login URLAudience URLsProduction: https://login.salesforce.comSandbox: https://test.salesforce.comMy Domain: matching login hostnameSignature ConstructionHeader algorithm: RS256Base64url-encode header and payloadSign with certificate-matched private keyExpiration Controlsexp: Unix timestamp in secondsSet exp within five minutes (approx)Synchronize signing server clockTokenHandling05Token ExchangePOST form-encoded token requestJWT bearer grant_type and assertionparametersParse access_token and instance_url fromJSONAPI RequestsAuthorization: Bearer <access_token>Use instance_url as API baseGET /services/data/vXX.X/sobjects/AccountExpiry DetectionCheck HTTP 401 and INVALID_SESSION_IDAccount for Salesforce session timeout policiesAvoid fixed access-token lifetime assumptionsToken RenewalJWT bearer: exchange a fresh assertionRefresh grant: grant_type=refresh_tokenRetry failed API request once after renewalAccessGovernance06Permission BoundariesGrant API Enabled via permission setsLimit object CRUD and field accessReview effective permissions quarterlyApp ApprovalSet Permitted Users: Admin approved usersAssign connected app access via permissionsetsReview approved users after role changesCredential RotationSchedule signing-certificate rotation beforeexpirationStore private keys in a secrets managerRemove retired certificates after cutoverFailure and RevocationCheck Login History for authenticationfailuresAlert on repeated invalid_grant responsesRevoke grants through Connected App OAuthUsageSalesforce JWTand OAuthAuthentication6 BRANCHES · 24 TOPICS · 72 IDEAS

Tap a branch to zoom in · pinch to explore

100%
Made with Spark Linky