Přeskočit na obsah

Checkpoint challenge

Tento obsah zatím není dostupný ve vašem jazyce.

Original, hands-on practice. Never modeled on actual exam questions. This closes the chapter The Login Experience, chapter 15 of Securing Salesforce: Identity and Access.

In chapter 14’s practice, you built a site, Lab Customers, in the service provider org. Amara Nwosu registered herself on it, with a password, and verified her email.

The company now wants three things. Its login page should look like the company, not like Salesforce. Customers who’d rather not keep another password should get a code by email instead. And the company’s new mobile app should sign Amara in on its own screens, with Salesforce behind them.

In part 1, you brand the page. In part 2, you make it ask “who are you?” first. In part 3, you play the mobile app’s server from Postman and sign Amara in headless.

  • The brand: a logo, colors and a footer on the site’s login page.
  • Login Discovery: Amara types her email and gets a code, no password.
  • Headless: Amara signed in from Postman, through the site, with the Authorization Code and Credentials Flow.
  • The guard seen: the first headless call refused without the integration user’s token.
  • Lab orgs only. No company data, nothing personal. Use the email address you gave Amara in chapter 14, one you control.
  • Never for an admin. Your admin keeps a password and MFA, and logs in through the org’s own login page.
  • Keep secrets out of shared places. The app’s consumer secret goes in a Postman environment that you don’t share or export, never in a collection you’d send someone.
  • The custom URL is described, not built. A Developer Edition org can’t add one (S4).

1. Open the branding. In the service provider org, open Lab Customers in Workspaces, then Administration, Login & Registration. On an Aura site, the branding options are here. On an LWR site that wasn’t branded here before Summer ‘23, you brand the login page in Experience Builder instead (S1). This course hasn’t yet checked which of the two chapter 14’s template gives you: look in Login & Registration first.

2. Brand it (S1):

  • Logo: upload any small image you made yourself, or use a URL to one.
  • Background: a solid color.
  • Login button: one color. It’s used for the Log In, Verify, Continue and Sign Up buttons.
  • Footer text: ”© Lab Customers. A practice site.”

Save. In a private window, open the site’s login page. Then open its forgotten-password page from the link on it: the same look, because this branding covers the login, verify, reset and self-registration pages (S1).

3. Read the address bar. It ends in my.site.com, Salesforce’s domain, not the company’s. In production, you’d add a custom URL so the page sits on the company’s own domain, and then never change it (module 1). A Developer Edition org can’t add one (S4), so here you only write down what you’d need: the domain, set up first, and the site’s path on it (S4).

4. Think about many brands. If a second brand needed this page, you wouldn’t build a second site. You’d put the experience ID, expid, into the logo URL, and the page would pick its brand at run time (S3). You don’t need it here; just know where it goes.

5. Make it a Login Discovery page. Still in Login & Registration (S6):

  • Login Page Type: Login Discovery Page.
  • Login Prompt: “Email Address or Phone Number”. (In production, a custom label, so it can be translated.)
  • Login Discovery Handler: leave it blank, and click Create a Login Discovery Handler. Salesforce writes the Apex when you save.
  • Execute Login As: your admin. (In production, a system user with Manage Users, never a person: module 2.)
  • Employees: if Allow employees to log in directly to the site is selected, deselect it. A Login Discovery page doesn’t support it (S6).

Save, and publish the site.

6. Amara, without a password. In a private window, open the login page. One field now, not two. Type Amara’s email and continue. Salesforce sends a code to her email, because her email is verified (S6). Type the code. She’s in, and she never typed her password.

Now look at the handler Salesforce wrote, in Setup, Apex Classes. Find the branch that sends a code, and the branch that asks for a password when the email or phone isn’t verified (S6). That second branch is why chapter 14’s verification step mattered.

In this part, Postman plays the mobile app’s server: a private client, an app with a server that can keep a secret (module 3).

7. Turn on the guard first. In the site’s settings for headless passwordless login, require authentication for the first call (S10). Salesforce won’t let you leave it open: you must choose authentication or reCAPTCHA (S10). A private client uses authentication. This course hasn’t yet checked where these settings sit, or their exact names, in a Developer Edition org.

8. Make the app, in External Client App Manager, as in chapters 8 and 13. Call it “Lab Headless App”.

  • First, turn on the Authorization Code and Credentials Flow for the org, in OAuth and OpenID Connect Settings (S12).
  • On the app: enable OAuth, give it a callback URL (any https:// address you control, or Postman’s), and select Enable Code and Credential Flow (S12). Plan to use PKCE: Salesforce recommends it for private clients too (S12).
  • Permitted Users: Admin approved users are pre-authorized (S12). Make a permission set, “Lab headless app users”, add the app to it, and assign it to Amara.
  • The integration user’s token: turn on chapter 8’s client credentials flow for this app, with an integration user as the execution user and the pwdless_login_api scope (S9, S10). It’s the token the app’s server sends with its first call.

9. The first call, without the guard. In Postman, call the site’s headless passwordless login endpoint with Amara’s email, and no integration user’s token. Salesforce refuses: the site requires authentication (S10).

Copy the endpoint’s address and its fields from Salesforce Help (S9), not from a blog: they’re the part most likely to change. This course hasn’t yet run steps 9 to 11 against a Developer Edition org; Salesforce Help is the source for the addresses and fields.

10. The first call, with the guard. Get the integration user’s token with client credentials, as in chapter 8. Send the same call again, with that token. This time Salesforce sends a code to Amara’s email and returns a request identifier (S9).

11. From the code to her token (S9):

  • Send the request identifier and the code from her email, with your PKCE code challenge. Salesforce returns an authorization code: “your app exchanges a request identifier and OTP for the authorization code, instead of a username and password” (S9).
  • Swap the authorization code for her access token at the token endpoint, with the app’s consumer key and secret and your PKCE code verifier.

12. Use her token. Call the userinfo endpoint (chapter 9) with her access token. It answers with Amara: her user, on the site. Your “app” now knows who she is, and every call it makes with this token is limited by her profile and sharing, like any other user.

13. Take it back. Revoke Amara’s token for “Lab Headless App”, as in chapter 13. Call userinfo again: refused.

In part 2, who decided to send a code, and who would decide differently? The handler. The default sends a code when her email is verified, and asks for a password when it isn’t (S6). A custom handler could send a partner’s people to their own identity provider instead (module 2).

What happened to chapter 14’s button for the partner’s identity provider? Look at the login page. If it’s gone, the Login Discovery page now decides who goes where, and Tomás’s route would be a branch in the handler, chosen by his email’s domain (module 2). This course hasn’t yet tested this route.

In part 3, what did Salesforce stop doing for you? Its own login page decides who’s allowed to try. Your own screens don’t, so the guard on the first call became yours: the integration user’s token here, reCAPTCHA for a public client (S10).

Why not put the integration user’s token in the mobile app itself? Because anything in a phone or a browser can be read. A public client uses reCAPTCHA instead, and never holds a secret (S10, S12).

If the company also had a website, which of the three would you give it? A redirect to the site’s login page, branded as in part 1 (module 4). Not embedded login: it’s off by default since Summer ‘24 (S13).

  • The brand: Lab Customers’ login and reset pages with your logo, colors and footer.
  • The custom URL: written down, not built, and you can say why.
  • Login Discovery: Amara logs in with a code by email.
  • The handler: you found the branch that asks for a password.
  • Headless: the first call refused without the integration user’s token, then a code, an authorization code, and Amara’s token.
  • Revoked: her token no longer works.
  • COM-1 (customizing the login experience for a community): parts 1 and 2.
  • COM-4 (when to use headless or embedded login): part 3, and the last discussion question.
  • SID-2 (whether Customer 360 Identity fits a full Customer 360): every part is a piece of Salesforce Customer Identity (module 5).