Skip to content

Conversation

nrkruk
Copy link
Collaborator

@nrkruk nrkruk commented Sep 17, 2024

What does this PR do?

  • On local-dev startup, simulate the auth flow for establishing a valid SID token for sites via servlets (/servlet/networks/switch). Grab the valid token from those requests and append to any proxied requests back to core for the life of the local development session. Requests in the browser may still show asGuest=true but be proxied to your org with valid authentication credentials by the dev server.

  • Create a new environment variable SITE_GUEST_ACCESS. When set to true, this will skip attempting to establish a valid authentication session at startup and allow you to access the site as a guest user.

Note: This is more of a temporary solution to support sites auth and may evolve as we update the Beta and work towards GA

What issues does this PR fix or reference?

@W-16647027@

@nrkruk nrkruk self-assigned this Sep 17, 2024
@nrkruk nrkruk marked this pull request as ready for review September 18, 2024 00:45
@nrkruk nrkruk requested a review from a team as a code owner September 18, 2024 00:45
@nrkruk nrkruk changed the title feat: authentication - part 2 feat: sites authentication - pt 2 Sep 18, 2024
@nrkruk nrkruk changed the title feat: sites authentication - pt 2 feat: sites authentication poc Sep 18, 2024
@nrkruk nrkruk changed the title feat: sites authentication poc feat: establish valid experience site sessions at startup Sep 20, 2024
import fs from 'node:fs';
import path from 'node:path';
import { Org, SfError } from '@salesforce/core';
import axios from 'axios';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we used axios over native node fetch (just curious).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not really, it was just a little easier to get working initially. Axios has some nice extra features that help with debugging like interceptors. But yeah I could switch over to using fetch I guess

@nrkruk nrkruk removed the request for review from lpomerleau September 20, 2024 17:53
@nrkruk nrkruk merged commit 1f29721 into main Sep 20, 2024
11 checks passed
@nrkruk nrkruk deleted the nkruk/authentication branch September 20, 2024 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants