为什么谷歌登录失败与http-headers?



目前我正在开发一个前端和后端应用程序。我想实现安全的http头,特别是内容安全策略。但现在的问题是,谷歌登录不再工作了。一旦我可以选择登录哪个帐户,什么都不会发生了。

我添加了HelmetJS,并在我的后端使用ExpressJS更改了这些CSP设置:

defaultSrc: [
"'self' 'unsafe-inline' 'unsafe-eval' 'www.google.com' 'www.gstatic.com'",
],
scriptSrc: [
'"self" "unsafe-eval" "unsafe-inline" "google" "*.google" "*.google.com" "*.googleapis.com"',
],

我尝试添加google到允许的域名,但它没有工作。

看起来你引用了不该引用的东西。比如"self"one_answers";unsafe-inline"应该被引用,但其他不应该。

试试这个:

defaultSrc: [
// Should be quoted
"'self'", "'unsafe-inline'", "'unsafe-eval'",
// Shouldn't be quoted
"www.google.com", "www.gstatic.com",
],
scriptSrc: [
// Should be quoted
"'self'", "'unsafe-eval'", "'unsafe-inline'",
// Shouldn't be quoted
"*.google", "*.google.com", "*.googleapis.com",
],

最新更新