MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / GetUserByAPIKey

Method GetUserByAPIKey

internal/identity/store.go:3512–3518  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

3510// the future, evaluated against now() in the same query so there's no
3511// clock skew between row read and check.
3512func (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).

Implementers 1

Storeinternal/identity/store.go

Calls 1

GetPrincipalByAPIKeyMethod · 0.95