Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Multi domain token usage #9791

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft

Multi domain token usage #9791

wants to merge 1 commit into from

Conversation

barankyle
Copy link
Member

Summary

References

closes #insert number here

QA Steps

packages/client/package.json Outdated Show resolved Hide resolved
@@ -49,7 +57,7 @@ export class Engine {
const UndefinedEntity = bitECS.addEntity(HyperFlux.store)
}

api: FeathersApplication<ServiceTypes>
api: FeathersClient
Copy link
Member

Choose a reason for hiding this comment

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

we shouldn't overload this here, since we access it on the backend and it will have different types

Copy link
Member

Choose a reason for hiding this comment

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

we should be able to declare a type override in client-core that will only be applied in packages that import client-core

Copy link
Member Author

Choose a reason for hiding this comment

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

Weird, I made this change because of type errors when I started, but maybe something has changed in dev since then, because now it's not showing any type mismatches when I revert to what it was.

@@ -97,7 +97,11 @@ export const configurePrimus =
const origin = [
'https://' + appConfig.server.clientHost,
'capacitor://' + appConfig.server.clientHost,
'ionic://' + appConfig.server.clientHost
'ionic://' + appConfig.server.clientHost,
'https://cool.pants.com',
Copy link
Member

Choose a reason for hiding this comment

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

Left over test domains? We should probably remove capacitor & ionic stuff too

@barankyle barankyle force-pushed the multi-domain-token-usage branch 3 times, most recently from 9ddd052 to 6561bc3 Compare March 2, 2024 02:21
@barankyle barankyle force-pushed the multi-domain-token-usage branch 3 times, most recently from 3e4fcf0 to afbd7af Compare March 7, 2024 00:15
For multi-domain setups, having to log in on each different domain
is annoying. This saves the user's login information in the 'root'
domain of the deployment, and on all domains sources the login
credentials from an iframe running in the root domain using
postMessage. This only gets skipped if a user has expressly denied
cross-domain sharing of their login information, in which case
localStorage will be used as the source for login credentials.

The iframe loads a new non-vite page in client/public, and does so
in the root domain. Some user authorization flow is required on
most browsers to enable this, using the requestStorageAccess API.

A new backend service, allowed-domains, takes in a domain on a query
paramter and returns true if that domain is part of the deployment,
and a 204 if not. By default this just returns the root domain, but
this is extensible via projects' hooks to add other domains to the
allowed list. It can also just be passed a variable isAllowed from
a hook if fetching all domains would be cumbersome, and simply
querying whether the domain is in a table would be simpler.
The accessor iframe uses the response to determine
whether to even attempt to access the cookies or prompt the user
with requestStorageAccess.
@barankyle barankyle force-pushed the multi-domain-token-usage branch from afbd7af to af080a2 Compare March 7, 2024 00:25
@barankyle
Copy link
Member Author

Note to myself, something about the cookie seems to mess up OAuth login on the root domain if it becomes disconnected from a database user. Locally, I'd reinited the database several times while the cookie was still on localhost:3000, and it broke all OAuth providers. The grant session didn't seem to persist across the entire OAuth flow.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants