Usage for filtering #202
Replies: 1 comment 5 replies
-
Hi @bodgerbarnett. This hinted me at activating discussions on this repo. :) From afar, it does seem like an appropriate use case. E.g. a custom API key setup that would link API keys to a class SiteAPIKey(AbstractAPIKey):
site = models.ForeignKey(Site, on_delete=models.CASCADE) Then you can protect ressources on each behind an API key tied to that domain. The rest of your "events" code would also think in terms of sites and domains, allowing you to filter events once permissions passed. There's probably some fiddling required to carry out to find an appropriate implementation, though. I think the key part is a custom You'll probably also need a custom permissions class to link it to You may also want to consider what the admin should look like. Feel free to look at the actual code to help yourself out, or ask if you need some help. |
Beta Was this translation helpful? Give feedback.
-
I am developing a REST API with DRF for an events site which serves multiple domains. So there's a bunch of events that are particular to SiteA and a load more that are tied to SiteB.
Initially, I was planning to leave the API totally open (for reading) and allow filtering based on the site (something like /events/?site=sitea.com/) but then it occurred to me that anyone can then access every single event in my system which I don't really want.
I'm writing a frontend for it using Nuxt and I wondered about using this library to allow the event filtering. The idea would be that each Site would have it's own API_KEY and the Nuxt frontend would send this along with the HTTP requests to obtain the events. That API_KEY would then be tied to a particular Site in the database and that could be used to only return the appropriate events.
Before I go off down this road, is that a valid usage of this library? It sounds like it is but I just wanted to check that this all makes sense as I'm fairly new to DRF and this sort of thing.
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions