-
I'd like to add a decorator on top of my Model API for allowing access to authorized consumers.
Does anyone see any downside / negative side-effects with the approach ? The one thing I notice - I must do on the application-defined
Without this - the "metadata" added to the decorated function within
Let me know if the Let me know if there are any other things that I may not have considered. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Yeah, I believe Plus I recommend calling your decorator before @bentoml.api
@auth
def predict(self, inputs, tasks):
pass The bentoml API hasn't promised any behavior of the decorated function now. But the args that the user API function got are well defined. |
Beta Was this translation helpful? Give feedback.
-
@jiyer2016 in general we recommend doing authentication/authorization in a proxy server in front of the API server rather than implementing it in the API server itself because it gives more flexibility for the DevOps/Security side and makes the deployment workflow easier to manage. |
Beta Was this translation helpful? Give feedback.
Yeah, I believe
functools.wraps
is the right thing to do.Plus I recommend calling your decorator before
bentoml.api
like this:The bentoml API hasn't promised any behavior of the decorated function now. But the args that the user API function got are well defined.