Download config.py from dn-scribe/attstore: direct link, hf CLI and curl.
- Browser
- Download file 3.87 kB
-
https://huggingface.co/spaces/dn-scribe/attstore/resolve/main/config.py
- Command line
-
hf download hf://spaces/dn-scribe/attstore/config.py
-
curl -L -o config.py https://huggingface.co/spaces/dn-scribe/attstore/resolve/main/config.py
3.87 kB
| import os | |
| import logging | |
| logger = logging.getLogger(__name__) | |
| PORT = int(os.environ.get('PORT', '5003')) | |
| class Config: | |
| # Storage configuration | |
| STORAGE_TYPE = os.environ.get('STORAGE_TYPE', 'FILE_MOUNT') # FILE_MOUNT or CLOUD_STORAGE | |
| # File mount storage settings | |
| FILE_STORAGE_PATH = os.environ.get('FILE_STORAGE_PATH', './storage') | |
| FILE_STORAGE_BASE_URL = os.environ.get('FILE_STORAGE_BASE_URL', f'http://localhost:{PORT}/download') | |
| PUBLIC_BASE_URL = os.environ.get('PUBLIC_BASE_URL', f'http://localhost:{PORT}') | |
| # Cloud storage settings | |
| CLOUD_STORAGE_PROVIDER = os.environ.get('CLOUD_STORAGE_PROVIDER', 'AWS') # AWS or MINIO | |
| AWS_ACCESS_KEY_ID = os.environ.get('AWS_ACCESS_KEY_ID') | |
| AWS_SECRET_ACCESS_KEY = os.environ.get('AWS_SECRET_ACCESS_KEY') | |
| AWS_SESSION_TOKEN = os.environ.get('AWS_SESSION_TOKEN') | |
| AWS_REGION = os.environ.get('AWS_DEFAULT_REGION', 'il-central-1') | |
| S3_BUCKET = os.environ.get('S3_BUCKET') | |
| # MinIO settings | |
| MINIO_ENDPOINT = os.environ.get('MINIO_ENDPOINT') | |
| MINIO_ACCESS_KEY = os.environ.get('MINIO_ACCESS_KEY') | |
| MINIO_SECRET_KEY = os.environ.get('MINIO_SECRET_KEY') | |
| MINIO_BUCKET = os.environ.get('MINIO_BUCKET') | |
| MINIO_SECURE = os.environ.get('MINIO_SECURE', 'true').lower() == 'true' | |
| # Presigned URL expiration (in seconds) | |
| PRESIGNED_URL_EXPIRATION = int(os.environ.get('PRESIGNED_URL_EXPIRATION', '3600')) | |
| # SAML / External Identity settings | |
| SAML_SP_CERTIFICATE = os.environ.get('SAML_SP_CERTIFICATE') | |
| SAML_SP_PRIVATE_KEY = os.environ.get('SAML_SP_PRIVATE_KEY') | |
| SAML_DEFAULT_NAMEID_FORMAT = os.environ.get('SAML_DEFAULT_NAMEID_FORMAT', 'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress') | |
| # RFC 5424 Syslog settings | |
| SYSLOG_FACILITY = int(os.environ.get('SYSLOG_FACILITY', '16')) # Local use 0 (16*8) | |
| SYSLOG_HOSTNAME = os.environ.get('SYSLOG_HOSTNAME', 'attestation-store') | |
| SYSLOG_APP_NAME = os.environ.get('SYSLOG_APP_NAME', 'attestation-store') | |
| # Log retention settings | |
| # Number of days to retain logs in the database (default: 10 days) | |
| # Set to 0 to disable automatic log cleanup | |
| LOG_RETENTION_DAYS = int(os.environ.get('LOG_RETENTION_DAYS', '10')) | |
| # Authentication settings | |
| DEFAULT_ADMIN_USERNAME = os.environ.get('DEFAULT_ADMIN_USERNAME', 'admin') | |
| DEFAULT_ADMIN_PASSWORD = os.environ.get('DEFAULT_ADMIN_PASSWORD', 'admin#admin') | |
| DEFAULT_ADMIN_EMAIL = os.environ.get('DEFAULT_ADMIN_EMAIL', 'admin@example.com') | |
| def setup_config(app): | |
| """Setup application configuration""" | |
| config = Config() | |
| # Store config in app context | |
| app.config['STORAGE_CONFIG'] = config | |
| # Create storage directory if using file mount | |
| if config.STORAGE_TYPE == 'FILE_MOUNT': | |
| os.makedirs(config.FILE_STORAGE_PATH, exist_ok=True) | |
| logger.info(f"File storage directory created: {config.FILE_STORAGE_PATH}") | |
| else: | |
| logger.info(f"Using cloud storage with provider: {config.CLOUD_STORAGE_PROVIDER}") | |
| logger.info(f"Storage type configured: {config.STORAGE_TYPE}") | |
| def create_default_admin_user(app): | |
| """Create default admin user - must be called within application context""" | |
| config = Config() | |
| from models import User | |
| from app import db | |
| admin_user = User.query.filter_by(username=config.DEFAULT_ADMIN_USERNAME).first() | |
| if not admin_user: | |
| admin_user = User( | |
| username=config.DEFAULT_ADMIN_USERNAME, | |
| email=config.DEFAULT_ADMIN_EMAIL | |
| ) | |
| admin_user.set_password(config.DEFAULT_ADMIN_PASSWORD) | |
| db.session.add(admin_user) | |
| db.session.commit() | |
| logger.info(f"Default admin user created: {config.DEFAULT_ADMIN_USERNAME}") | |
| else: | |
| logger.info(f"Default admin user already exists: {config.DEFAULT_ADMIN_USERNAME}") | |