Django admin + authentication system in microservice architecture
Asked Answered
Y

1

11

I have a large Django project which is basically a monolith containing apps. I need to break it to microservices.

I have 2 questions that I couldn't find a clear answers to:

  1. 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.

  2. 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?

Yorgo answered 20/5, 2018 at 14:13 Comment(0)
E
2

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.

Yes, you can but it may not access the other microservices databases (neither write nor read). This means that if the Admin microservice update some Article (or whatever entity types you have, this is just an example) then this is not reflected immediately in the microservice that displays that Article. You need to have some mechanism to transfer the updates from the Admin to the other microservices. So shared databases/tables is not an option.

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?

Yes, but you need to split it into two sides. One side is responsible for managing users and roles/permissions and the other is responsible to authenticate the users and to check if a user may perform some action.

The first side should be a microservices (the creation/administration or users and the managing of roles/permissions).

The checking part can be a microservice but those responsibilities are in general taken by the API gateway or by a module (+ local, replicated data) in every microservice that need authentication or authorisation. These are cross-cutting concerns. If they reside in a separate microservice then there is the problem of resilience: if that microservice fails then it brings down you entire system.

Exigent answered 21/5, 2018 at 8:11 Comment(3)
Currently Admin is a reflections of the models. If I take (using your example) Articles management to a microservice then the model is there with its own DB. You didn't say how can I show on my working Admin, models from other microservice. As for the update itself, I would want it to be updated through REST between Admin service to the Article one.Yorgo
@Yorgo 1/2. you can see models from other microservices inside one microservice but as a different model. Models should not be fully imported. In Domain Driven Design there is a component that has the responsibility of importing remote models: The Anti-corruption layer; it takes remote models as input and produces local models as output. In 99% of cases the local models are different (with less properties) than the remote ones (the sources).Exigent
@Yorgo 2/2. For example, the Articles management system has only the ID and the Title of the Published article or an URL to it, and not all the properties, with the purpose of showing a link to it in the Admin Panel.Exigent

© 2022 - 2024 — McMap. All rights reserved.