Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃殌 Feature: Support for Middleware/Plugins #2358

Open
2 tasks done
Exadra37 opened this issue Oct 27, 2021 · 3 comments
Open
2 tasks done

馃殌 Feature: Support for Middleware/Plugins #2358

Exadra37 opened this issue Oct 27, 2021 · 3 comments
Assignees
Labels
discussion Gathering community feedback product / databases Fixes and upgrades for the Appwrite Database.

Comments

@Exadra37
Copy link

Exadra37 commented Oct 27, 2021

馃敄 Feature description

Whatever the name convention we may want to use, Middleware or Plugins, the goal is to have some way for the developer to be able to hook into the request and response life cycles of Appwrite in order to be able to add further functionality without the need for it to be implemented by Appwrite core-team itself.

Middleware support would allow us to run custom code on each request/response handled by AppWrite for the client.

The middleware could hook in several places of the request and response lifecycle of Apprwrite to give total flexibility to the developer.

Some possible example hooks:

  • start of processing request
  • authentication (before and after)
  • end of processing request
  • start of processing response
  • end of processing response

This approach is used by some popular API Gateways to give flexibility to the developers in how they can use the platform without being limited by what the core team can offer.

馃帳 Pitch

This could be useful to:

  • Check third-party JWT tokens, that are not created by Appwrite, therefore cannot be checked with the current Appwrite implementation.
  • Implement third-party security solutions that would strength what is already done by Appwrite.
  • Implement a replica of the Firebase App Check.
  • Other use cases where the developer needs to customize how the request/response is handled before it reaches the start and/or end of the normal AppWrite flow.

馃憖 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

馃彚 Have you read the Code of Conduct?

@moshOntong-IT
Copy link

I have this feature approach:

Permission Extension this feature could possibly solve the limitations of setting up the permission of such collection, documents, function execution and etc. But this feature is I think is a good approach. Middleware could solve all the limitations.

Cloud function might be to extend the backend of appwrite. But middleware is also be good idea.

@moshOntong-IT
Copy link

what is the status for this issue. This issue has been 2 years.

@moshOntong-IT
Copy link

I am thinking that what if we have Guard in setting tab of each collection:
image

So what is Guard?

Guard is a middleware that always returns boolean. If returns true, then it can be proceed to next process. Otherwise it throws an error.

So what is the process of creating Guard?

It will utilize the cloud function. It means we can attach a cloud function in Guard or ID reference from any function. Below picture is will be the UI of how to attach functions. Yes it could be a list of function. So that it will be scalable or flexible I think? 馃槈

image

Why Cloud Functions?

  • Firstly, we can use various programming language. So then it will also a good developer experience, so we should not have to learn another syntax on how to create a middleware plugin codes.

  • Second, security since we cloud function needs an API key or jwt session.

  • Thirdly, since this is about preprocessing, we can take advantage of the cloud function because cloud function is we can access some of API of appwrite like, fetching documents, fetching users, fetching storage, etc.

  • Fourthly, the cloud function provide res,req,log and error, So it not hassle to how to get the req.body.

What we need feature to add in cloud function

  • I am thinking right now that we should add method of res.resolver(true) or res.resolver(false). This is a response that we can proceed to next process/post process.

What should be the disadvantage of using cloud function?

  • It will takes more time (but it depends on how the developer create guard function).

@eldadfux eldadfux added the discussion Gathering community feedback label Feb 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Gathering community feedback product / databases Fixes and upgrades for the Appwrite Database.
Projects
None yet
Development

No branches or pull requests

5 participants