mirror of
https://github.com/logto-io/logto.git
synced 2025-01-13 21:30:30 -05:00
feat(schemas,core): add unknown session redirect url to sie (#6796)
* feat(schemas,core): add unknown session redirect url to sie add unknown session redirect url config to sie settings * chore(core): update openapi docs update openapi docs * fix(core): fix typo fix typo * fix(core): fix typo Co-authored-by: Charles Zhao <charleszhao@silverhand.io> --------- Co-authored-by: Charles Zhao <charleszhao@silverhand.io>
This commit is contained in:
parent
4e826deabe
commit
ec0f0c35f8
9 changed files with 71 additions and 1 deletions
|
@ -102,4 +102,5 @@ export const mockSignInExperience: SignInExperience = {
|
||||||
socialSignIn: {},
|
socialSignIn: {},
|
||||||
supportEmail: null,
|
supportEmail: null,
|
||||||
supportWebsiteUrl: null,
|
supportWebsiteUrl: null,
|
||||||
|
unknownSessionRedirectUrl: null,
|
||||||
};
|
};
|
||||||
|
|
|
@ -41,7 +41,7 @@ describe('sign-in-experience query', () => {
|
||||||
it('findDefaultSignInExperience', async () => {
|
it('findDefaultSignInExperience', async () => {
|
||||||
/* eslint-disable sql/no-unsafe-query */
|
/* eslint-disable sql/no-unsafe-query */
|
||||||
const expectSql = `
|
const expectSql = `
|
||||||
select "tenant_id", "id", "color", "branding", "language_info", "terms_of_use_url", "privacy_policy_url", "agree_to_terms_policy", "sign_in", "sign_up", "social_sign_in", "social_sign_in_connector_targets", "sign_in_mode", "custom_css", "custom_content", "custom_ui_assets", "password_policy", "mfa", "single_sign_on_enabled", "support_email", "support_website_url"
|
select "tenant_id", "id", "color", "branding", "language_info", "terms_of_use_url", "privacy_policy_url", "agree_to_terms_policy", "sign_in", "sign_up", "social_sign_in", "social_sign_in_connector_targets", "sign_in_mode", "custom_css", "custom_content", "custom_ui_assets", "password_policy", "mfa", "single_sign_on_enabled", "support_email", "support_website_url", "unknown_session_redirect_url"
|
||||||
from "sign_in_experiences"
|
from "sign_in_experiences"
|
||||||
where "id"=$1
|
where "id"=$1
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -51,6 +51,15 @@
|
||||||
},
|
},
|
||||||
"mfa": {
|
"mfa": {
|
||||||
"description": "MFA settings"
|
"description": "MFA settings"
|
||||||
|
},
|
||||||
|
"supportEmail": {
|
||||||
|
"description": "The support email address to display on the error pages."
|
||||||
|
},
|
||||||
|
"supportWebsiteUrl": {
|
||||||
|
"description": "The support website URL to display on the error pages."
|
||||||
|
},
|
||||||
|
"unknownSessionRedirectUrl": {
|
||||||
|
"description": "The fallback URL to redirect users when the sign-in session does not exist or unknown. Client should initiates a new authentication flow after the redirection."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,6 +120,15 @@
|
||||||
},
|
},
|
||||||
"mfa": {
|
"mfa": {
|
||||||
"description": "MFA settings"
|
"description": "MFA settings"
|
||||||
|
},
|
||||||
|
"supportEmail": {
|
||||||
|
"description": "The support email address to display on the error pages."
|
||||||
|
},
|
||||||
|
"supportWebsiteUrl": {
|
||||||
|
"description": "The support website URL to display on the error pages."
|
||||||
|
},
|
||||||
|
"unknownSessionRedirectUrl": {
|
||||||
|
"description": "The fallback URL to redirect users when the sign-in session does not exist or unknown. Client should initiate a new authentication flow after the redirection."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,4 +232,28 @@ describe('PATCH /sign-in-exp', () => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should guard unknown session redirect URL field format', async () => {
|
||||||
|
const exception = await signInExperienceRequester
|
||||||
|
.patch('/sign-in-exp')
|
||||||
|
.send({ unknownSessionRedirectUrl: 'invalid' });
|
||||||
|
|
||||||
|
expect(exception).toMatchObject({
|
||||||
|
status: 400,
|
||||||
|
});
|
||||||
|
|
||||||
|
const unknownSessionRedirectUrl = 'https://logto.io';
|
||||||
|
|
||||||
|
const response = await signInExperienceRequester.patch('/sign-in-exp').send({
|
||||||
|
unknownSessionRedirectUrl,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(response).toMatchObject({
|
||||||
|
status: 200,
|
||||||
|
body: {
|
||||||
|
...mockSignInExperience,
|
||||||
|
unknownSessionRedirectUrl,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -55,6 +55,7 @@ export default function signInExperiencesRoutes<T extends ManagementApiRouter>(
|
||||||
privacyPolicyUrl: true,
|
privacyPolicyUrl: true,
|
||||||
supportEmail: true,
|
supportEmail: true,
|
||||||
supportWebsiteUrl: true,
|
supportWebsiteUrl: true,
|
||||||
|
unknownSessionRedirectUrl: true,
|
||||||
})
|
})
|
||||||
.merge(
|
.merge(
|
||||||
object({
|
object({
|
||||||
|
@ -62,6 +63,7 @@ export default function signInExperiencesRoutes<T extends ManagementApiRouter>(
|
||||||
privacyPolicyUrl: string().url().optional().nullable().or(literal('')),
|
privacyPolicyUrl: string().url().optional().nullable().or(literal('')),
|
||||||
supportEmail: string().email().optional().nullable().or(literal('')),
|
supportEmail: string().email().optional().nullable().or(literal('')),
|
||||||
supportWebsiteUrl: string().url().optional().nullable().or(literal('')),
|
supportWebsiteUrl: string().url().optional().nullable().or(literal('')),
|
||||||
|
unknownSessionRedirectUrl: string().url().optional().nullable().or(literal('')),
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.partial(),
|
.partial(),
|
||||||
|
|
|
@ -116,6 +116,7 @@ export const mockSignInExperience: SignInExperience = {
|
||||||
socialSignIn: {},
|
socialSignIn: {},
|
||||||
supportEmail: null,
|
supportEmail: null,
|
||||||
supportWebsiteUrl: null,
|
supportWebsiteUrl: null,
|
||||||
|
unknownSessionRedirectUrl: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const mockSignInExperienceSettings: SignInExperienceResponse = {
|
export const mockSignInExperienceSettings: SignInExperienceResponse = {
|
||||||
|
@ -153,6 +154,7 @@ export const mockSignInExperienceSettings: SignInExperienceResponse = {
|
||||||
socialSignIn: {},
|
socialSignIn: {},
|
||||||
supportEmail: null,
|
supportEmail: null,
|
||||||
supportWebsiteUrl: null,
|
supportWebsiteUrl: null,
|
||||||
|
unknownSessionRedirectUrl: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
const usernameSettings = {
|
const usernameSettings = {
|
||||||
|
|
|
@ -116,6 +116,7 @@ export const mockSignInExperience: SignInExperience = {
|
||||||
socialSignIn: {},
|
socialSignIn: {},
|
||||||
supportEmail: null,
|
supportEmail: null,
|
||||||
supportWebsiteUrl: null,
|
supportWebsiteUrl: null,
|
||||||
|
unknownSessionRedirectUrl: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const mockSignInExperienceSettings: SignInExperienceResponse = {
|
export const mockSignInExperienceSettings: SignInExperienceResponse = {
|
||||||
|
@ -153,6 +154,7 @@ export const mockSignInExperienceSettings: SignInExperienceResponse = {
|
||||||
socialSignIn: {},
|
socialSignIn: {},
|
||||||
supportEmail: null,
|
supportEmail: null,
|
||||||
supportWebsiteUrl: null,
|
supportWebsiteUrl: null,
|
||||||
|
unknownSessionRedirectUrl: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
const usernameSettings = {
|
const usernameSettings = {
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
import { sql } from '@silverhand/slonik';
|
||||||
|
|
||||||
|
import type { AlterationScript } from '../lib/types/alteration.js';
|
||||||
|
|
||||||
|
const alteration: AlterationScript = {
|
||||||
|
up: async (pool) => {
|
||||||
|
await pool.query(sql`
|
||||||
|
alter table sign_in_experiences
|
||||||
|
add column unknown_session_redirect_url text;
|
||||||
|
`);
|
||||||
|
},
|
||||||
|
down: async (pool) => {
|
||||||
|
await pool.query(sql`
|
||||||
|
alter table sign_in_experiences
|
||||||
|
drop column unknown_session_redirect_url;
|
||||||
|
`);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default alteration;
|
|
@ -25,5 +25,6 @@ create table sign_in_experiences (
|
||||||
single_sign_on_enabled boolean not null default false,
|
single_sign_on_enabled boolean not null default false,
|
||||||
support_email text,
|
support_email text,
|
||||||
support_website_url text,
|
support_website_url text,
|
||||||
|
unknown_session_redirect_url text,
|
||||||
primary key (tenant_id, id)
|
primary key (tenant_id, id)
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Reference in a new issue