Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(api): authentication consumer migration #5850

Merged
merged 1 commit into from
Jun 16, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func AuthConsumerTokenExpiration(ctx context.Context, dbFunc func() *gorp.DbMap,

func authConsumerTokenExpirationPerID(ctx context.Context, tx gorpmapper.SqlExecutorWithTx, id string, duration time.Duration) error {
// Lock the row
id, err := tx.SelectStr("select id from auth_consumer where id=$1 and validity_periods is null for update skip locked")
id, err := tx.SelectStr("select id from auth_consumer where id=$1 and validity_periods is null for update skip locked", id)
if err == sql.ErrNoRows {
return nil
}
Expand All @@ -70,7 +70,7 @@ func authConsumerTokenExpirationPerID(ctx context.Context, tx gorpmapper.SqlExec
return nil
}

consumer.ValidityPeriods = sdk.NewAuthConsumerValidityPeriod(time.Now(), duration)
consumer.ValidityPeriods = sdk.NewAuthConsumerValidityPeriod(consumer.DeprecatedIssuedAt, duration)
log.Info(ctx, "consumer %q IAT=%v Expiration=%v", consumer.ID, consumer.ValidityPeriods.Latest().IssuedAt, consumer.ValidityPeriods.Latest().IssuedAt.Add(consumer.ValidityPeriods.Latest().Duration))

return authentication.UpdateConsumer(ctx, tx, consumer)
Expand Down