我目前正在使用ReactJS构建一个单页应用程序。

我读到不使用localStorage的原因之一是因为XSS漏洞。

既然React会转义所有用户输入,那么现在使用localStorage是否安全呢?

我知道基于cookie的身份验证。SSL和HttpOnly标志可以应用于保护基于cookie的身份验证不受MITM和XSS的影响。然而,为了保护它不受CSRF的影响,还需要采取更多的特殊措施。它们只是有点复杂。(参考)

最近,我发现JSON Web Token (JWT)作为一种身份验证解决方案非常热门。我了解编码、解码和验证JWT的知识。然而,我不明白为什么有些网站/教程告诉我们,如果使用JWT,就不需要CSRF保护。我已经阅读了很多,并试图总结以下问题。我只是希望有人能提供一个关于JWT的更大的图景,并澄清我对JWT的误解。

If the JWT is stored in a cookie, I think it is the same as cookie-based authentication except that the server does not need to have sessions to verify the cookie/token. There is still a risk of CSRF if no special measure is implemented. Isn't JWT stored in a cookie? If the JWT is stored in localStorage/sessionStorage, then there is no cookie involved so don't need to protect against CSRF. The question is how to send the JWT to the server. I found here that it is suggested to use jQuery to send the JWT by HTTP header of ajax requests. So, only the ajax requests can do the authentication? Also, I found one more blog that points to use "Authorization header" and "Bearer" to send the JWT. I don't understand the method the blog talks about. Could someone please explain more about "Authorization header" and "Bearer"? Does this make the JWT transmitted by HTTP header of ALL requests? If yes, what about CSRF?

使用Flask,我如何读取HTTP头?我想检查客户端发送的授权头。

我怎么能检查用户是否从HTML5中的<select>字段选择了一些东西?

我看到<select>不支持新的必需属性…我必须使用JavaScript吗?还是我遗漏了什么?:/

我正在做一个网站,用户可以登录和下载文件,使用Flask微框架(基于Werkzeug),它使用Python(在我的情况下是2.6)。

我需要在用户登录时获得用户的IP地址(用于登录目的)。 有人知道怎么做吗?肯定有一种方法可以用Python来实现吗?

如何在SQLAlchemy中执行原始SQL ?

我有一个python web应用程序,运行在flask和接口到数据库通过SQLAlchemy。

我需要一种方法来运行原始SQL。该查询涉及多个表连接和内联视图。

我试过了:

connection = db.session.connection()
connection.execute( <sql here> )

但是我总是得到网关错误。

是否有可能做一个选择语句,只采取非空值?

现在我正在使用这个:

SELECT * FROM table

然后我要用php循环过滤空值。

有没有办法做到:

SELECT * (that are NOT NULL) FROM table

?

现在当我选择*时,我得到val1,val2,val3,null,val4,val5,null,null等....但我只想得到结果中不为空的值。这可能不使用循环过滤吗?

我使用核心数据与云工具包,因此要检查iCloud用户状态在应用程序启动。如果出现问题,我想向用户发出一个对话框,我使用UIApplication.shared.keyWindow?. rootviewcontroller ?.present(…)到目前为止。

在Xcode 11 beta 4中,现在有一个新的弃用消息,告诉我:

'keyWindow'在iOS 13.0中已弃用:不应该用于支持多个场景的应用程序,因为它在所有连接的场景中返回一个键窗口

我应该如何呈现对话呢?

自从我安装了iOS 13.2测试版后,我一直收到一个调试控制台错误消息。每次我在故事板中加载带有WKWebView对象的ViewController时都会发生这种情况。

然后,下面的消息不断显示,而web视图是可见的 ...

