-
Notifications
You must be signed in to change notification settings - Fork 2
/
authorization.go
42 lines (34 loc) · 900 Bytes
/
authorization.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package omisego
import (
"encoding/base64"
)
type Authorization interface {
CreateAuthorizationHeader() string
}
type AdminAuth struct {
UserId string
UserAuthToken string
}
type ProviderAuth struct {
AccessKey string
SecretKey string
}
type ClientAuth struct {
ApiKey string
AuthenicationToken string
}
func (a *AdminAuth) CreateAuthorizationHeader() string {
data := []byte(a.UserId + ":" + a.UserAuthToken)
str := base64.StdEncoding.EncodeToString(data)
return "OMGAdmin " + str
}
func (s *ProviderAuth) CreateAuthorizationHeader() string {
data := []byte(s.AccessKey + ":" + s.SecretKey)
str := base64.StdEncoding.EncodeToString(data)
return "OMGProvider " + str
}
func (c *ClientAuth) CreateAuthorizationHeader() string {
data := []byte(c.ApiKey + ":" + c.AuthenicationToken)
str := base64.StdEncoding.EncodeToString(data)
return "OMGClient " + str
}