-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Basic Auth Implementation in Retail React App Take 2️⃣ #732
Conversation
Hi @johnboxall this looks like a great progress, thanks. |
Nice write up @johnboxall ! Are we looking at any kinds of permanent solutions for this? Off of the top of my head I can think of 2 places were we might want to do that, that is not the PWA-Kit*.
|
I think this is pretty great idea. Let's ask!
The challenge here is that as long as SCAPI/OCAPI/other APIs we're proxying on the same domain want to use the I think ideally we'd have some kinda toggle that would require oauth based access, something like https://oauth2-proxy.github.io/oauth2-proxy/ – of which you could say you want auth through Account Manager. |
in in |
Once SalesforceCommerceCloud/commerce-sdk-isomorphic#115 is merged, we should be able to simplify this approach significantly. Native browser |
Folks often want to protect their in-progress or non-production storefront from prying eyes.
HTTP basic authentication (same mechanism as storefront protection in B2CE) is one way to do this.
This PR shows how you might approach implementing basic auth.
The big challenge is that both HTTP Basic Auth and SCAPI/OCAPI want to use the
Authorization
header.In this attempt, I move the API calls to route through the App Server (
ssr.js
) rather than proxies, and introduce a "mock" headerX-Authorization
that I use for all API auth. Ib App Server, I swap the header back before forwarding it to the API origin.This works great, but we're currently blocked by a bug in
aws-serverless-express
around duplicate query param handling: CodeGenieApp/serverless-express#214We use it here:
pwa-kit/packages/pwa-kit-runtime/src/ssr/server/build-remote-server.js
Line 774 in effd675
This has since been fixed in that more recent releases of that library.
Blocked by: #733
A demo of this code is deployed here: https://basic-auth-production.mobify-storefront.com/
Username:
storefront
Password:
password
Note because of the blocking bug, product search doesn't work correctly.