Skip to content
This repository was archived by the owner on Oct 3, 2025. It is now read-only.

Commit 39dcbe3

Browse files
authored
Merge pull request #391 from NDLANO/custom-login-domain
Use custom domain for login
2 parents b1e5185 + 628f2ac commit 39dcbe3

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

src/config.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,11 @@ const apiDomain = activatedForEnvironment(
4040
const ltiActivated = activatedForEnvironment({ test: true, local: true }, false);
4141
const pinterestActivated = activatedForEnvironment({ test: true, local: true }, false);
4242

43-
const getAuth0Hostname = () => {
44-
switch (environment) {
45-
case "prod":
46-
return "ndla.eu.auth0.com";
47-
default:
48-
return `ndla-${environment}.eu.auth0.com`;
43+
const getAuth0Hostname = (prettyUrl = false) => {
44+
if (prettyUrl) {
45+
return `login.${environment}.ndla.no`.replace(".prod", "");
4946
}
47+
return `ndla-${environment}.eu.auth0.com`.replace("-prod", "");
5048
};
5149

5250
const editorialFrontendDomain = () => {
@@ -79,6 +77,10 @@ const config = {
7977
ltiActivated: getEnvironmentVariable("LTI_ACTIVATED", ltiActivated),
8078
ndlaPersonalClientId: getEnvironmentVariable("NDLA_PERSONAL_CLIENT_ID", ""),
8179
auth0Domain: getEnvironmentVariable("AUTH0_DOMAIN", getAuth0Hostname()),
80+
auth0BrowserDomain: getEnvironmentVariable(
81+
"AUTH0_CUSTOM_DOMAIN",
82+
getAuth0Hostname(getEnvironmentVariable("AUTH0_CUSTOM_DOMAIN_ENABLED", false)),
83+
),
8284
disableSSR: getEnvironmentVariable("DISABLE_SSR", false),
8385
zendeskWidgetKey: getEnvironmentVariable("NDLA_ZENDESK_WIDGET_KEY"),
8486
app: {

src/server/helpers/Auth0SilentCallback.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const Auth0SilentCallback = `
1515
<script src="https://cdn.auth0.com/js/auth0/9.10.0/auth0.min.js"></script>
1616
<script type="text/javascript">
1717
var webAuth = new auth0.WebAuth({
18-
domain: '${config.auth0Domain}',
18+
domain: '${config.auth0BrowserDomain}',
1919
clientID: '${config.ndlaPersonalClientId}'
2020
});
2121
var result = webAuth.parseHash({ hash: window.location.hash }, function(err, data) {

src/server/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ app.get(
173173
jwksUri: `https://${config.auth0Domain}/.well-known/jwks.json`,
174174
}),
175175
audience: "ndla_system",
176-
issuer: `https://${config.auth0Domain}/`,
176+
issuer: `https://${config.auth0BrowserDomain}/`,
177177
algorithms: ["RS256"],
178178
}),
179179
async (req, res) => {

src/sources/apiConstants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import defined from "defined";
1010
import config from "../config";
1111

1212
const NDLA_API_URL = config.ndlaApiUrl;
13-
const AUTH0_DOMAIN = config.auth0Domain;
13+
const AUTH0_DOMAIN = config.auth0BrowserDomain;
1414
const NDLA_PERSONAL_CLIENT_ID = config.ndlaPersonalClientId;
1515

1616
/* if (process.env.NODE_ENV === 'unittest') {

0 commit comments

Comments
 (0)