Skip to content

Commit

Permalink
feat(cspp): Send more information to user when requesting an API key
Browse files Browse the repository at this point in the history
Previously, we only sent a string. Now we send some example usage and security
messaging around keeping API keys safe.

Fixes #31
  • Loading branch information
Michael Stahnke committed Feb 8, 2024
1 parent c783cd9 commit 2996a9f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion cspp/slack_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
<service URI>"`
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 {
Expand Down

0 comments on commit 2996a9f

Please sign in to comment.