EdgeAuth-Token-Golang is Akamai Edge Authorization Token in the HTTP Cookie, Query String and Header for a client. You can configure it in the Property Manager at https://control.akamai.com. It's the behaviors which is Auth Token 2.0 Verification and Segmented Media Protection.
EdgeAuth-Token-Golang supports for Golang 1.x
To install Akamai Edge Authorization Token with dep:
$ dep ensure -add github.com/mobilerider/EdgeAuth-Token-Golang
package main
import "github.com/mobilerider/EdgeAuth-Token-Golang/edgeauth"
func main {
acl := "/s/c/m/f/5/9/2/f5929e909d4/*"
key := "52a152a152a152a152a152a152a1"
config := &edgeauth.Config{
Algo: crypto.SHA256,
Key: sampleKey,
DurationWindow: 300 * time.Second,
}
client := edgeauth.NewClient(config)
token, err := client.GenerateToken(acl, false)
if err != nil {
// Handle error
}
// Use generated token
// token would be in the form of:
// exp=1562609231~acl=/s/c/m/f/5/9/2/f5929e909d4/*~hmac=7a6bd5d5abdad74bda765b4da67b7ad54b6a4d6ba54d67b4ad76b4
// You will probably use that token as a value of a cookie
// or query string parameter, the name of the parameter is
// configured via PM
}
- ACL can use the wildcard(*, ?) in the path.
- Don't use '!' in your path because it's ACL Delimiter
- Use 'escapeEarly=false' as default setting but it doesn't matter turning on/off 'Escape token input' option in the Property Manager
type Config struct {
Algo crypto.Hash
Key string
Salt string
FieldDelimiter string
ACLDelimiter string
StartTime time.Time
EndTime time.Time
DurationWindow time.Duration
IP string
SessionID string
Payload string
Verbose bool
}
Parameter | Description |
---|---|
Key | Secret required to generate the token. It must be hexadecimal digit string with even-length. |
Algo | Algorithm to use to generate the token. ('sha1', 'sha256', or 'md5') [ Default: 'sha256' ] |
Salt | Additional data validated by the token but NOT included in the token body. (It will be deprecated) |
StartTime | What is the start time? (Use string 'now' for the current time) |
EndTime | When does this token expire? endTime overrides windowSeconds |
DurationWindow | How long is this token valid for? |
FieldDelimiter | Character used to delimit token body fields. [ Default: ~ ] |
AclDelimiter | Character used to delimit acl. [ Default: ! ] |
EscapeEarly | Not implemented yet. |
Verbose | Not implemented yet. |
client.GenerateToken(value, isUrl) {}
Parameter | Description |
---|---|
value | Single URL path or Access Control List (String) |
isUrl | Wether passed value is a url or not (Boolean) |
If you use the Segmented Media Protection behavior in AMD(Adaptive Media Delivery) Product, tokenName(options.tokenName) should be 'hdnts'.
- Implement EscapeEarly option
- Implement Verbose option