add download to issued cert

This commit is contained in:
2025-09-08 17:32:28 -03:00
parent b327b6c177
commit ac07ee0101
15 changed files with 94 additions and 400 deletions

View File

@@ -15,10 +15,11 @@ from middlewares import Tenant, TenantMiddleware
from .cancel import router as cancel
from .deduplication_window import router as deduplication_window
from .download_issued_cert import router as issued_cert
from .enroll import router as enroll
from .slots import router as slots
__all__ = ['slots', 'cancel', 'enroll', 'deduplication_window']
__all__ = ['slots', 'cancel', 'enroll', 'deduplication_window', 'issued_cert']
router = Router()

View File

@@ -0,0 +1,27 @@
from aws_lambda_powertools.event_handler.api_gateway import Router
from layercake.dynamodb import DynamoDBPersistenceLayer
from boto3clients import dynamodb_client, s3_client
from config import BUCKET_NAME, ENROLLMENT_TABLE
EXPIRES_IN = 300
router = Router()
enrollment_layer = DynamoDBPersistenceLayer(ENROLLMENT_TABLE, dynamodb_client)
@router.get('/<id>/download')
def download(id: str):
params = {
'Bucket': BUCKET_NAME,
'Key': f'issuedcerts/{id}.pdf',
'ResponseContentDisposition': f'attachment; filename="{id}.pdf"',
}
return {
'presigned_url': s3_client.generate_presigned_url(
'get_object',
Params=params,
ExpiresIn=EXPIRES_IN,
)
}