mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2025-10-28 04:35:40 +00:00
feat: add cookie domain back to context controller
This commit is contained in:
@@ -21,7 +21,7 @@
|
|||||||
"continueInsecureRedirectTitle": "Insecure redirect",
|
"continueInsecureRedirectTitle": "Insecure redirect",
|
||||||
"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?",
|
"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?",
|
||||||
"continueUntrustedRedirectTitle": "Untrusted redirect",
|
"continueUntrustedRedirectTitle": "Untrusted redirect",
|
||||||
"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?",
|
"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?",
|
||||||
"logoutFailTitle": "Failed to log out",
|
"logoutFailTitle": "Failed to log out",
|
||||||
"logoutFailSubtitle": "Please try again",
|
"logoutFailSubtitle": "Please try again",
|
||||||
"logoutSuccessTitle": "Logged out",
|
"logoutSuccessTitle": "Logged out",
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
"continueInsecureRedirectTitle": "Insecure redirect",
|
"continueInsecureRedirectTitle": "Insecure redirect",
|
||||||
"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?",
|
"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?",
|
||||||
"continueUntrustedRedirectTitle": "Untrusted redirect",
|
"continueUntrustedRedirectTitle": "Untrusted redirect",
|
||||||
"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?",
|
"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?",
|
||||||
"logoutFailTitle": "Failed to log out",
|
"logoutFailTitle": "Failed to log out",
|
||||||
"logoutFailSubtitle": "Please try again",
|
"logoutFailSubtitle": "Please try again",
|
||||||
"logoutSuccessTitle": "Logged out",
|
"logoutSuccessTitle": "Logged out",
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import { Navigate, useLocation, useNavigate } from "react-router";
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
export const ContinuePage = () => {
|
export const ContinuePage = () => {
|
||||||
const { rootDomain } = useAppContext();
|
const { cookieDomain } = useAppContext();
|
||||||
const { isLoggedIn } = useUserContext();
|
const { isLoggedIn } = useUserContext();
|
||||||
const { search } = useLocation();
|
const { search } = useLocation();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -33,8 +33,8 @@ export const ContinuePage = () => {
|
|||||||
: null;
|
: null;
|
||||||
const isTrustedRedirectUri =
|
const isTrustedRedirectUri =
|
||||||
redirectUriObj !== null
|
redirectUriObj !== null
|
||||||
? redirectUriObj.hostname === rootDomain ||
|
? redirectUriObj.hostname === cookieDomain ||
|
||||||
redirectUriObj.hostname.endsWith(`.${rootDomain}`)
|
redirectUriObj.hostname.endsWith(`.${cookieDomain}`)
|
||||||
: false;
|
: false;
|
||||||
const isAllowedRedirectProto =
|
const isAllowedRedirectProto =
|
||||||
redirectUriObj !== null
|
redirectUriObj !== null
|
||||||
@@ -105,7 +105,7 @@ export const ContinuePage = () => {
|
|||||||
components={{
|
components={{
|
||||||
code: <code />,
|
code: <code />,
|
||||||
}}
|
}}
|
||||||
values={{ rootDomain }}
|
values={{ cookieDomain }}
|
||||||
/>
|
/>
|
||||||
</CardDescription>
|
</CardDescription>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ export const appContextSchema = z.object({
|
|||||||
title: z.string(),
|
title: z.string(),
|
||||||
genericName: z.string(),
|
genericName: z.string(),
|
||||||
appUrl: z.string(),
|
appUrl: z.string(),
|
||||||
|
cookieDomain: z.string(),
|
||||||
forgotPasswordMessage: z.string(),
|
forgotPasswordMessage: z.string(),
|
||||||
oauthAutoRedirect: z.enum(["none", "github", "google", "generic"]),
|
oauthAutoRedirect: z.enum(["none", "github", "google", "generic"]),
|
||||||
backgroundImage: z.string(),
|
backgroundImage: z.string(),
|
||||||
|
|||||||
@@ -183,6 +183,7 @@ func (app *BootstrapApp) Setup() error {
|
|||||||
Title: app.Config.Title,
|
Title: app.Config.Title,
|
||||||
GenericName: app.Config.GenericName,
|
GenericName: app.Config.GenericName,
|
||||||
AppURL: app.Config.AppURL,
|
AppURL: app.Config.AppURL,
|
||||||
|
CookieDomain: cookieDomain,
|
||||||
ForgotPasswordMessage: app.Config.ForgotPasswordMessage,
|
ForgotPasswordMessage: app.Config.ForgotPasswordMessage,
|
||||||
BackgroundImage: app.Config.BackgroundImage,
|
BackgroundImage: app.Config.BackgroundImage,
|
||||||
OAuthAutoRedirect: app.Config.OAuthAutoRedirect,
|
OAuthAutoRedirect: app.Config.OAuthAutoRedirect,
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ type AppContextResponse struct {
|
|||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
GenericName string `json:"genericName"`
|
GenericName string `json:"genericName"`
|
||||||
AppURL string `json:"appUrl"`
|
AppURL string `json:"appUrl"`
|
||||||
|
CookieDomain string `json:"cookieDomain"`
|
||||||
ForgotPasswordMessage string `json:"forgotPasswordMessage"`
|
ForgotPasswordMessage string `json:"forgotPasswordMessage"`
|
||||||
BackgroundImage string `json:"backgroundImage"`
|
BackgroundImage string `json:"backgroundImage"`
|
||||||
OAuthAutoRedirect string `json:"oauthAutoRedirect"`
|
OAuthAutoRedirect string `json:"oauthAutoRedirect"`
|
||||||
@@ -38,6 +39,7 @@ type ContextControllerConfig struct {
|
|||||||
Title string
|
Title string
|
||||||
GenericName string
|
GenericName string
|
||||||
AppURL string
|
AppURL string
|
||||||
|
CookieDomain string
|
||||||
ForgotPasswordMessage string
|
ForgotPasswordMessage string
|
||||||
BackgroundImage string
|
BackgroundImage string
|
||||||
OAuthAutoRedirect string
|
OAuthAutoRedirect string
|
||||||
@@ -98,6 +100,7 @@ func (controller *ContextController) appContextHandler(c *gin.Context) {
|
|||||||
Title: controller.config.Title,
|
Title: controller.config.Title,
|
||||||
GenericName: controller.config.GenericName,
|
GenericName: controller.config.GenericName,
|
||||||
AppURL: fmt.Sprintf("%s://%s", appUrl.Scheme, appUrl.Host),
|
AppURL: fmt.Sprintf("%s://%s", appUrl.Scheme, appUrl.Host),
|
||||||
|
CookieDomain: controller.config.CookieDomain,
|
||||||
ForgotPasswordMessage: controller.config.ForgotPasswordMessage,
|
ForgotPasswordMessage: controller.config.ForgotPasswordMessage,
|
||||||
BackgroundImage: controller.config.BackgroundImage,
|
BackgroundImage: controller.config.BackgroundImage,
|
||||||
OAuthAutoRedirect: controller.config.OAuthAutoRedirect,
|
OAuthAutoRedirect: controller.config.OAuthAutoRedirect,
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ var controllerCfg = controller.ContextControllerConfig{
|
|||||||
Title: "Test App",
|
Title: "Test App",
|
||||||
GenericName: "Generic",
|
GenericName: "Generic",
|
||||||
AppURL: "http://localhost:8080",
|
AppURL: "http://localhost:8080",
|
||||||
|
CookieDomain: "localhost",
|
||||||
ForgotPasswordMessage: "Contact admin to reset your password.",
|
ForgotPasswordMessage: "Contact admin to reset your password.",
|
||||||
BackgroundImage: "/assets/bg.jpg",
|
BackgroundImage: "/assets/bg.jpg",
|
||||||
OAuthAutoRedirect: "google",
|
OAuthAutoRedirect: "google",
|
||||||
@@ -61,6 +62,7 @@ func TestAppContextHandler(t *testing.T) {
|
|||||||
Title: controllerCfg.Title,
|
Title: controllerCfg.Title,
|
||||||
GenericName: controllerCfg.GenericName,
|
GenericName: controllerCfg.GenericName,
|
||||||
AppURL: controllerCfg.AppURL,
|
AppURL: controllerCfg.AppURL,
|
||||||
|
CookieDomain: controllerCfg.CookieDomain,
|
||||||
ForgotPasswordMessage: controllerCfg.ForgotPasswordMessage,
|
ForgotPasswordMessage: controllerCfg.ForgotPasswordMessage,
|
||||||
BackgroundImage: controllerCfg.BackgroundImage,
|
BackgroundImage: controllerCfg.BackgroundImage,
|
||||||
OAuthAutoRedirect: controllerCfg.OAuthAutoRedirect,
|
OAuthAutoRedirect: controllerCfg.OAuthAutoRedirect,
|
||||||
|
|||||||
Reference in New Issue
Block a user