当我尝试在真实设备上使用 Google Pay 付款(在 TEST 环境中)时,我收到标题中的错误消息。
我曾尝试将“网关”更改为像 google docs 显示的字符串,但到目前为止什么都没有。
const DETAILS = {
id: 'COMPANY',
displayItems: [
{
label: 'Phone Bill',
amount: { currency: 'USD', value: compTotal }
}
],
total: {
label: 'COMPANY',
amount: { currency: 'USD', value: compTotal }
}
};
// GOOGLE PAY
const METHOD_DATA = [{
supportedMethods: ['android-pay'],
data: {
supportedNetworks: ['visa', 'mastercard', 'amex'],
currencyCode: 'USD',
environment: 'TEST', // defaults to production
paymentMethodTokenizationParameters: {
tokenizationType: 'GATEWAY_TOKEN',
parameters: {
gateway: 'braintree',
'braintree:tokenizationKey': 'sandbox_XXXXXXXXXXX'
}
}
} …Run Code Online (Sandbox Code Playgroud) javascript react-native-android payment-request-api google-pay
我正在使用 socketio 运行 Flask 应用程序来处理通知。Flask 应用程序正在侦听端口 5000,而客户端在 8080。
js 客户端总是收到这个错误:
VM15520:1 GET http://localhost:5000/socket.io/?EIO=3&transport=polling&t=Mb2_LpO 400 (Bad Request)
Access to XMLHttpRequest at 'http://localhost:5000/socket.io/?EIO=3&transport=polling&t=Mb2_LpO' from origin 'http://localhost:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Run Code Online (Sandbox Code Playgroud)
我实际上是用 gunicorn 启动我的应用程序的,如下所示:
gunicorn --workers=1 --worker-class eventlet --certfile=keys/key.crt --keyfile=keys/key.key --bind 0.0.0.0:5000 myapp.run:app
Run Code Online (Sandbox Code Playgroud)
这是我的 run.py:
import eventlet
from myapp import create_app
eventlet.monkey_patch()
app, celery = create_app('config_prod.py')
Run Code Online (Sandbox Code Playgroud)
我也在我的应用工厂中使用 CORS(app)。
我还尝试将其添加到我的一张蓝图中:
@api.after_request
def after_request(response):
response.headers.add('Access-Control-Allow-Origin', 'http://localhost:8080')
response.headers.add('Access-Control-Allow-Headers',
'Origin, X-Requested-With, Content-Type, Accept, Authorization')
response.headers.add('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS') …Run Code Online (Sandbox Code Playgroud) 我正在使用前端的React.js和服务器端的Django构建一个简单的Web应用程序。
因此frontend.herokuapp.com和backend.herokuapp.com。
当我尝试通过react应用对我的API进行调用时,从API接收到的cookie不会与请求一起发送。
我曾希望我能够支持此配置,而不必做任何特殊的事情,因为所有服务器端请求(我认为)都将由JS客户端应用直接向后端进程发送,并附加其身份验证Cookie。
为了找到我认为可行的解决方案,我尝试设置
SESSION_COOKIE_DOMAIN = "herokuapp.com"
在Production中哪一个虽然不理想(因为herokuapp.com是一个广阔的领域),但在api.myapp.com和www.myapp.com上似乎是相当安全的。
但是,在settings.py中设置此值AuthStateMissing时,在命中/oauth/complete/linkedin-oauth2/端点时会得到一个。
搜索google会AuthStateMissing SESSION_COOKIE_DOMAIN得出一个单独的结果,这意味着该问题被报告为Django社交身份验证中的错误,此后已关闭,无需进一步评论。
任何人都可以抛出的任何光将不胜感激。
我的项目是创建一个输入页面,用于在其中输入一些文本并将其发送到 mysql (phpmyadmin) 。我正在使用 spring-boot 2.1.4 和 Angular 7。提前感谢您的调查!爱
我专注于 GraphController.java 并尝试使用@CrossOrigin. 我试图在全局中调用它,但什么也没有......这是我的来源https://spring.io/blog/2015/06/08/cors-support-in-spring-framework
我也什么也没尝试
我的实体(Graph.java)
@Entity(name = "graphiques")
@Table(name ="graphiques")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Graph {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name ="id")
private Long id;
@Column(name ="xml")
private String xml;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getXml() {
return xml;
}
public void setXml(String xml) {
this.xml = xml;
}
}
Run Code Online (Sandbox Code Playgroud)
我的 GraphController.java
@RestController …Run Code Online (Sandbox Code Playgroud) 我已经构建了一个 spa 网站,前端使用 Angular,服务器端使用 asp.net Core Web Api 3.0。
我正在尝试配置 Windows 身份验证,感谢这篇文章到目前为止一切顺利!但是...当 Api 正确返回 401/403 时,CORS 标头会出现问题,cors 标头会丢失。这是一个例子:
General:
Status Code: 403 Forbidden
Remote Address: [::1]:44389
Referrer Policy: no-referrer-when-downgrade
Response-Headers:
Date: Wed, 20 Nov 2019 16:33:57 GMT
Persistent-Auth: true
Server: Microsoft-IIS/10.0
Transfer-Encoding: chunked
X-Powered-By: ASP.NET
Run Code Online (Sandbox Code Playgroud)
这是我使用该属性时生成的[Authorise]。我遇到的问题是,当 CORS 标头丢失时,角度内的状态代码为 0,因此我的 http 拦截器不知道未经授权,并且无法正确处理重定向。
我尝试使用中间件手动添加标头StartUp:
app.Use(async (context, next) =>
{
context.Response.OnStarting(() =>
{
context.Response.Headers.Add("Access-Control-Allow-Origin", "http://localhost:4200");
return Task.FromResult(0);
});
await next();
});
Run Code Online (Sandbox Code Playgroud)
但这不起作用,中间件仍然删除标头。
有趣的是,如果我删除授权属性并在控制器方法中返回 401/403:
[HttpGet]
public IActionResult …Run Code Online (Sandbox Code Playgroud) 我一直在我的网站上运行新闻 api,并通过将文件拖到网络浏览器中来在我的计算机上进行测试,网址会像这样显示file:///C:。然后我会将所有更改上传到我的 GitHub 存储库并在 Github 页面上运行它https://name.github.io/repository/。
很长一段时间一切都工作正常,但最终 API 停止工作并在控制台中显示错误Access to fetch at 'https://newsapi.org/v2/everything?xx' from origin 'https://name.github.io' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
我尝试添加mode: 'no-cors'到提取中,但它不起作用return response.json();
我的函数如下所示:
const url = 'https://newsapi.org/v2/everything?' +
'qInTitle=""&' +
`from=` +
'language=en&' +
'apiKey=';
const req = new Request(url); …Run Code Online (Sandbox Code Playgroud) 在我的网络应用程序中,csrf 令牌工作正常。但我想禁用从我的 Android 应用程序进行 API 调用的 API 调用。我正在为我的 API 使用另一种身份验证。请告诉我如何禁用 API 控制器的所有功能的 csrf 令牌。我尝试在控制器中添加访问权限作为标头,但它不起作用。请帮我。
public function __construct() {
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow- Methods: POST, GET, PUT, DELETE, OPTIONS');
}
Run Code Online (Sandbox Code Playgroud) 我有一个 iframe 标签,其中 src 是不同服务器上的另一个网页。我有能力修改两个站点的标题。在开始实施控制安全策略之前,我能够单击 iframe 内的按钮并检索 GPS 坐标。我相信控制安全策略会阻止我的父站点运行 Geolocation API。
父站点的代码:
<customHeaders>
<add name="Content-Security-Policy" value="frame-src 'self' https://MyChildSite.com" />
</customHeaders>
Run Code Online (Sandbox Code Playgroud)
<html>
<iframe src="https://MyChildSite.com" allow="geolocation"></iframe>
</html>
Run Code Online (Sandbox Code Playgroud)
子站点的代码:
<customHeaders>
<add name="Content-Security-Policy" value="frame-src 'self' https://MyParentSite.com" />
<add name="Feature-Policy" value="geolocation 'self' https://MyParentSite.com" />
</customHeaders>
Run Code Online (Sandbox Code Playgroud)
<html>
<button onclick="getCoordinates()">Get GPS</button>
...list some stuff
</html>
Run Code Online (Sandbox Code Playgroud)
当我通过父站点单击子站点上的按钮时,我没有从坐标中得到我期望的响应。这个问题有方法解决吗?
TLDR:我在使用 Material-UI(服务器端渲染)为 NextJS 设置 CSP 并由 Nginx(使用反向代理)提供服务时遇到问题。
目前我在加载 Material-UI 样式表和加载我自己的样式时遇到问题
使用makeStyles来自@material-ui/core/styles
笔记:
nonce值,因为 nonce 生成为不可预测的字符串.default.conf (nginx)
# https://www.acunetix.com/blog/web-security-zone/hardening-nginx/
upstream nextjs_upstream {
server localhost:3000;
# We could add additional servers here for load-balancing
}
server {
listen $PORT default_server;
# redirect http to https. use only in production
# if ($http_x_forwarded_proto != 'https') {
# rewrite ^(.*) https://$host$request_uri redirect;
# }
server_name _;
server_tokens off;
proxy_http_version …Run Code Online (Sandbox Code Playgroud) 我的哈巴狗的元标签中有类似的东西。我的文件中有大量 2 3 CDN。
meta(http-equiv='Content-Security-Policy' content="default-src * 'unsafe-inline' 'unsafe-eval'; script-src-elem * 'unsafe-inline';" )
Run Code Online (Sandbox Code Playgroud)
尽管我已经定义了 script-src-elem,但我收到类似这样的错误。
Refused to load the script '<URL>' because it violates the following Content Security Policy directive: "script-src 'self'". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.
我将衷心感谢您的帮助。先感谢您
cors ×3
angular ×2
javascript ×2
cookies ×1
cross-domain ×1
csrf-token ×1
django ×1
flask ×1
geolocation ×1
google-pay ×1
heroku ×1
iframe ×1
java ×1
material-ui ×1
next.js ×1
nginx ×1
node.js ×1
ocsp ×1
php ×1
pug ×1
python ×1
socket.io ×1
spring-boot ×1