Skip to content
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

chore: support multitenancy domain #1979

Merged
merged 25 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ed20cb4
chore: support multitenancy domain
Dec 26, 2024
6566089
chore: support multitenancy domain
Dec 26, 2024
996b051
chore: support multitenancy domain
Dec 26, 2024
ffb269a
chore: support multitenancy domain
Dec 26, 2024
2d37a21
chore: support multitenancy domain
Dec 26, 2024
b286870
chore: support multitenancy domain
Dec 26, 2024
5b6da36
chore: support multitenancy domain
Dec 26, 2024
3f20ca2
chore: support multitenancy domain
Dec 27, 2024
929bf3b
Merge branch 'main' of https://github.com/juspay/hyperswitch-control-…
Dec 27, 2024
91d356e
chore: support multitenancy domain
Dec 27, 2024
272aac3
chore: support multitenancy domain
Dec 27, 2024
4e1c373
Merge branch 'main' of https://github.com/juspay/hyperswitch-control-…
Dec 31, 2024
9c96a71
chore: custom role for tenant admin
Dec 31, 2024
0e63049
chore: close switch org modal
Dec 31, 2024
b954827
chore: extract domain from request headers host
Jan 2, 2025
c766c63
Merge branch 'main' of https://github.com/juspay/hyperswitch-control-…
Jan 2, 2025
acdc6f1
chore: revert host changes, and session data changes
Jan 2, 2025
c2c315b
chore: revert host changes, and session data changes
Jan 2, 2025
cfa97be
chore: log request and domain
Jan 2, 2025
ffb3c2b
chore: log request and domain
Jan 2, 2025
f4926f0
chore: log request and domain
Jan 2, 2025
72bb98e
chore: use x-tenant-id for domain
Jan 2, 2025
860c857
chore: removed sending default value of domain
Jan 2, 2025
576f010
chore: removed logs
Jan 2, 2025
e144f86
Merge branch 'main' into test-tenancy-domain
gitanjli525 Jan 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/entryPoints/AuthModule/AuthUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ let redirectToLogin = () => {
open LogicUtils

let authId = getSessionData(~key="auth_id")
let domain = getSessionData(~key="domain")
let domain = getSessionData(~key="domain") // todo: setting domain in session storage shall be removed later

let urlToRedirect = switch (authId->isNonEmptyString, domain->isNonEmptyString) {
| (true, true) => `/login?auth_id=${authId}&domain=${domain}`
Expand Down
2 changes: 1 addition & 1 deletion src/entryPoints/AuthModule/TwoFaAuth/TwoFaAuth.res
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ let make = (~setAuthStatus, ~authType, ~setAuthType) => {
~entityName=USERS,
~userType=#CONNECT_ACCOUNT,
~methodType=Post,
~queryParamerters=Some(`auth_id=${authId}&domain=${domain}`),
~queryParamerters=Some(`auth_id=${authId}&domain=${domain}`), // todo: domain shall be removed from query params later
)
let res = await updateDetails(url, body, Post)
let valuesDict = res->getDictFromJsonObject
Expand Down
6 changes: 3 additions & 3 deletions src/entryPoints/HyperSwitchEntry.res
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ module HyperSwitchEntryComponent = {
let fetchConfig = async () => {
try {
open LogicUtils
let domain = HyperSwitchEntryUtils.getSessionData(~key="domain", ~defaultValue="default")
let apiURL = `${GlobalVars.getHostUrlWithBasePath}/config/feature?domain=${domain}`
let domain = HyperSwitchEntryUtils.getSessionData(~key="domain", ~defaultValue="")
let apiURL = `${GlobalVars.getHostUrlWithBasePath}/config/feature?domain=${domain}` // todo: domain shall be removed from query params later
let res = await fetchDetails(apiURL)
let featureFlags = res->FeatureFlagUtils.featureFlagType
setFeatureFlag(_ => featureFlags)
Expand Down Expand Up @@ -111,7 +111,7 @@ module HyperSwitchEntryComponent = {

React.useEffect(() => {
let _ = HyperSwitchEntryUtils.setSessionData(~key="auth_id", ~searchParams=url.search)
let _ = HyperSwitchEntryUtils.setSessionData(~key="domain", ~searchParams=url.search)
let _ = HyperSwitchEntryUtils.setSessionData(~key="domain", ~searchParams=url.search) // todo: setting domain in session storage shall be removed later

let _ = fetchConfig()->ignore
None
Expand Down
4 changes: 2 additions & 2 deletions src/screens/Hooks/MerchantSpecificConfigHook.res
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ let useMerchantSpecificConfig = () => {
HyperswitchAtom.merchantSpecificConfigAtom->Recoil.useRecoilValueFromAtom
let fetchMerchantSpecificConfig = async () => {
try {
let domain = HyperSwitchEntryUtils.getSessionData(~key="domain", ~defaultValue="default")
let merchantConfigURL = ` ${GlobalVars.getHostUrlWithBasePath}/config/merchant?domain=${domain}`
let domain = HyperSwitchEntryUtils.getSessionData(~key="domain", ~defaultValue="")
let merchantConfigURL = ` ${GlobalVars.getHostUrlWithBasePath}/config/merchant?domain=${domain}` // todo: domain shall be removed from query params later
let body =
[
("org_id", orgId->JSON.Encode.string),
Expand Down
7 changes: 5 additions & 2 deletions src/screens/OMPSwitch/OrgSwitch.res
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ module SwitchOrg = {
let _ = await orgSwitch(~expectedOrgId=value, ~currentOrgId=orgId)
setShowModal(_ => false)
} catch {
| _ => showToast(~message="Failed to switch the org! Try again.", ~toastType=ToastError)
| _ => {
showToast(~message="Failed to switch the org! Try again.", ~toastType=ToastError)
setShowModal(_ => false)
}
}
}

Expand Down Expand Up @@ -311,7 +314,7 @@ let make = () => {
dropdownContainerStyle
shouldDisplaySelectedOnTop=true
/>
<RenderIf condition={tenantUser && isTenantAdmin && orgList->Array.length > 20}>
<RenderIf condition={tenantUser && isTenantAdmin && orgList->Array.length >= 20}>
<SwitchOrg setShowModal={setShowSwitchingOrg} />
</RenderIf>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ let roleScope = userRole => {
~options=roleScopeArray,
~buttonText="Select Option",
~deselectDisable=true,
~disableSelect=userRole === "org_admin" ? false : true,
~disableSelect=userRole === "org_admin" || userRole === "tenant_admin" ? false : true,
),
~isRequired=true,
)
Expand Down
15 changes: 12 additions & 3 deletions src/server/Server.res
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,22 @@ let currentCommitHash = nullableGitCommitStr->Option.getOr("no-commit-hash")

let serverHandler: Http.serverHandler = (request, response) => {
let arr = request.url.toString()->String.split("?")
let domain =

let domainFromQueryParam =
arr
->Array.get(1)
->Option.getOr("domain=default")
->Option.getOr("domain=")
->Js.String2.split("=")
->Array.get(1)
->Option.getOr("default")
->Option.getOr("")

let xTenantId = request.headers->Dict.get("x-tenant-id")
let domainFromXTenantId = switch xTenantId->Option.getOr("public") {
| "public" => "default"
| value => value
}

let domain = domainFromQueryParam == "" ? domainFromXTenantId : domainFromQueryParam

let path =
arr
Expand Down
Loading