Skip to content

Commit

Permalink
Token time should be int not float
Browse files Browse the repository at this point in the history
  • Loading branch information
Rupert Bryant-Greene committed Aug 8, 2018
1 parent c42cc68 commit c346f2c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/lastkeypair/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ func ClientAwsSession(profile, region string) *session.Session {
}

type PlaintextPayload struct {
NotBefore float64 // this is what json.unmarshal wants
NotAfter float64
NotBefore int64 // this is what json.unmarshal wants
NotAfter int64
}

func kmsClientForKeyId(sess *session.Session, keyId string) *kms.KMS {
Expand All @@ -144,7 +144,7 @@ func kmsClientForKeyId(sess *session.Session, keyId string) *kms.KMS {
func CreateToken(sess *session.Session, params TokenParams, keyId string) Token {
context := params.ToKmsContext()

now := float64(time.Now().Unix())
now := int64(time.Now().Unix())
end := now + 3600 // 1 hour

payload := PlaintextPayload{
Expand Down Expand Up @@ -208,7 +208,7 @@ func ValidateToken(sess *session.Session, token Token, expectedKeyId string) boo
//return nil, errors.Wrap(err, "decoding token json")
}

now := float64(time.Now().Unix())
now := int64(time.Now().Unix())
if now < payload.NotBefore || now > payload.NotAfter {
return false
//return nil, errors.New("expired token")
Expand Down

0 comments on commit c346f2c

Please sign in to comment.