Skip to content

Commit 8c9ff62

Browse files
authored
Merge pull request #121 from pvarki/conventional_commits
Enforce Conventional commits, add deployment name to pfx filename, add endpoint for OIDC self reg token request
2 parents e077a4e + e923e67 commit 8c9ff62

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+284
-251
lines changed

.pre-commit-config.yaml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,18 @@
22
# See https://pre-commit.com/hooks.html for more hooks
33
default_language_version:
44
python: python3.11
5+
default_install_hook_types:
6+
- pre-commit
7+
- commit-msg
58
repos:
9+
- repo: https://github.com/compilerla/conventional-pre-commit
10+
rev: v4.0.0
11+
hooks:
12+
- id: conventional-pre-commit
13+
stages: [commit-msg]
14+
args: []
615
- repo: https://github.com/pre-commit/pre-commit-hooks
7-
rev: v4.4.0
16+
rev: v5.0.0
817
hooks:
918
- id: no-commit-to-branch
1019
- id: check-executables-have-shebangs
@@ -22,29 +31,29 @@ repos:
2231
args:
2332
- --autofix
2433
- repo: https://github.com/psf/black
25-
rev: 23.7.0
34+
rev: 25.1.0
2635
hooks:
2736
- id: black
2837
language_version: python3
2938
- repo: https://github.com/pre-commit/mirrors-mypy
30-
rev: v1.5.1
39+
rev: v1.15.0
3140
hooks:
3241
- id: mypy
3342
language: system
3443
- repo: https://github.com/pycqa/pylint
35-
rev: v2.17.5
44+
rev: v3.3.6
3645
hooks:
3746
- id: pylint
3847
language: system
3948
- repo: https://github.com/Lucas-C/pre-commit-hooks
40-
rev: v1.5.0
49+
rev: v1.5.5
4150
hooks:
4251
- id: forbid-crlf
4352
- id: remove-crlf
4453
- id: forbid-tabs
4554
- id: remove-tabs
4655
- repo: https://github.com/PyCQA/bandit
47-
rev: 1.7.5
56+
rev: 1.8.3
4857
hooks:
4958
- id: bandit
5059
args: ["--skip=B101"]
@@ -53,7 +62,7 @@ repos:
5362
hooks:
5463
- id: rst-linter
5564
- repo: https://github.com/Yelp/detect-secrets
56-
rev: v1.4.0
65+
rev: v1.5.0
5766
hooks:
5867
- id: detect-secrets
5968
language: system

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ pre-commit considerations
236236

237237
If working in Docker instead of native env you need to run the pre-commit checks in docker too::
238238

239-
docker exec -i rasenmaeher_api_devel /bin/bash -c "pre-commit install"
239+
docker exec -i rasenmaeher_api_devel /bin/bash -c "pre-commit install --install-hooks"
240240
docker exec -i rasenmaeher_api_devel /bin/bash -c "pre-commit run --all-files"
241241

242242
You need to have the container running, see above. Or alternatively use the docker run syntax but using
@@ -290,7 +290,7 @@ TLDR:
290290
- Install project deps and pre-commit hooks::
291291

292292
poetry install
293-
pre-commit install
293+
pre-commit install --install-hooks
294294
pre-commit run --all-files
295295

296296
- Ready to go.

poetry.lock

Lines changed: 75 additions & 218 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ psycopg2 = "^2.9"
9999
pytest = "^7.4"
100100
coverage = "^7.3"
101101
pytest-cov = "^4.1"
102-
pylint = "^2.17"
103-
black = "^23.7"
104-
bandit = "^1.7"
105-
mypy = "^1.5"
102+
pylint = "^3.3"
103+
black = "^25.1"
104+
bandit = "^1.8"
105+
mypy = "^1.15"
106106
pre-commit = "^3.3"
107107
pytest-asyncio = ">=0.23,<1.0" # caret behaviour on 0.x is to lock to 0.x.*
108108
bump2version = "^1.0"

src/rasenmaeher_api/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
""" python-rasenmaeher-api """
1+
"""python-rasenmaeher-api"""
2+
23
__version__ = "1.6.4" # NOTE Use `bump2version --config-file patch` to bump versions correctly

src/rasenmaeher_api/cfssl/anoncsr.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""This needs to be separated to avoid circular imports"""
2+
23
import logging
34

45
import aiohttp
@@ -18,7 +19,7 @@ async def anon_sign_csr(csr: str, bundle: bool = True) -> str:
1819
params: csr
1920
returns: certificate
2021
"""
21-
async with (await anon_session()) as session:
22+
async with await anon_session() as session:
2223
url = f"{ocsprest_base()}/api/v1/csr/sign"
2324
payload = {"certificate_request": csr, "profile": "client", "bundle": bundle}
2425
try:

