Skip to content

Repository files navigation

bt_api_security

Python 3.9-3.14License: MIT

Security compliance and audit framework for the bt_api ecosystem. Provides zero-trust architecture, end-to-end encryption, audit logging, MFA/OAuth2 authentication, and regulatory compliance support.

Features

Authentication

  • OAuth2Provider — OAuth 2.0 authorization code / client credentials flow
  • MFAProvider — TOTP/HOTP multi-factor authentication

Access Control

  • AccessControlManager — Role-based access control (RBAC)
  • Role / Permission — Typed role and permission enums

Audit & Compliance

  • AuditLogger — Immutable audit trail with structured event logging
  • ComplianceMonitor — Real-time compliance rule enforcement
  • ThreatDetector — Pattern-based threat detection engine

Encryption & Data Protection

  • EncryptionManager — AES-256-GCM encryption with PBKDF2 key derivation
  • DataProtectionManager — Data classification and protection policies

Network Security

  • TLSManager — TLS 1.3 certificate management and cipher suite configuration

Disaster Recovery

  • DisasterRecoveryManager — Backup, failover, and recovery orchestration

Security Monitoring

  • SecurityMonitoring — Real-time security event aggregation and alerting
  • IdentityManager — Identity lifecycle management

Supported Compliance Standards

StandardDescription
PCI DSS Level 1Payment card industry data security
SOX 404Sarbanes-Oxley Act
MiFID IIEU markets instrument directive
GDPREU data protection
ISO 27001Information security management
NIST CSFUS NIST cybersecurity framework
SOC 2 Type IIService organization control
FIPS 140-2 Level 3Federal cryptographic standard

Installation

pip install bt_api_security

Requirements

  • Python >= 3.9
  • pyjwt >= 2.8.0
  • cryptography >= 41.0.0
  • bcrypt >= 4.1.0
  • pydantic >= 2.0.0

Quick Start

Authentication

frombt_api_securityimportOAuth2Provider, MFAProvider# OAuth2 authenticationoauth=OAuth2Provider(client_id="app", client_secret="secret")
token=oauth.get_token(scope="read write")
# MFA verificationmfa=MFAProvider()
verified=mfa.verify_totp(user_secret="JBSWY3DPEHPK3PXP", code="123456")

Access Control

frombt_api_securityimportAccessControlManager, Role, Permissionacm=AccessControlManager()
acm.assign_role(user_id="user_001", role=Role.TRADER)
acm.grant_permission(role=Role.TRADER, permission=Permission.PLACE_ORDER)

Audit Logging

frombt_api_securityimportAuditLogger, EventTypelogger=AuditLogger()
logger.log_event(
event_type=EventType.ORDER_PLACED,
user_id="user_001",
resource="BINANCE___SPOT:BTCUSDT",
metadata={"order_id": "xyz", "volume": 0.5},
)

Encryption

frombt_api_securityimportEncryptionManagerenc=EncryptionManager()
ciphertext=enc.encrypt(plaintext="api_key_secret", associated_data="user_001")
plaintext=enc.decrypt(ciphertext=ciphertext, associated_data="user_001")

API Reference

ClassDescription
OAuth2ProviderOAuth 2.0 authentication provider
MFAProviderTOTP/HOTP MFA verification
AccessControlManagerRBAC access control
AuditLoggerImmutable audit trail
ComplianceMonitorCompliance rule enforcement
ThreatDetectorThreat pattern detection
EncryptionManagerAES-256-GCM encryption
DataProtectionManagerData classification and protection
TLSManagerTLS 1.3 certificate management
DisasterRecoveryManagerBackup and failover
SecurityMonitoringSecurity event monitoring
IdentityManagerIdentity lifecycle management

Documentation

Full documentation available at bt_api_py documentation.

License

MIT License

About

bt_api security compliance module - unified security controls and compliance for cryptocurrency exchange trading APIs

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages