gemini (kostenintensives) app-aufbauen
This commit is contained in:
1 parent
c74bca1e13
commit
8232f4d8f7
11 files changed
+659
-519
No files matched your search
@@ -0,0 +1,34 @@
|
||||
# ==============================================================================
|
||||
# Formeleon - Multi-tenant Form Generator
|
||||
# Author: Björn Runden <br@runden.net>
|
||||
# Module: utils/helpers.py
|
||||
# Description: Helper and utility functions for the application.
|
||||
# ==============================================================================
|
||||
|
||||
import hashlib
|
||||
from typing import Optional
|
||||
from flask import request
|
||||
|
||||
def hash_ip(ip: str) -> str:
|
||||
"""
|
||||
Create a hash of an IP address for privacy-preserving storage.
|
||||
|
||||
:param ip: IP address string
|
||||
:return: SHA256 hash of the IP
|
||||
"""
|
||||
if not ip:
|
||||
return ''
|
||||
return hashlib.sha256(ip.encode()).hexdigest()
|
||||
|
||||
def get_request_context() -> dict:
|
||||
"""
|
||||
Get standardized request context for audit logging.
|
||||
|
||||
:return: Dictionary with request context information
|
||||
"""
|
||||
return {
|
||||
'ip_address': request.remote_addr,
|
||||
'user_agent': request.user_agent.string if request.user_agent else None,
|
||||
'path': request.path,
|
||||
'method': request.method
|
||||
}
|
||||
Reference in new issue
Block a user