src/rasenmaeher_api/cfssl/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Base helpers etc"""
2+
23
from typing import Any, Mapping, Union, List, cast
34
import logging
45
import ssl

src/rasenmaeher_api/cfssl/mtls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""mTLS stuff, needs to be away from base to avoid cyclic imports"""
2+
23
import logging
34

45
import aiohttp

src/rasenmaeher_api/cfssl/private.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Private apis"""
2+
23
from typing import Union, Optional, Any, Dict
34
import asyncio
45
import logging
@@ -26,7 +27,7 @@ async def post_ocsprest(
2627
"""Do a POST with the mTLS client"""
2728
if timeout is None:
2829
timeout = RMSettings.singleton().cfssl_timeout
29-
async with (await mtls_session()) as session:
30+
async with await mtls_session() as session:
3031
try:
3132
LOGGER.debug("POSTing to {}, payload={}".format(url, send_payload))
3233
async with session.post(url, data=send_payload, timeout=aiohttp.ClientTimeout(total=timeout)) as response:
@@ -54,7 +55,7 @@ async def sign_csr(csr: str, bundle: bool = True) -> str:
5455
params: csr, whether to return cert of full bundle
5556
returns: certificate as PEM
5657
"""
57-
async with (await mtls_session()) as session:
58+
async with await mtls_session() as session:
5859
url = f"{ocsprest_base()}/api/v1/csr/sign"
5960
payload = {"certificate_request": csr, "profile": "client", "bundle": bundle}
6061
try:
@@ -76,7 +77,7 @@ async def sign_ocsp(cert: str, status: str = "good") -> Any:
7677
Call ocspsign endpoint
7778
"""
7879

79-
async with (await mtls_session()) as session:
80+
async with await mtls_session() as session:
8081
url = f"{base_url()}/api/v1/cfssl/ocspsign"
8182
payload = {"certificate": cert, "status": status}
8283
try:
@@ -129,7 +130,7 @@ async def revoke_serial(serialno: str, authority_key_id: str, reason: ReasonType
129130
Reason must be one of the enumerations of cryptography.x509.ReasonFlags or it's string values (see REASONS_BY_VALUE)
130131
"""
131132
reason = validate_reason(reason)
132-
async with (await mtls_session()) as session:
133+
async with await mtls_session() as session:
133134
url = f"{base_url()}/api/v1/cfssl/revoke"
134135
payload = {
135136
"serial": serialno,
@@ -168,7 +169,7 @@ async def certadd_pem(pem: Union[str, Path], status: str = "good") -> Any:
168169
if not kid:
169170
raise ValueError("Cannot resolve authority_key_id from the cert")
170171

171-
async with (await mtls_session()) as session:
172+
async with await mtls_session() as session:
172173
url = f"{base_url()}/api/v1/cfssl/certadd"
173174
payload = {
174175
"pem": pem,

src/rasenmaeher_api/cfssl/public.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Public things, CA cert, CRL etc"""
2+
23
from typing import Dict, Any
34
import logging
45
import base64
@@ -28,7 +29,7 @@ async def get_ca() -> str:
2829
returns: CA certificate
2930
"""
3031

31-
async with (await anon_session()) as session:
32+
async with await anon_session() as session:
3233
url = f"{base_url()}/api/v1/cfssl/info"
3334
payload: Dict[str, Any] = {}
3435
# PONDER: Why does this need to be a POST ??
@@ -42,7 +43,7 @@ async def get_ca() -> str:
4243
async def get_ocsprest_crl(suffix: str) -> bytes:
4344
"""Fetch CRL from OCSPREST"""
4445

45-
async with (await anon_session()) as session:
46+
async with await anon_session() as session:
4647
url = f"{ocsprest_base()}/api/v1/crl/{suffix}"
4748
try:
4849
async with session.get(url) as response:
@@ -59,7 +60,7 @@ async def get_crl() -> bytes:
5960
returns: DER binary encoded Certificate Revocation List
6061
"""
6162

62-
async with (await anon_session()) as session:
63+
async with await anon_session() as session:
6364
url = f"{base_url()}/api/v1/cfssl/crl"
6465
try:
6566
async with session.get(url, params={"expiry": CRL_LIFETIME}, timeout=default_timeout()) as response:
@@ -78,7 +79,7 @@ async def get_bundle(cert: str) -> str:
7879
# FIXME: This is not a good way but I don't have a better one right now either
7980
# Force OCSP refresh before getting the bundle so we hopefully get all we need
8081
await refresh_ocsp()
81-
async with (await anon_session()) as session:
82+
async with await anon_session() as session:
8283
url = f"{base_url()}/api/v1/cfssl/bundle"
8384
payload: Dict[str, Any] = {"certificate": cert, "flavor": "optimal"}
8485
try:

0 commit comments

Comments
 (0)