mask_key (configuration/masking.py)

dograh · api/services/configuration/masking.py · python · BSD-2-Clause
voice

Utilities for masking API keys before they are sent to the client. The rules are simple: 1. Only expose the last *visible* characters (default 4) of a key. 2. Incoming masked keys are considered a placeholder – if they equal the mask of the already-stored key, we treat them as *u

# Source: https://github.com/dograh-hq/dograh | License: BSD-2-Clause | Copyright 2025, Zansat Technologies Private Limited
# Provided via justclaw.it.com; keep this notice with the code.
"""Utilities for masking API keys before they are sent to the client.

The rules are simple:
1. Only expose the last *visible* characters (default 4) of a key.
2. Incoming masked keys are considered a placeholder – if they equal the mask of
   the already-stored key, we treat them as *unchanged* and keep the real value
   in storage.
"""

from __future__ import annotations

import copy
from typing import Any, Dict, Optional

from api.schemas.ai_model_configuration import EffectiveAIModelConfiguration
from api.services.configuration.registry import ServiceConfig
from api.services.integrations import get_no

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key