@@ -6,10 +6,8 @@ import (
66 "encoding/base64"
77 "encoding/hex"
88 "net/url"
9- "strconv"
109 "time"
1110
12- "github.com/mozilla-services/stubattribution/stubservice/metrics"
1311 "github.com/pkg/errors"
1412 "github.com/sirupsen/logrus"
1513)
@@ -66,13 +64,6 @@ func (v *Validator) Validate(code, sig string) (string, error) {
6664 }
6765 }
6866
69- if since , err := v .validateTimestamp (vals .Get ("timestamp" )); err != nil {
70- if since > 0 {
71- logEntry = logEntry .WithField ("timestamp_age" , since .Seconds ())
72- }
73- logEntry .WithError (err ).WithField ("code_ts" , vals .Get ("timestamp" )).Error ("could not validate timestamp" )
74- return "" , err
75- }
7667 vals .Del ("timestamp" )
7768
7869 // all keys are valid
@@ -106,26 +97,6 @@ func (v *Validator) validateSignature(code, sig string) error {
10697 return checkMAC ([]byte (v .HMACKey ), []byte (code ), sigBytes )
10798}
10899
109- func (v * Validator ) validateTimestamp (ts string ) (since time.Duration , err error ) {
110- if ts == "" {
111- return since , nil
112- }
113-
114- tsInt , err := strconv .ParseInt (ts , 10 , 64 )
115- if err != nil {
116- return since , errors .Wrap (err , "Atoi" )
117- }
118-
119- t := time .Unix (tsInt , 0 )
120- since = time .Since (t )
121- metrics .Statsd .Histogram ("attributioncode.validator.timestamp.age" , since .Seconds ())
122- if since > v .Timeout {
123- return since , errors .Errorf ("Timestamp: %s is older than timeout: %v" , t .UTC (), v .Timeout )
124- }
125-
126- return since , nil
127- }
128-
129100func checkMAC (key , msg , msgMAC []byte ) error {
130101 mac := hmac .New (sha256 .New , key )
131102 mac .Write (msg )
0 commit comments