Skip to content

Commit 9588109

Browse files
authored
Merge pull request #73 from busykoala/options_auth
Authenticate OPTIONS requests to prevent information leaks
2 parents 6dd6f8c + 917f196 commit 9588109

File tree

6 files changed

+1031
-346
lines changed

6 files changed

+1031
-346
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Change Log
22

3+
## [2.0.1] - 2024-07-15
4+
- Security Improvement: Added authentication and authorization checks for HTTP
5+
OPTIONS requests in OpaMiddleware. This ensures that OPTIONS requests are
6+
subjected to the same security policies as other HTTP methods, preventing
7+
potential information leaks.
8+
[See advisory for more details](https://github.com/advisories/GHSA-5f5c-8rvc-j8wf)
9+
- Update dependencies due to multiple vulnerabilities.
10+
311
## [2.0.0] - 2024-02-07
412
- Drop Python 3.7 support due to FastAPI update
513
- Update dependencies due to vulnerabilities:

fastapi_opa/opa/opa_middleware.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,7 @@
1818
from fastapi_opa.auth.exceptions import AuthenticationException
1919
from fastapi_opa.opa.opa_config import OPAConfig
2020

21-
try:
22-
Pattern = re.Pattern
23-
except AttributeError:
24-
# Python3.6 does not contain re.Pattern
25-
Pattern = None
26-
21+
Pattern = re.Pattern
2722
logger = logging.getLogger(__name__)
2823

2924

@@ -76,15 +71,13 @@ async def __call__(
7671
own_receive = OwnReceive(receive)
7772
request = Request(scope, own_receive, send)
7873

79-
if request.method == "OPTIONS":
80-
return await self.app(scope, receive, send)
81-
8274
# allow openapi endpoints without authentication
8375
if should_skip_endpoint(request.url.path, self.skip_endpoints):
8476
return await self.app(scope, receive, send)
8577

8678
# authenticate user or get redirect to identity provider
8779
successful = False
80+
user_info_or_auth_redirect = None
8881
for auth in self.config.authentication:
8982
try:
9083
user_info_or_auth_redirect = auth.authenticate(

0 commit comments

Comments
 (0)