Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prefer more generic Mapping over dict type #10

Merged
merged 2 commits into from
Jul 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions audit_log/headers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import re
from collections.abc import Mapping
from dataclasses import dataclass
from urllib.parse import urlparse

Expand Down Expand Up @@ -65,14 +66,14 @@ def parse_spiffe(xfcc_header: str) -> ParsedSPIFFE:


def get_principal_from_headers(
headers: dict[str, str],
headers: Mapping[str, str],
) -> Principal:
"""Get principal from headers, supports mTLS, headers set in Istio, and JWTs.

Note: Do not use this to handle your auth, it expects auth to already be handled elsewhere and this is just to help get principals.

Args:
headers (dict[str, str]): Headers with all keys lowercase
headers (Mapping[str, str]): Headers with all keys lowercase
edvardm marked this conversation as resolved.
Show resolved Hide resolved

Raises:
AuditPrincipalError: Cannot get a principal from the headers
Expand Down