reprogl
1package security
2
3import (
4"crypto/rand"
5"crypto/sha1"
6"encoding/base64"
7"fmt"
8"time"
9
10"xelbot.com/reprogl/container"
11)
12
13func GetWSSEHeader() (string, string) {
14cnf := container.GetConfig()
15created := time.Now().Format(time.RFC3339)
16
17nonce := make([]byte, 12)
18_, err := rand.Read(nonce)
19if err != nil {
20panic(err)
21}
22
23h := sha1.New()
24h.Write(nonce)
25h.Write([]byte(created))
26h.Write([]byte(cnf.BackendApiWsseKey))
27
28return "X-WSSE", fmt.Sprintf(
29`UsernameToken Username="%s", PasswordDigest="%s", Nonce="%s", Created="%s"`,
30cnf.BackendApiUser,
31base64.StdEncoding.EncodeToString(h.Sum(nil)),
32base64.StdEncoding.EncodeToString(nonce),
33created,
34)
35}
36