}
return &arvados.APIClientAuthorization{
- UUID: uuid,
- APIToken: token,
- ExpiresAt: "",
- Scopes: scopes}, nil
+ UUID: uuid,
+ APIToken: token,
+ Scopes: scopes}, nil
}
// Extract the auth token supplied in req, and replace it with a
var aca arvados.APIClientAuthorization
c.Check(json.NewDecoder(resp.Body).Decode(&aca), check.IsNil)
c.Check(aca.ExpiresAt, check.NotNil) // Time.Now()+BlobSigningTTL
- t, _ := time.Parse(time.RFC3339Nano, aca.ExpiresAt)
+ t := aca.ExpiresAt
c.Check(t.After(time.Now().Add(s.testHandler.Cluster.API.MaxTokenLifetime.Duration())), check.Equals, true)
c.Check(t.Before(time.Now().Add(s.testHandler.Cluster.Collections.BlobSigningTTL.Duration())), check.Equals, true)
}
tokensecret = tokenparts[2]
}
}
- var exp sql.NullString
+ var exp sql.NullTime
var scopes []byte
err = tx.QueryRowxContext(ctx, "select uuid, api_token, expires_at, scopes from api_client_authorizations where api_token=$1", tokensecret).Scan(&resp.UUID, &resp.APIToken, &exp, &scopes)
if err != nil {
return
}
- resp.ExpiresAt = exp.String
+ resp.ExpiresAt = exp.Time
if len(scopes) > 0 {
err = json.Unmarshal(scopes, &resp.Scopes)
if err != nil {
// cached positive result
aca := cached.(arvados.APIClientAuthorization)
var expiring bool
- if aca.ExpiresAt != "" {
- t, err := time.Parse(time.RFC3339Nano, aca.ExpiresAt)
- if err != nil {
- return fmt.Errorf("error parsing expires_at value: %w", err)
- }
+ if !aca.ExpiresAt.IsZero() {
+ t := aca.ExpiresAt
expiring = t.Before(time.Now().Add(time.Minute))
}
if !expiring {
if err != nil {
return err
}
- aca.ExpiresAt = exp.Format(time.RFC3339Nano)
+ aca.ExpiresAt = exp
ta.cache.Add(tok, aca)
return nil
}
CreatedByIPAddress string `json:"created_by_ip_address"`
DefaultOwnerUUID string `json:"default_owner_uuid"`
Etag string `json:"etag"`
- ExpiresAt string `json:"expires_at"`
+ ExpiresAt time.Time `json:"expires_at"`
LastUsedAt time.Time `json:"last_used_at"`
LastUsedByIPAddress string `json:"last_used_by_ip_address"`
ModifiedAt time.Time `json:"modified_at"`