Compare commits

...

6 Commits

Author SHA1 Message Date
arian 9830b06534 docs 2026-03-17 22:02:39 -04:00
arian effbcd15e3 tests for schemas 2026-03-15 17:29:10 -04:00
arian fb14c7d804 framework 2026-03-15 12:25:51 -04:00
arian e07db4780f secrets folder for cf api token 2026-03-15 00:59:04 -04:00
arian a13cf668d4 gitignore secrets folder 2026-03-15 00:55:38 -04:00
arian 351ec0544d venv requirements.txt 2026-03-15 00:52:59 -04:00
8 changed files with 63 additions and 0 deletions
+2
View File
@@ -1,2 +1,4 @@
.idea/ .idea/
.venv/ .venv/
.secrets/
__pycache__/
+1
View File
@@ -0,0 +1 @@
dns_cloudflare_api_token = <API_TOKEN>
+8
View File
@@ -0,0 +1,8 @@
FROM python:latest
WORKDIR /app
COPY . /app
RUN pip install --no-cache-dir -r requirements.txt
ENTRYPOINT ["python", "certman.py"]
CMD ["--help"]
+20
View File
@@ -0,0 +1,20 @@
from schemas import DomainRequest
import subprocess
def request_certificate(domain_request: DomainRequest):
domain = domain_request.domain
credentials_file = domain_request.credentials_file
email = domain_request.email
certbot_command = [
'certbot', 'certonly',
'--dns-cloudflare',
'--dns-cloudflare-credentials', credentials_file,
'--email', email,
'--agree-tos',
'--non-interactive',
'-d', domain,
]
result = subprocess.run(certbot_command, capture_output=True, text=True)
if result.returncode != 0:
raise RuntimeError(f'Certbot returned non-zero exit code:\n{result.stderr}')
return result.stdout
+4
View File
@@ -0,0 +1,4 @@
certbot==5.4.0
certbot-dns-cloudflare==5.4.0
pydantic==2.12.5
email-validator==2.3.0
+6
View File
@@ -0,0 +1,6 @@
from pydantic import BaseModel, FilePath, EmailStr
class DomainRequest(BaseModel):
domain: str
credentials_file: FilePath
email: EmailStr
+4
View File
@@ -0,0 +1,4 @@
allow command `cat /path/to/files/certificate.crt` using the specified SSH key:\
`command="cat /path/to/files/certificate.crt",restrict ssh-ed25519 AAAAC3Nza...[key_content]... server-a`
make user with no permissions and put ^ in `.ssh/authorized_keys`
+18
View File
@@ -0,0 +1,18 @@
test_domain_request = {
'domain': 'example.com',
'credentials_file': '.secrets.example/certbot/cloudflare.ini',
'email': 'admin@example.com'
}
if __name__ == '__main__':
from schemas import DomainRequest
from pydantic import ValidationError
try:
domain_request = DomainRequest(**test_domain_request)
print("DomainRequest validation successful:", domain_request)
except ValidationError as e:
print("DomainRequest validation failed:", e)
except Exception as e:
print("An unexpected error occurred:", e)
raise e