Skip to content

Commit 5b0fb71

Browse files
authored
Merge branch 'develop' into ci-bump-11699447604
2 parents 0a653e0 + 86ffa3e commit 5b0fb71

File tree

6 files changed

+35
-7
lines changed

6 files changed

+35
-7
lines changed

aws_lambda_powertools/event_handler/openapi/models.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ class SecuritySchemeType(Enum):
363363
http = "http"
364364
oauth2 = "oauth2"
365365
openIdConnect = "openIdConnect"
366+
mutualTLS = "mutualTLS"
366367

367368

368369
class SecurityBase(OpenAPIExtensions):
@@ -440,7 +441,11 @@ class OpenIdConnect(SecurityBase):
440441
openIdConnectUrl: str
441442

442443

443-
SecurityScheme = Union[APIKey, HTTPBase, OAuth2, OpenIdConnect, HTTPBearer]
444+
class MutualTLS(SecurityBase):
445+
type_: SecuritySchemeType = Field(default=SecuritySchemeType.mutualTLS, alias="type")
446+
447+
448+
SecurityScheme = Union[APIKey, HTTPBase, OAuth2, OpenIdConnect, HTTPBearer, MutualTLS]
444449

445450

446451
# https://swagger.io/specification/#components-object

docs/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# v9.1.18
2-
FROM squidfunk/mkdocs-material@sha256:2c2802b4d26154eb2c30238ba8ed3aab3a6276009334fd99613e4c01e97cd420
2+
FROM squidfunk/mkdocs-material@sha256:ce587cbffd5283056df4a84bd3f2eb0c54f0031b1789844dcaf6ac53da0fd52c
33
# pip-compile --generate-hashes --output-file=requirements.txt requirements.in
44
COPY requirements.txt /tmp/
55
RUN pip install --require-hashes -r /tmp/requirements.txt

docs/core/event_handler/api_gateway.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,6 +1111,7 @@ OpenAPI 3 lets you describe APIs protected using the following security schemes:
11111111
| [API keys](https://swagger.io/docs/specification/authentication/api-keys/https://swagger.io/docs/specification/authentication/api-keys/){target="_blank"} (e.g: query strings, cookies) | `APIKey` | API keys in headers, query strings or [cookies](https://swagger.io/docs/specification/authentication/cookie-authentication/){target="_blank"}. |
11121112
| [OAuth 2](https://swagger.io/docs/specification/authentication/oauth2/){target="_blank"} | `OAuth2` | Authorization protocol that gives an API client limited access to user data on a web server. |
11131113
| [OpenID Connect Discovery](https://swagger.io/docs/specification/authentication/openid-connect-discovery/){target="_blank"} | `OpenIdConnect` | Identity layer built [on top of the OAuth 2.0 protocol](https://openid.net/developers/how-connect-works/){target="_blank"} and supported by some OAuth 2.0. |
1114+
| [Mutual TLS](https://swagger.io/specification/#security-scheme-object){target="_blank"}. | `MutualTLS` | Client/server certificate mutual authentication scheme. |
11141115

11151116
???-note "Using OAuth2 with the Swagger UI?"
11161117
You can use the `OAuth2Config` option to configure a default OAuth2 app on the generated Swagger UI.

poetry.lock

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

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ aws-cdk-lib = "^2.165.0"
7979
pytest-benchmark = "^4.0.0"
8080
types-requests = "^2.31.0"
8181
typing-extensions = "^4.12.2"
82-
mkdocs-material = "^9.5.43"
82+
mkdocs-material = "^9.5.44"
8383
filelock = "^3.16.0"
8484
dirhash = "^0.5.0"
8585
mypy-boto3-appconfigdata = "^1.35.0"

tests/functional/event_handler/_pydantic/test_openapi_security_schemes.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
APIKey,
44
APIKeyIn,
55
HTTPBearer,
6+
MutualTLS,
67
OAuth2,
78
OAuthFlowImplicit,
89
OAuthFlows,
@@ -110,3 +111,24 @@ def handler():
110111
open_id_connect_scheme = security_schemes["openIdConnect"]
111112
assert open_id_connect_scheme.type_.value == "openIdConnect"
112113
assert open_id_connect_scheme.openIdConnectUrl == "https://example.com/oauth2/authorize"
114+
115+
116+
def test_openapi_security_scheme_mtls():
117+
app = APIGatewayRestResolver()
118+
119+
@app.get("/")
120+
def handler():
121+
raise NotImplementedError()
122+
123+
schema = app.get_openapi_schema(
124+
security_schemes={
125+
"mutualTLS": MutualTLS(description="mTLS Authentication"),
126+
},
127+
)
128+
129+
security_schemes = schema.components.securitySchemes
130+
assert security_schemes is not None
131+
132+
assert "mutualTLS" in security_schemes
133+
mtls_scheme = security_schemes["mutualTLS"]
134+
assert mtls_scheme.description == "mTLS Authentication"

0 commit comments

Comments
 (0)