2019-10-10 12:10:47.867830+0200 (...) [Process] kill() returned unexpected error 1  
2019-10-10 12:10:47.908698+0200 (...) [Process] kill() returned unexpected error 1  
2019-10-10 12:10:47.908814+0200 (...) [Process] kill() returned unexpected error 1  
2019-10-10 12:10:47.934169+0200 (...) [Process] kill() returned unexpected error 1  
2019-10-10 12:10:47.947668+0200 (...) [Process] kill() returned unexpected error 1  
2019-10-10 12:10:47.964375+0200 (...) [Process] kill() returned unexpected error 1  
2019-10-10 12:10:48.193556+0200 (...) [Process] kill() returned unexpected error 1  
2019-10-10 12:10:48.193723+0200 (...) [Process] kill() returned unexpected error 1  
2019-10-10 12:10:48.193941+0200 (...) [Process] kill() returned unexpected error 1  
2019-10-10 12:10:48.194012+0200 (...) [Process] kill() returned unexpected error 1  
2019-10-10 12:10:48.195679+0200 (...) [Process] kill() returned unexpected error 1  
2019-10-10 12:10:48.200432+0200 (...) [Process] kill() returned unexpected error 1  
2019-10-10 12:10:48.207225+0200 (...) [Process] kill() returned unexpected error 1  
2019-10-10 12:10:48.207298+0200 (...) [Process] kill() returned unexpected error 1 

在我关闭视图的那一刻,我得到了以下消息:

2019-10-10 12:32:41.577505+0200 (...)[ProcessSuspension] 0x1051e50b0 - ProcessAssertion::processAssertionWasInvalidated() 

有时我会在web视图加载的过程中收到以下消息:(我不能说什么时候发生的)

2019-10-10 12:33:11.453528+0200 (...) Could not signal service com.apple.WebKit.WebContent: 113: Could not find specified service
2019-10-10 12:33:11.459713+0200 (...) Could not signal service com.apple.WebKit.Networking: 113: Could not find specified service

如果我触摸屏幕,它会重新开始

    2019-10-10 12:10:48.200432+0200 (...) [Process] kill() returned unexpected error 1  
    2019-10-10 12:10:48.207225+0200 (...) [Process] kill() returned unexpected error 1  
    2019-10-10 12:10:48.207298+0200 (...) [Process] kill() returned unexpected error 1 
...

我已经检查了,这是发生在所有的视图控制器与我的应用程序的WKWebViews,所以它似乎不是一个代码错误。

这不会使应用程序崩溃,但我想知道为什么会发生这种情况,如果其他人也有同样的问题。

我有一个Flask服务器通过端口5000运行,它很好。我可以在http://example.com:5000上访问它

但是是否可以通过http://example.com访问呢?我假设这意味着我必须将端口从5000更改为80。但是当我在Flask上尝试时,当我运行它时,我得到这个错误消息。

Traceback (most recent call last):
  File "xxxxxx.py", line 31, in <module>
app.run(host="0.0.0.0", port=int("80"), debug=True)
   File "/usr/local/lib/python2.6/dist-packages/flask/app.py", line 772, in run
run_simple(host, port, self, **options)
  File "/usr/local/lib/python2.6/dist-packages/werkzeug/serving.py", line 706, in run_simple
    test_socket.bind((hostname, port))
  File "<string>", line 1, in bind
socket.error: [Errno 98] Address already in use

运行lsof -i:80返回

COMMAND   PID     USER   FD   TYPE   DEVICE SIZE/OFF NODE NAME
apache2   467     root    3u  IPv4 92108840      0t0  TCP *:www (LISTEN)
apache2  4413 www-data    3u  IPv4 92108840      0t0  TCP *:www (LISTEN)
apache2 14346 www-data    3u  IPv4 92108840      0t0  TCP *:www (LISTEN)
apache2 14570 www-data    3u  IPv4 92108840      0t0  TCP *:www (LISTEN)
apache2 14571 www-data    3u  IPv4 92108840      0t0  TCP *:www (LISTEN)
apache2 14573 www-data    3u  IPv4 92108840      0t0  TCP *:www (LISTEN)

我需要先终止这些进程吗?这样安全吗?或者有没有另一种方法来保持Flask在端口5000上运行,但有主网站域名以某种方式重定向?