-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Secure the Intercom messenger with Identity Verification (#567)
* Secure the Intercom messenger with Identity Verification
- Loading branch information
1 parent
dd27bba
commit b9386c4
Showing
7 changed files
with
52 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package analytics | ||
|
||
import ( | ||
"crypto/hmac" | ||
"crypto/sha256" | ||
"encoding/hex" | ||
"fmt" | ||
) | ||
|
||
// https://www.intercom.com/help/en/articles/183-set-up-identity-verification-for-web-and-mobile | ||
func GenerateIntercomHmacDigest(email string) (string, error) { | ||
key := []byte(intercomHmacKey) | ||
message := []byte(email) | ||
hash := hmac.New(sha256.New, key) | ||
if _, err := hash.Write(message); err != nil { | ||
return "", fmt.Errorf("failed generating hmac signature for %v, hmac-key-length=%v, reason=%v", | ||
email, len(intercomHmacKey), err) | ||
} | ||
sha := hash.Sum(nil) | ||
return hex.EncodeToString(sha), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
package analytics | ||
|
||
var segmentApiKey string | ||
var ( | ||
segmentApiKey string | ||
intercomHmacKey string | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters