Page MenuHomeMusing Studio

auth.go
No OneTemporary

package auth
import (
uuid "github.com/nu7hatch/gouuid"
"github.com/writeas/web-core/log"
"strings"
)
// GetToken parses out the user token from either an Authorization header or simply passed in.
func GetToken(header string) []byte {
var accessToken []byte
token := header
if len(header) > 0 {
f := strings.Fields(header)
if len(f) == 2 && f[0] == "Token" {
token = f[1]
}
}
t, err := uuid.ParseHex(token)
if err != nil {
log.Error("Couldn't parseHex on '%s': %v", accessToken, err)
} else {
accessToken = t[:]
}
return accessToken
}
// GetHeaderToken parses out the user token from an Authorization header.
func GetHeaderToken(header string) []byte {
var accessToken []byte
if len(header) > 0 {
f := strings.Fields(header)
if len(f) == 2 && f[0] == "Token" {
t, err := uuid.ParseHex(f[1])
if err != nil {
log.Error("Couldn't parseHex on '%s': %v", accessToken, err)
} else {
accessToken = t[:]
}
}
}
return accessToken
}

File Metadata

Mime Type
text/plain
Expires
Sun, Apr 6, 6:50 AM (6 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3187607

Event Timeline