1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
13 "git.arvados.org/arvados.git/lib/ctrlctx"
14 "git.arvados.org/arvados.git/sdk/go/auth"
17 func (conn *Conn) ExpireAPIClientAuthorization(ctx context.Context) error {
18 creds, ok := auth.FromContext(ctx)
21 return errors.New("credentials not found from context")
24 if len(creds.Tokens) < 1 {
25 return errors.New("no tokens found to expire")
28 token := creds.Tokens[0]
30 if strings.Contains(token, "/") {
31 tokenparts := strings.Split(token, "/")
32 if len(tokenparts) >= 3 {
33 tokensecret = tokenparts[2]
37 tx, err := ctrlctx.CurrentTx(ctx)
42 res, err := tx.ExecContext(ctx, "UPDATE api_client_authorizations SET expires_at=current_timestamp WHERE api_token=$1", tokensecret)
47 rows, err := res.RowsAffected()
52 return fmt.Errorf("token expiration affected rows: %d - token: %s", rows, token)