(w http.ResponseWriter, r *http.Request)
| 1507 | } |
| 1508 | |
| 1509 | func (v *SignatureAuthenticator) Authenticate(w http.ResponseWriter, r *http.Request) { |
| 1510 | result, headerSig, computedSig := v.auth.AuthenticateRequest(r) |
| 1511 | |
| 1512 | var msg string |
| 1513 | switch result { |
| 1514 | case hmacauth.ResultNoSignature: |
| 1515 | msg = "no signature received" |
| 1516 | case hmacauth.ResultMatch: |
| 1517 | msg = "signatures match" |
| 1518 | case hmacauth.ResultMismatch: |
| 1519 | msg = fmt.Sprintf( |
| 1520 | "signatures do not match:\n received: %s\n computed: %s", |
| 1521 | headerSig, |
| 1522 | computedSig) |
| 1523 | default: |
| 1524 | panic("unknown result value: " + result.String()) |
| 1525 | } |
| 1526 | |
| 1527 | _, err := w.Write([]byte(msg)) |
| 1528 | if err != nil { |
| 1529 | panic(err) |
| 1530 | } |
| 1531 | } |
| 1532 | |
| 1533 | type SignatureTest struct { |
| 1534 | opts *options.Options |
nothing calls this directly
no test coverage detected