微服务架构中的Django admin + 认证系统

标签 django django-rest-framework django-admin microservices django-apps

我有一个大型 Django 项目,它基本上是一个包含应用程序的整体。 我需要将其分解为微服务。

我有两个问题无法找到明确的答案:

  1. 目前我们广泛使用 Django admin,我想知道它是否 一旦单体被破坏,就可以继续使用它。它的意思是 读取和操作“使用的”中所有微服务的数据 来处理“UI。这也将有助于这个过程更顺利地完成。

  2. 身份验证和授权 - 我们仍然可以使用 这是微服务架构中内置的“应用程序”吗?是否可以 仅将此配对带到另一个服务并与其通信 通过 HTTP?

最佳答案

Currently we're using Django admin extensively and I wonder if it's possible to continue using it once the monolith is broken. It means reading and manipulating data from all the microservices in a "used to work on" UI. It would also be helpful for this process to be done more smoothly.

是的,您可以,但它可能无法访问其他微服务数据库(既不写入也不读取)。这意味着,如果管理微服务更新某些文章(或您拥有的任何实体类型,这只是一个示例),那么这不会立即反射(reflect)在显示该文章的微服务中。您需要有某种机制将更新从管理员传输到其他微服务。因此共享数据库/表不是一个选项。

Authentication and authorization - Would we still be able to use this built in "app" in a microservice architecture? Is it possible to take this pare only to another service and communicate with it over HTTP?

是的,但是你需要将其分成两侧。一侧负责管理用户和角色/权限,另一侧负责对用户进行身份验证并检查用户是否可以执行某些操作。

第一方应该是微服务(创建/管理或用户以及角色/权限的管理)。

检查部分可以是微服务,但这些职责通常由 API 网关或每个需要身份验证或授权的微服务中的模块(+本地、复制数据)承担。这些都是跨领域的问题。如果它们驻留在单独的微服务中,则会出现弹性问题:如果该微服务发生故障,则会导致整个系统瘫痪。

关于微服务架构中的Django admin + 认证系统,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50435696/

相关文章:

jquery - 通过 jQuery ajax 调用将值列表传递给 django View

python - 代码更新时停止 uwsgi

Python——Curl 可以工作,而 requests lib 不行

python - 外部库中的 PyCharm 断点

python - django-tinymce 无法正确显示小部件

python - Django admin 中同一模型的多个 ModelAdmins/ View

python - 我的 Django Web 中的简单搜索引擎无法正常工作

javascript - 为什么我的 javascript 方法没有被调用?

带有 GET 参数的基于 Django 类的 View

python - 寻找一种在 Django admin 中显示代码块的简单方法