accessmgr
Chargement et distribution sécurisés de credentials (mail, Telegram, KuCoin, Kraken, DataBento, healthcheck) depuis un fichier JSON externe — sans jamais exposer de secret en clair dans le code.
Le nom de distribution est
accessmgr, le package importable estAccessMgr.
Principe
- Tous les secrets vivent dans un fichier JSON externe (hors du dépôt), jamais dans le code source.
- Des factory functions (
get_kucoin_token,get_telegram_config,get_healthcheck_config, …) lisent ce fichier et créent des objets credential. - Les secrets transitent par les variables d'environnement du process et sont
exposés via des propriétés avec contrôle de durée de vie (
duration, en secondes ;-1= permanent).
Installation
pip install accessmgr
Aucune dépendance externe (stdlib uniquement). Python ≥ 3.11.
Format du fichier de configuration (access.json)
Les clés de premier niveau sont des environnements (prod, uat_<nom>, dev_<nom>).
Chaque entrée est préfixée par son type (telegram_, kucoin_, healthcheck_, …).
{
"prod": {
"telegram_myBot": {
"id": "myBot", "type": "telegram", "duration": -1,
"name": "My Bot", "token": "<telegram-bot-token>", "chat_id": "<chat-id>"
},
"healthcheck_nightly": {
"id": "nightly", "type": "healthcheck", "duration": -1,
"name": "nightly job", "uuid": "<healthchecks-uuid>"
},
"provider_kraken_meanrev": {
"id": "meanrev", "type": "provider", "support": "spot", "duration": -1,
"user_name": "Kraken MeanRev", "key": "<api-key>", "secret": "<api-secret-base64>"
}
}
}
Objet Kraken — remplir une entrée
provider_kraken_<id>:
- clé de l'objet =
provider_kraken_suivi de la valeur deid(ils doivent concorder) ;id: identifiant technique passé àget_kraken_config(st_id=...)(sensible à la casse) ;type: toujours"provider";support:"spot"(APIapi.kraken.com) ou"fut"(APIfutures.kraken.com) — une clé spot ne s'authentifie que sur l'API spot, une clé futures que sur l'API futures. Défaut :"spot";duration: durée de vie en secondes (-1= permanent) ;user_name: libellé humain (affiché dans les logs, non sensible) ;key: clé publique (API Key) ;secret: clé privée (base64). Jamais de clé en clair ailleurs.
⚠️ Ce fichier contient vos secrets : gardez-le hors du dépôt git et à accès restreint.
Utilisation
from AccessMgr import (
get_telegram_config,
get_healthcheck_config,
AccessEnvironment,
)
CONFIG = "/chemin/vers/access.json"
# Telegram
tg = get_telegram_config(st_id="myBot", an_environment=AccessEnvironment.PROD,
st_config_path=CONFIG)
bot_token = tg.token()
chat_id = tg.chat_id()
# Healthcheck (healthchecks.io ou compatible)
hc = get_healthcheck_config(st_id="nightly", an_environment=AccessEnvironment.PROD,
st_config_path=CONFIG)
ping_url = hc.url() # https://hc-ping.com/<uuid> (base = constante du code)
# Kraken (spot ou futures selon le champ 'support')
from AccessMgr import get_kraken_config
kr = get_kraken_config(st_id="meanrev", an_environment=AccessEnvironment.PROD,
st_config_path=CONFIG)
api_key = kr.key() # clé publique
api_secret = kr.secret() # clé privée (base64)
venue = kr.support # 'spot' ou 'fut' -> aiguille le bon connecteur
if kr.is_spot:
... # api.kraken.com
Pour les environnements hors production, un st_sub_name est obligatoire :
cfg = get_telegram_config(st_id="myBot", an_environment=AccessEnvironment.UAT,
st_sub_name="global", st_config_path=CONFIG)
Chemin de configuration par défaut (depuis 0.1.2)
Plutôt que de répéter st_config_path à chaque appel, définissez-le une seule
fois au démarrage avec set_default_config_path. Tous les get_*() l'utilisent
ensuite automatiquement :
import AccessMgr
from AccessMgr import get_kucoin_token, get_databendo_config, AccessEnvironment
AccessMgr.set_default_config_path("/chemin/vers/access.json") # une fois au boot
# plus besoin de st_config_path : le défaut est utilisé
kc = get_kucoin_token(st_id="main", an_environment=AccessEnvironment.PROD)
# l'argument explicite reste prioritaire : surcharge ponctuelle (ex. dev)
db = get_databendo_config(st_id="feed", an_environment=AccessEnvironment.DEV,
st_sub_name="test", st_config_path="/autre/access_dev.json")
Passer
set_default_config_path(None)réinitialise explicitement le comportement (retour aux chemins par défaut codés en dur). Une chaîne vide lèveValueError. L'argumentst_config_pathd'un appel prime toujours sur le défaut.
Providers disponibles
| Factory | Type JSON | Retourne |
|---|---|---|
get_mail_config |
mail |
MailLogin (SMTP/IMAP) |
get_telegram_config |
telegram |
ProviderTelegram (token(), chat_id()) |
get_kucoin_token |
provider (provider_kuCoin_<id>) |
ProviderKucoin |
get_kraken_config |
provider (provider_kraken_<id>) |
ProviderKraken (key(), secret(), support, is_spot/is_fut) |
get_massive_data_token |
massivedata |
ProviderMassiveData |
get_databendo_config |
databento |
ProviderDataBendo |
get_healthcheck_config |
healthcheck |
ProviderHealthcheck (url(), uuid()) |
Sécurité
- Aucun secret en clair dans le code source.
- Les secrets transitent : JSON externe →
os.environ→ propriétés avec contrôle d'expiration. - Les objets ne loggent jamais leurs secrets (absents de
repr/str).
Licence
MIT — voir LICENSE.
Metadata
Release files for accessmgr 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| accessmgr-0.1.5.tar.gz | 16.0 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| accessmgr-0.1.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 39.2 kB
Release files / accessmgr-0.1.5.tar.gz
| Download URL | accessmgr-0.1.5.tar.gz |
|---|---|
| Size | 16.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7500f88c25f88322354c96ffdcf4a45acb289b903c51c0372daf31b112ae1b6a
|
|
BLAKE2b-256 checksum How to use checksums |
2e771b63365538003faabe01f8478b187e7328a3e30ca3cf251cc412abb3b68f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.
Transparency logRelease files / accessmgr-0.1.5-py3-none-any.whl
| Download URL | accessmgr-0.1.5-py3-none-any.whl |
|---|---|
| Size | 23.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7193715b7a5034508fe4c89213d32396a65ce0a5d47fbcbc151221ac625b27ea
|
|
BLAKE2b-256 checksum How to use checksums |
b507e5c26c656a071d30428b05390fdb7d2358668967f6b3d3912dcd4e5c7fd1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.
Transparency logSecurity for accessmgr 0.1.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for accessmgr-0.1.5.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.