我正在尝试使用Google App Engine部署Django应用程序.
我的app.yaml文件:
# [START runtime]
runtime: python
api_version: 1
threadsafe: true
env: flex
entrypoint: gunicorn -b :$PORT wsgi
runtime_config:
python_version: 3.4
env_variables:
CLOUDSQL_CONNECTION_NAME: ugram-mysql
CLOUDSQL_USER: root
handlers:
- url: /
script: wsgi.application
# [END runtime]
Run Code Online (Sandbox Code Playgroud)
但是当我运行时gcloud app deploy,app deploy正在运行(5分钟),但是我收到错误:
Updating service [default]...failed.
ERROR: (gcloud.app.deploy) Error Response: [9]
Application startup error:
/bin/sh: 1: exec: gunicorn: not found
Run Code Online (Sandbox Code Playgroud)
但是已经安装了gunicorn
mysupers-beta:~$ gunicorn
usage: gunicorn [OPTIONS] [APP_MODULE]
gunicorn: error: No application module specified.
Run Code Online (Sandbox Code Playgroud) django google-app-engine wsgi gunicorn google-compute-engine
我构建了一个具有多种服务的网络应用程序:
该应用程序并不小,只有 60k 多行代码。这是一家初创公司。我提到它是为了让你知道我可能根本不会受到黑客或流量的那么多关注。这样我就有了逐步提高的空间。
身份验证是通过 DRF simple jwt 库完成的。访问权限+刷新令牌过期。
我做了安全审计,从安全架构的角度发现了缺陷。我不知道这些问题有多重要,我应该如何解决它们,或者以后可以解决哪些问题。所以我正在寻求解决方案和建议。我更喜欢速度和质量之间的最佳比例,而不是仅仅质量(如果我错过了这一点,请告诉我),因此,如果某件事是“很好有”而不是“重要”,我会将其放入下一个版本的积压中。
如果您愿意,我们可以通过其编号来参考。
我当前的设置:
REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.IsAuthenticated',
),
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.SessionAuthentication',
'rest_framework.authentication.BasicAuthentication',
'rest_framework_simplejwt.authentication.JWTAuthentication',
),
.....
}
Run Code Online (Sandbox Code Playgroud)
正如你所看到的,我有 3 种方法。JWT 可以,但 BasicAuthentication 和 SessionAuthentication 似乎不行。我想要实现的是拥有真正的 JWT 身份验证,并作为 API 视图的唯一身份验证方式(我确实相信我拥有它,直到我发现相反的情况)。
据我了解(可能是错误的),我在生产环境中不需要 SessionAuthentication 和 BasicAuthentication,但我在开发环境中需要,因为它允许我使用登录表单登录 DRF API UI,这对于测试来说很酷。我的说法正确吗?
当我使用 Chrome 开发工具并检查 cookie 时,我感到很沮丧。此时,我在测试中弃用了 SessionAuthentication 和 BasicAuthentication。
据我了解,由于 SessionMiddleware,我拥有会话 id cookie。拥有它是可以的,因为它仅用于管理面板身份验证,并且被 DRF API 视图忽略, …
security django jwt django-rest-framework django-rest-framework-simplejwt
我有一个基于 Django 的项目。我们添加了一堆新的应用程序 (3-4),但服务器不响应任何请求。日志清晰。它甚至不记录 GET/POST 请求。在浏览器中我看到:
\n\nThis site can\xe2\x80\x99t be reached\n\nlocalhost refused to connect.\nRun Code Online (Sandbox Code Playgroud)\n\n我想,这个问题出现在新应用程序中,所以我将其从 中删除INSTALLED_APPS,但结果是相同的。所以我试图找出问题所在settings.py,但结果仍然相同。
之后我通过netstat和检查我的端口nmap,我惊呆了,因为端口 8000 是空的。
root@artem-debian:/home/artem# nmap -sT -O localhost\n\nStarting Nmap 6.47 ( http://nmap.org ) at 2017-05-19 10:20 EEST\nNmap scan report for localhost (127.0.0.1)\nHost is up (0.00018s latency).\nOther addresses for localhost (not scanned): 127.0.0.1\nNot shown: 994 closed ports\nPORT STATE SERVICE\n22/tcp open ssh\n25/tcp open smtp\n111/tcp open rpcbind\n631/tcp open ipp\n902/tcp open iss-realsecure\n3306/tcp open mysql\nDevice …Run Code Online (Sandbox Code Playgroud) 我在将数据保存到数据库中的 def 中遇到了问题。
@staticmethod
def _save(account, proxy,
proxy_provider_id, period,
country, start_date,
price, meta,
account_type, ip):
try:
period = int(period)
end_date = start_date + timedelta(days=period)
prx = Proxy()
prx.account = account
prx.proxy = proxy
prx.proxy_provider_id = proxy_provider_id
prx.period = period,
prx.country = country,
prx.start_date = start_date
prx.end_date = end_date
prx.price = price
prx.meta = meta
prx.ip = ip
print('\n')
print('Save proxy {}'.format(prx))
print('account: {} type {}'.format(account, type(account)))
print('proxy: {} type {}'.format(proxy, type(proxy)))
print('proxy id: {} type {}'.format(proxy_provider_id, type(proxy_provider_id)))
print('country: {} type …Run Code Online (Sandbox Code Playgroud) 首先,我不是经验丰富的React开发人员。只是让你知道。
我有一家商店:
import {observable, action, reaction, computed, autorun} from 'mobx';
import scrollTo from 'react-scroll-to-component'
Run Code Online (Sandbox Code Playgroud)
ActivePostsStore类{
@observable _posts = new Map()
@observable _visiblePosts = new Set()
@computed get visiblePosts() {
return this._visiblePosts
}
@action
addPost(uuid, ref) {
// console.log('add post')
this._posts.set(uuid, ref)
}
@action
scrollToPost(uuid) {
// console.log('scroll to post')
scrollTo(this._posts.get(uuid), {})
}
@action
addVisiblePost(uuid) {
console.log('add vis post', this._visiblePosts.values())
this._visiblePosts.add(uuid)
}
@action
removeVisiblePost(uuid) {
console.log('rem vis post', this._visiblePosts.values())
this._visiblePosts = new Set([...this._visiblePosts].filter(el => el !== uuid))
}
// reacts = …Run Code Online (Sandbox Code Playgroud) django ×4
python ×2
debian ×1
django-orm ×1
django-rest-framework-simplejwt ×1
gunicorn ×1
javascript ×1
jwt ×1
linux ×1
localhost ×1
mobx ×1
mobx-react ×1
python-3.x ×1
security ×1
wsgi ×1