app.model.api_key module

class app.model.api_key.ApiKey(*, id=<factory>, created_at, updated_at, apiKey, apiKeyHash, client, description, active, createdBy, oauth_user_id)[source]

Bases: SQLModel

Represents an API key used for authenticating and authorizing access to the system.

Plaintext keys are never persisted. Each row stores:
  • apiKey – the public prefix (e.g. gme_live_abc12345). Safe to log and referenced by apiKey_used FK columns across the schema.

  • apiKeyHashsha256(plaintext) hex digest, used to authenticate requests in O(1) without ever storing the secret.

Parameters:
  • id (str)

  • created_at (datetime)

  • updated_at (datetime)

  • apiKey (str)

  • apiKeyHash (str)

  • client (str)

  • description (str)

  • active (bool)

  • createdBy (str)

  • oauth_user_id (str)

apiKey

Public key prefix.

Type:

str

apiKeyHash

sha256 hex digest of the key plaintext.

Type:

str

description

A description of the API key.

Type:

str) (optional

active

Flag indicating whether the API key is active.

Type:

bool

createdBy

Keycloak userId of the creator.

Type:

str

model_config: ClassVar[ConfigDict] = {'from_attributes': True, 'read_from_attributes': True, 'read_with_orm_mode': True, 'registry': PydanticUndefined, 'table': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

static get_e2e_seed_api_key()[source]

Returns the E2E seed API key plaintext from environment variable E2E_API_KEY_GAME, or None when missing/empty.

Return type:

str | None

classmethod build_e2e_seed(*, created_by, client='e2e-seeded-client', description='Seeded API key from E2E_API_KEY_GAME', oauth_user_id=None)[source]

Builds an ApiKey row from the plaintext stored in E2E_API_KEY_GAME. The row only carries the derived prefix and hash; the plaintext is not persisted.

Returns None when the env variable is not configured.

Parameters:
  • created_by (str)

  • client (str)

  • description (str)

  • oauth_user_id (str | None)

Return type:

ApiKey | None