예제 #1
0
파일: options.go 프로젝트: 18F/hmacproxy
func validateAuthParams(opts *HmacProxyOpts, msgs []string) []string {
	var err error
	opts.Digest.ID, err = hmacauth.DigestNameToCryptoHash(opts.Digest.Name)
	if err != nil {
		msgs = append(msgs, "unsupported digest: "+opts.Digest.Name)
	}
	if opts.Secret == "" {
		msgs = append(msgs, "no secret specified")
	}
	if opts.SignHeader == "" {
		msgs = append(msgs, "no signature header specified")
	}
	return msgs
}
예제 #2
0
func parseSignatureKey(o *Options, msgs []string) []string {
	if o.SignatureKey == "" {
		return msgs
	}

	components := strings.Split(o.SignatureKey, ":")
	if len(components) != 2 {
		return append(msgs, "invalid signature hash:key spec: "+
			o.SignatureKey)
	}

	algorithm, secretKey := components[0], components[1]
	if hash, err := hmacauth.DigestNameToCryptoHash(algorithm); err != nil {
		return append(msgs, "unsupported signature hash algorithm: "+
			o.SignatureKey)
	} else {
		o.signatureData = &SignatureData{hash, secretKey}
	}
	return msgs
}