Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 12 additions & 0 deletions site-config/hca-dcp/ma-dev/authentication/authentication.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { AuthenticationConfig } from "@databiosphere/findable-ui/lib/config/entities";
import { getGoogleProvider, TERRA_SERVICE } from "./constants";

export function getAuthenticationConfig(
authenticationConfig: AuthenticationConfig,
dataSourceUrl: string
): AuthenticationConfig {
const authentication = { ...authenticationConfig };
authentication.providers = [getGoogleProvider(dataSourceUrl)];
authentication.services = [TERRA_SERVICE];
return authentication;
}
38 changes: 38 additions & 0 deletions site-config/hca-dcp/ma-dev/authentication/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import {
OAUTH_FLOW,
OAuthProvider,
} from "@databiosphere/findable-ui/lib/config/entities";
import { GOOGLE_SIGN_IN_PROVIDER } from "@databiosphere/findable-ui/lib/google/config";
import { GoogleProfile } from "@databiosphere/findable-ui/lib/google/types";

import { OAUTH_GOOGLE_SIGN_IN } from "../../../common/authentication";

const CLIENT_ID =
"713613812354-aelk662bncv14d319dk8juce9p11um00.apps.googleusercontent.com";

/**
* Returns the Google OAuth provider configured for the authorization code
* flow, with `authorize` derived from the given Azul base URL.
* @param dataSourceUrl - Azul base URL.
* @returns Google OAuth provider.
*/
export function getGoogleProvider(
dataSourceUrl: string
): OAuthProvider<GoogleProfile> {
return {
...GOOGLE_SIGN_IN_PROVIDER,
...OAUTH_GOOGLE_SIGN_IN,
// Relies on dataSourceUrl having a trailing slash (set as `${dataUrl}/` in dev/config.ts).
authorize: `${dataSourceUrl}user/authorize`,
clientId: CLIENT_ID,
flow: OAUTH_FLOW.AUTHORIZATION_CODE,
};
}

export const TERRA_SERVICE = {
endpoint: {
profile: "https://sam.dsde-dev.broadinstitute.org/register/user/v1",
tos: "https://sam.dsde-dev.broadinstitute.org/register/user/v2/self/termsOfServiceDetails",
},
id: "terra",
};
9 changes: 9 additions & 0 deletions site-config/hca-dcp/ma-dev/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { GIT_HUB_REPO_URL } from "../../common/constants";
import { SiteConfig } from "../../common/entities";
import { makeManagedAccessConfig } from "../cc-ma-dev/config";
import { makeConfig } from "../dev/config";
import { getAuthenticationConfig } from "./authentication/authentication";

// Template constants
const BROWSER_URL = "https://explore.dev.singlecell.gi.ucsc.edu";
Expand All @@ -20,4 +21,12 @@ if (config.analytics) {
config.analytics = undefined;
}

// Update authentication for the dev environment (authorization code flow).
if (config.authentication) {
config.authentication = getAuthenticationConfig(
config.authentication,
config.dataSource.url
);
}

export default config;
Loading