GetUserByAPIKey authenticates a bearer token and returns the owning user. Rejects revoked keys and time-expired keys; touches last_used_at only on the success path so the column stays a real "last successful authentication" signal (rather than "last attempt"). Expiration semantics: expires_at IS NU
(ctx context.Context, apiKey string)
| 3510 | // the future, evaluated against now() in the same query so there's no |
| 3511 | // clock skew between row read and check. |
| 3512 | func (s *Store) GetUserByAPIKey(ctx context.Context, apiKey string) (*User, error) { |
| 3513 | p, err := s.GetPrincipalByAPIKey(ctx, apiKey) |
| 3514 | if err != nil { |
| 3515 | return nil, err |
| 3516 | } |
| 3517 | return p.User, nil |
| 3518 | } |
| 3519 | |
| 3520 | // GetPrincipalByAPIKey authenticates a bearer token and returns the full |
| 3521 | // principal — the owning user PLUS the key's scope and bound agent (Slice 5a). |