how to config AUTH in mastra cloud?

Hi, whats the right way to protect a deployment on mastra cloud? i'm using the middleware to add a custom API endpoint, I can access it on the dashboard but i cannot see the "agents" and "workflows" i understand this is due to the middleware, but whats the right way to do this?
8 Replies
_roamin_
_roamin_7d ago
Hi @bryan_3mavericks ! Which auth middleware are you using?
bryan_3mavericks
bryan_3mavericksOP7d ago
Middleware
Apply custom middleware functions to intercept requests.
bryan_3mavericks
bryan_3mavericksOP6d ago
i customized it for my own use case. when i deployed to mastra cloud, i need to use my own API key to invoke the api. It's just in the playground, i cannot see the agents/workflows anymore perhaps im doing wrong. But i just want to deploy to mastra cloud and protect the endpoints, and still be able to see the agents in playground
_roamin_
_roamin_6d ago
I see! Thanks for the additional info. Yes, that's because the playground uses the API and since it doesn't send the API key, nothing gets displayed. Let me check something.
bryan_3mavericks
bryan_3mavericksOP6d ago
ya i figured that, is there a way to fix that? its great to see the deployment + playground on cloud, just need to protect it
_roamin_
_roamin_6d ago
Do you need to provide the API key in a header?
bryan_3mavericks
bryan_3mavericksOP6d ago
ideally, im calling from other places. how do you guys usually do this? the deployment can't be just open to public right i fixed it. thanks
_roamin_
_roamin_6d ago
So, usually people use our experimental_auth approach instead of a normal middleware, you basicaly need to implement one of our already made auth provider, or implement our MastraAuthProvider class (these basically use the usual authorization: bearer ... approach.) We don't support other ways of authentication at the moment, but we'll be adding the ability to add custom headers through the playground.

Did you find this page helpful?