Beginning of Strict CSP Compliance (#6841)

* Add CSP Support and enable it initially for Login page

* Update README

* Make sure that CSP is not enabled if CSP_POLICY isnt set

* Add a new value for x-csp header that tells if instance has opted-in to CSP or not

* Add more src to CSP

* Fix typo in header name

* Remove duplicate headers fn

* Add https://eu.ui-avatars.com/api/

* Add CSP_POLICY to env.example
This commit is contained in:
Hariom Balhara authored and GitHub committed 2023-02-06 22:50:08 +00:00
1 parent 390967990a
commit 30c0e6d1d7
14 files changed
+243 -58

No files matched your search

+7 -4
View File
@@ -19,6 +19,7 @@ import { Alert, Button, EmailField, PasswordField } from "@calcom/ui";
import { FiArrowLeft } from "@calcom/ui/components/icon";
import { inferSSRProps } from "@lib/types/inferSSRProps";
import withNonce, { WithNonceProps } from "@lib/withNonce";
import AddToHomescreen from "@components/AddToHomescreen";
import TwoFactor from "@components/auth/TwoFactor";
@@ -40,7 +41,7 @@ export default function Login({
isSAMLLoginEnabled,
samlTenantID,
samlProductID,
}: inferSSRProps<typeof getServerSideProps>) {
}: inferSSRProps<typeof _getServerSideProps> & WithNonceProps) {
const { t } = useLocale();
const router = useRouter();
const methods = useForm<LoginValues>();
@@ -205,7 +206,8 @@ export default function Login({
);
}
export async function getServerSideProps(context: GetServerSidePropsContext) {
// TODO: Once we understand how to retrieve prop types automatically from getServerSideProps, remove this temporary variable
const _getServerSideProps = async function getServerSideProps(context: GetServerSidePropsContext) {
const { req } = context;
const session = await getSession({ req });
const ssr = await ssrInit(context);
@@ -229,7 +231,6 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
},
};
}
return {
props: {
csrfToken: await getCsrfToken(context),
@@ -240,4 +241,6 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
samlProductID,
},
};
}
};
export const getServerSideProps = withNonce(_getServerSideProps);