https://discord.gg/botpress logo
How do I secure my Bot?
# 🤝help
c
We are trying to create a bot that serves a users secure information from our backend. Naturally, we are looking at securing the bot so that it is only accessible by the given user. We've so far struggled to understand how we should be doing this. When we create and publish a bot, it immediately is accessible from a public URL with no authentication. We can't find a way to add our own auth to the bot (i.e. integrate with auth0) and any form of embedding we do in our own sites with authentication upfront feels insecure, because a malicious agent could brute force the public URL. Are we missing something? How do we prevent there being either a lengthy complicated authentication process for the user when they get into the bot (i.e. home roll it), or how do we make sure there isn't a public authenticated link to the bot outside any application we build around it?
l
Hey 🙂 The share link botpress provides is intentionally public however you can choose to never expose that URL! Treat it as a dev tool for example. If you need strong, request level auth, use the Chat API with manual authentication. https://botpress.com/docs/api-reference/chat-api/introduction https://botpress.com/docs/api-reference/authentication
c
Thanks for taking the time to responsd! Talking with my team, we understand the process of using the ChatApi. When you say never expose the URL. Do you mean you can disable it from being public or you can just consider it a secret? If its the former, how would I go about it? If its the latter, my worry is that the url is reasonably predictable and could be brute forced, how would i protect against that scenario?
w
you can just not use the webchat
and handle everything with the chat API, which as ross said uses manual authentication
you can sign the user keys yourself using JWT and set custom secret keys
uninstalling the webchat integration will also void the public url you're talking about
alternatively you can use the messaging api as well
which is a lot simpler and easier
as the chat api is meant for custom integrations
you could also do that from inside your own workflow by tagging your KB documents with each user's unique identifier, password or something
and then use their tag to run a search on your kb
c
Thanks Shen! We thought of this but couldn't find how to uninstall it (but now have found the uninstall button) - URL is still published but the bot is basically just broken. Is that what you expect?
w
yep it'll never work
now for next steps i recommend setting up the messaging api integration
which is extremely easy
you get one url for sending your inputs to and place the webhook you want to get the answers to
sending responses requires authentication (your personal access token)
c
Cool! We've uninstalled it and It still presents the bot but messages can't be sent or retrieved. I take then I can't just take it down completely? Thanks for the suggest, we were using Chat API but will have a look to see if Messages better fit our use case. Feels like we are going a bit custom and may need it
w
that URL simply points to your bot's webchat configuration JSON file
which has the bot id and other visual elements
so the bot is still there as it has the id, but the channel isn't
i believe you might be able to erase that configuration file altogether using the [Files API](https://botpress.com/docs/api-reference/files-api/how-tos/manage-files)
query [listFiles](https://botpress.com/docs/api-reference/files-api/openapi/endpoints/get-v1files) to get all hidden files (and hopefully your configuration JSON) then [deleteFile](https://botpress.com/docs/api-reference/files-api/openapi/endpoints/delete-v1files) to delete it
c
Understood, this seems to be the bit we were missing to make sure we could secure our API! Thank Again guys!
4 Views