Skip to content

Commit 2d78e6b

Browse files
committed
feat: add cookie domain back to context controller
1 parent e03eaf4 commit 2d78e6b

7 files changed

Lines changed: 13 additions & 6 deletions

File tree

‎frontend/src/lib/i18n/locales/en-US.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"continueInsecureRedirectTitle": "Insecure redirect",
2222
"continueInsecureRedirectSubtitle": "You are trying to redirect from <code>https</code> to <code>http</code> which is not secure. Are you sure you want to continue?",
2323
"continueUntrustedRedirectTitle": "Untrusted redirect",
24-
"continueUntrustedRedirectSubtitle": "You are trying to redirect to a domain that does not match your configured domain (<code>{{rootDomain}}</code>). Are you sure you want to continue?",
24+
"continueUntrustedRedirectSubtitle": "You are trying to redirect to a domain that does not match your configured domain (<code>{{cookieDomain}}</code>). Are you sure you want to continue?",
2525
"logoutFailTitle": "Failed to log out",
2626
"logoutFailSubtitle": "Please try again",
2727
"logoutSuccessTitle": "Logged out",

‎frontend/src/lib/i18n/locales/en.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"continueInsecureRedirectTitle": "Insecure redirect",
2222
"continueInsecureRedirectSubtitle": "You are trying to redirect from <code>https</code> to <code>http</code> which is not secure. Are you sure you want to continue?",
2323
"continueUntrustedRedirectTitle": "Untrusted redirect",
24-
"continueUntrustedRedirectSubtitle": "You are trying to redirect to a domain that does not match your configured domain (<code>{{rootDomain}}</code>). Are you sure you want to continue?",
24+
"continueUntrustedRedirectSubtitle": "You are trying to redirect to a domain that does not match your configured domain (<code>{{cookieDomain}}</code>). Are you sure you want to continue?",
2525
"logoutFailTitle": "Failed to log out",
2626
"logoutFailSubtitle": "Please try again",
2727
"logoutSuccessTitle": "Logged out",

‎frontend/src/pages/continue-page.tsx‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { Navigate, useLocation, useNavigate } from "react-router";
1414
import { useEffect, useState } from "react";
1515

1616
export const ContinuePage = () => {
17-
const { rootDomain } = useAppContext();
17+
const { cookieDomain } = useAppContext();
1818
const { isLoggedIn } = useUserContext();
1919
const { search } = useLocation();
2020
const { t } = useTranslation();
@@ -33,8 +33,8 @@ export const ContinuePage = () => {
3333
: null;
3434
const isTrustedRedirectUri =
3535
redirectUriObj !== null
36-
? redirectUriObj.hostname === rootDomain ||
37-
redirectUriObj.hostname.endsWith(`.${rootDomain}`)
36+
? redirectUriObj.hostname === cookieDomain ||
37+
redirectUriObj.hostname.endsWith(`.${cookieDomain}`)
3838
: false;
3939
const isAllowedRedirectProto =
4040
redirectUriObj !== null
@@ -105,7 +105,7 @@ export const ContinuePage = () => {
105105
components={{
106106
code: <code />,
107107
}}
108-
values={{ rootDomain }}
108+
values={{ cookieDomain }}
109109
/>
110110
</CardDescription>
111111
</CardHeader>

‎frontend/src/schemas/app-context-schema.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export const appContextSchema = z.object({
55
title: z.string(),
66
genericName: z.string(),
77
appUrl: z.string(),
8+
cookieDomain: z.string(),
89
forgotPasswordMessage: z.string(),
910
oauthAutoRedirect: z.enum(["none", "github", "google", "generic"]),
1011
backgroundImage: z.string(),

‎internal/bootstrap/app_bootstrap.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ func (app *BootstrapApp) Setup() error {
183183
Title: app.Config.Title,
184184
GenericName: app.Config.GenericName,
185185
AppURL: app.Config.AppURL,
186+
CookieDomain: cookieDomain,
186187
ForgotPasswordMessage: app.Config.ForgotPasswordMessage,
187188
BackgroundImage: app.Config.BackgroundImage,
188189
OAuthAutoRedirect: app.Config.OAuthAutoRedirect,

‎internal/controller/context_controller.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type AppContextResponse struct {
2828
Title string `json:"title"`
2929
GenericName string `json:"genericName"`
3030
AppURL string `json:"appUrl"`
31+
CookieDomain string `json:"cookieDomain"`
3132
ForgotPasswordMessage string `json:"forgotPasswordMessage"`
3233
BackgroundImage string `json:"backgroundImage"`
3334
OAuthAutoRedirect string `json:"oauthAutoRedirect"`
@@ -38,6 +39,7 @@ type ContextControllerConfig struct {
3839
Title string
3940
GenericName string
4041
AppURL string
42+
CookieDomain string
4143
ForgotPasswordMessage string
4244
BackgroundImage string
4345
OAuthAutoRedirect string
@@ -98,6 +100,7 @@ func (controller *ContextController) appContextHandler(c *gin.Context) {
98100
Title: controller.config.Title,
99101
GenericName: controller.config.GenericName,
100102
AppURL: fmt.Sprintf("%s://%s", appUrl.Scheme, appUrl.Host),
103+
CookieDomain: controller.config.CookieDomain,
101104
ForgotPasswordMessage: controller.config.ForgotPasswordMessage,
102105
BackgroundImage: controller.config.BackgroundImage,
103106
OAuthAutoRedirect: controller.config.OAuthAutoRedirect,

‎internal/controller/context_controller_test.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ var controllerCfg = controller.ContextControllerConfig{
1616
Title: "Test App",
1717
GenericName: "Generic",
1818
AppURL: "http://localhost:8080",
19+
CookieDomain: "localhost",
1920
ForgotPasswordMessage: "Contact admin to reset your password.",
2021
BackgroundImage: "/assets/bg.jpg",
2122
OAuthAutoRedirect: "google",
@@ -61,6 +62,7 @@ func TestAppContextHandler(t *testing.T) {
6162
Title: controllerCfg.Title,
6263
GenericName: controllerCfg.GenericName,
6364
AppURL: controllerCfg.AppURL,
65+
CookieDomain: controllerCfg.CookieDomain,
6466
ForgotPasswordMessage: controllerCfg.ForgotPasswordMessage,
6567
BackgroundImage: controllerCfg.BackgroundImage,
6668
OAuthAutoRedirect: controllerCfg.OAuthAutoRedirect,

0 commit comments

Comments
 (0)