Open dborovcanin opened 10 months ago
Possibilities usage of API Gateway in Magistrala
Authentication and Authorization
Moving Auth PEP (Policy Enforcement Point) out of service
API Aggregation
Basic Data Aggregation
API Gateway Advantages :
Alternative for API Gateway Retrieve Basic data
Domain Delete Process required of following
things
,channels
both in respective repos and their its related policies. groups
in repo and its related policies At present we have HTTP API endpoints for deleting in other entities are:
On receive of delete domain request following steps will taken by the Delete function in Domain Service
auth service
(where the domain service resides) for delete the entities policies.API Gateway act as intermediate proxy for domain delete request Once the domain delete is received in API gateway, it does the following steps :
In this approach , Delete Domain function in Domain service will just change the state of the domain to delete Scheduler will look for the list of Domains with Delete status in Database And picks the list of domains to delete and run individual jobs for each Domains
In Steps:
@arvindh123 Thanks for the report. I have a couple of questions:
My View : We have most of functionalities are working condition except delete flow.
If we have API Gateway, Delete process will take time, if there are 1000 of entities to delete, So API becomes slower and irresponsive
So for now, we can proceed with building gRPC endpoint for removal of Things, channels and groups And , Delete the domain with cleanup job.
Later over time, we can add other gRPC endpoints and after that we can start building API Gateway for other API aggregations For now time being, we can do aggregation in UI Service. I believe, UI service is already doing API Gateway kind of aggregation work.
2 Does it make sense to update Things so that each Thing has its domain? Will that simplify Domain removal?
Adding domain to entities will help partially (50%) in domain delete process. We can have a separate function in each entities repo to delete all entities related to one domain. But for Policy removal we need to send individual request to remove policy . Remove policy works like matching of Subject Object and Relation. This can be done faster, by sending parallel batch delete request to spiceDB.
As I said in previous answer having cleanup job will simply domain delete process for now and API Gateway might not be a right choice for Delete flow as explained in previous comment
This one might also be addressed by API GW: https://github.com/absmach/magistrala-old/pull/269.
Note: We can build our own API Gateway according to our need with https://openresty.org/en/
This may be a part of https://www.github.com/absmach/mgate.
With the recent changes in architecture caused by Auth service and SpiceDB, there is a need for API aggregation. A simple example is Domain removal in Auth svc, which should result in all the Things and Groups (and Users) being removed (from the domain). This causes messy and circular dependencies between Auth and other services. Extracting API aggregation and authorization to API GW would solve this problem. It would also simplify domain services. One more benefit is that it would remove the need for private API because internally, we can have all the data we need (say, when we need an email for users), and API GW will take care that those data are not leaking to the end-user.