From 2996a9fcde80440c9732e7b46685d1539aa4b028 Mon Sep 17 00:00:00 2001 From: Michael Stahnke Date: Thu, 8 Feb 2024 16:13:23 -0600 Subject: [PATCH] feat(cspp): Send more information to user when requesting an API key Previously, we only sent a string. Now we send some example usage and security messaging around keeping API keys safe. Fixes #31 --- cspp/slack_sender.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cspp/slack_sender.go b/cspp/slack_sender.go index 222ece6..beac48c 100644 --- a/cspp/slack_sender.go +++ b/cspp/slack_sender.go @@ -88,9 +88,19 @@ func sendKeyInDM(slackId string, key string) error { log.Debugln("(sendKeyInDM) slackId", slackId, "key", key) slack_token := viper.GetString("slack_token") api := slack.New(slack_token) + msg := "Your CSPP API key is: `" + key + "`" + ". Please keep it safe and do not share it with anyone. " + msg += "In most cases, you can use your key and the entire CSPP service via something like the following command:\n" + cmd := `curl -X POST \ + -F "image=@/path/to/file" \ + -F "caption=String you want to with the picture" \ + -H "X-API-KEY: $API_KEY" \ + "` + msg += "```" + cmd + "```" + // TODO add the service URI to the message + msg += "\n See /usage for more details." _, _, err := api.PostMessage(slackId, - slack.MsgOptionText(key, false), + slack.MsgOptionText(msg, false), slack.MsgOptionAsUser(true), ) if err != nil {