You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Configure TLS mutual authentication for Azure App Service
14
14
@@ -438,4 +438,67 @@ public class ClientCertValidator {
438
438
}
439
439
```
440
440
441
+
## Python sample
442
+
443
+
The following Python code implements a decorator named `authorize_certificate` that can be used on a Django view function to permit access only to callers that present a valid client certificate. It expects a PEM formatted certificate in the `X-ARR-ClientCert` header and uses the Python [cryptography](https://pypi.org/project/cryptography/) package to validate the certificate based on its fingerprint (thumbprint), subject common name, issuer common name, and beginning and expiration dates. If validation fails, the decorator raises the Django `PermissionDenied` exception.
444
+
445
+
```python
446
+
from functools import wraps
447
+
from datetime import datetime, timezone
448
+
from django.core.exceptions import PermissionDenied
0 commit comments