oidcauthlib 3.1.1__tar.gz → 3.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {oidcauthlib-3.1.1/oidcauthlib.egg-info → oidcauthlib-3.1.2}/PKG-INFO +2 -2
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/README.md +1 -1
- oidcauthlib-3.1.2/VERSION +1 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/authorization/__init__.py +5 -3
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/authorization/admin_access.py +13 -2
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/authorization/client_slugs.py +7 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/authorization/reader_configuration.py +9 -7
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/authorization/scopes.py +10 -6
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2/oidcauthlib.egg-info}/PKG-INFO +2 -2
- oidcauthlib-3.1.1/VERSION +0 -1
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/LICENSE +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/MANIFEST.in +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/__init__.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/__init__.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/auth_helper.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/auth_manager.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/cache/__init__.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/cache/oauth_cache.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/cache/oauth_memory_cache.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/cache/oauth_mongo_cache.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/config/__init__.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/config/auth_config.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/config/auth_config_reader.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/dcr/__init__.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/dcr/dcr_client.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/dcr/dcr_manager.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/dcr/dcr_registration.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/exceptions/__init__.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/exceptions/authorization_bearer_token_expired_exception.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/exceptions/authorization_bearer_token_invalid_exception.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/exceptions/authorization_bearer_token_missing_exception.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/exceptions/authorization_needed_exception.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/fastapi_auth_manager.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/middleware/__init__.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/middleware/request_scope_middleware.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/middleware/token_reader_middleware.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/models/__init__.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/models/auth.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/models/base_db_model.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/models/cache_item.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/models/client_key_set.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/models/token.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/repository/__init__.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/repository/base_repository.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/repository/memory/__init__.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/repository/memory/memory_repository.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/repository/mongo/__init__.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/repository/mongo/mongo_repository.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/repository/repository_factory.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/routers/__init__.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/routers/auth_router.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/token_reader.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/userinfo/__init__.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/userinfo/oidc_userinfo_manager.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/well_known_configuration/__init__.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/well_known_configuration/auth_server_metadata.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/well_known_configuration/auth_server_metadata_discovery.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/well_known_configuration/well_known_configuration_cache.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/well_known_configuration/well_known_configuration_cache_result.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/well_known_configuration/well_known_configuration_manager.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/authorization/client_keys.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/cache_gate/__init__.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/cache_gate/advisory_lock.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/cache_gate/version_gate.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/container/__init__.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/container/oidc_authlib_container_factory.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/open_telemetry/__init__.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/open_telemetry/attribute_names.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/open_telemetry/configurator.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/open_telemetry/filtering_sampler.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/open_telemetry/filtering_span_exporter.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/open_telemetry/filtering_span_processor.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/open_telemetry/otel_setup.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/open_telemetry/span_names.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/py.typed +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/storage/__init__.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/storage/cache_to_collection_mapper.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/storage/memory_storage_factory.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/storage/mongo_gridfs_db.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/storage/mongo_gridfs_exception.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/storage/mongo_storage_factory.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/storage/storage_factory.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/storage/storage_factory_creator.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/utilities/__init__.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/utilities/cached.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/utilities/environment/__init__.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/utilities/environment/abstract_environment_variables.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/utilities/environment/oidc_environment_variables.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/utilities/logger/__init__.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/utilities/logger/log_levels.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/utilities/logger/logging_response.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/utilities/logger/logging_transport.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/utilities/mongo_url_utils.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/utilities/url_validator.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib.egg-info/SOURCES.txt +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib.egg-info/dependency_links.txt +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib.egg-info/requires.txt +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib.egg-info/top_level.txt +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/pyproject.toml +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/setup.cfg +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/tests/test_mongo_url_utils.py +0 -0
- {oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/tests/test_simple.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: oidcauthlib
|
|
3
|
-
Version: 3.1.
|
|
3
|
+
Version: 3.1.2
|
|
4
4
|
Summary: oidcauthlib
|
|
5
5
|
Author-email: Imran Qureshi <imran.qureshi@bwell.com>
|
|
6
6
|
License: Apache-2.0
|
|
@@ -74,7 +74,7 @@ scopes = await manager.get_scopes_from_user_info_async(access_token=token)
|
|
|
74
74
|
|
|
75
75
|
Pure helpers that turn a caller's merged scopes (for example the result of `OidcUserInfoManager`) into a
|
|
76
76
|
tier: `admin` (unrestricted), `reader` (limited to the client keys its `access/<slug>.*` scopes select), or
|
|
77
|
-
denied. The subpackage reads no environment variable, does no I/O and imports nothing else from
|
|
77
|
+
denied. The subpackage reads no environment variable, does no file or network I/O (its only side effect is a standard `logging` warning with a slug or a count) and imports nothing else from
|
|
78
78
|
`oidcauthlib`; the caller verifies the token, looks up the user and passes the configuration in. The
|
|
79
79
|
`access/<slug>.*` and `patient/` scope convention is the FHIR server's, described in its
|
|
80
80
|
[security guide](https://github.com/icanbwell/fhir-server/blob/main/readme/security.md) (section 5); the tier
|
|
@@ -46,7 +46,7 @@ scopes = await manager.get_scopes_from_user_info_async(access_token=token)
|
|
|
46
46
|
|
|
47
47
|
Pure helpers that turn a caller's merged scopes (for example the result of `OidcUserInfoManager`) into a
|
|
48
48
|
tier: `admin` (unrestricted), `reader` (limited to the client keys its `access/<slug>.*` scopes select), or
|
|
49
|
-
denied. The subpackage reads no environment variable, does no I/O and imports nothing else from
|
|
49
|
+
denied. The subpackage reads no environment variable, does no file or network I/O (its only side effect is a standard `logging` warning with a slug or a count) and imports nothing else from
|
|
50
50
|
`oidcauthlib`; the caller verifies the token, looks up the user and passes the configuration in. The
|
|
51
51
|
`access/<slug>.*` and `patient/` scope convention is the FHIR server's, described in its
|
|
52
52
|
[security guide](https://github.com/icanbwell/fhir-server/blob/main/readme/security.md) (section 5); the tier
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.1.2
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"""Pure authorization helpers: administrator and tenant-reader tiers from OAuth scopes.
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
environment variable, performs no I/O and imports nothing else from
|
|
5
|
-
so callers keep control of token verification, user lookup and
|
|
3
|
+
Every decision is a pure function of the values passed in. The package reads no
|
|
4
|
+
environment variable, performs no file or network I/O and imports nothing else from
|
|
5
|
+
``oidcauthlib``, so callers keep control of token verification, user lookup and
|
|
6
|
+
configuration. Its only side effect is a standard-library ``logging`` warning that
|
|
7
|
+
carries a slug or a count, never a client name or key.
|
|
6
8
|
"""
|
|
7
9
|
|
|
8
10
|
from oidcauthlib.authorization.admin_access import (
|
|
@@ -16,6 +16,7 @@ Scope matching is exact on the required scopes, and ``access/*.*`` alone never
|
|
|
16
16
|
grants the reader tier.
|
|
17
17
|
"""
|
|
18
18
|
|
|
19
|
+
import logging
|
|
19
20
|
from collections.abc import Iterable, Sequence
|
|
20
21
|
from dataclasses import dataclass, field
|
|
21
22
|
from enum import StrEnum
|
|
@@ -28,6 +29,9 @@ from oidcauthlib.authorization.client_slugs import (
|
|
|
28
29
|
from oidcauthlib.authorization.scopes import has_admin_scopes, has_blank_scope, has_patient_scope
|
|
29
30
|
|
|
30
31
|
|
|
32
|
+
logger = logging.getLogger(__name__)
|
|
33
|
+
|
|
34
|
+
|
|
31
35
|
class AdminTier(StrEnum):
|
|
32
36
|
"""The tier a granted caller holds; a denied caller has no tier."""
|
|
33
37
|
|
|
@@ -65,6 +69,9 @@ class AdminAccess:
|
|
|
65
69
|
denial_reason: DenialReason | None
|
|
66
70
|
|
|
67
71
|
def __post_init__(self) -> None:
|
|
72
|
+
if isinstance(self.allowed_client_keys, str | bytes):
|
|
73
|
+
# A bare string would silently become a set of its characters.
|
|
74
|
+
raise TypeError("allowed_client_keys must be a collection of keys, not a string")
|
|
68
75
|
if self.allowed_client_keys is not None and not isinstance(self.allowed_client_keys, frozenset):
|
|
69
76
|
# A mutable set would let a caller widen the decision after it was made.
|
|
70
77
|
object.__setattr__(self, "allowed_client_keys", frozenset(self.allowed_client_keys))
|
|
@@ -110,7 +117,7 @@ def resolve_admin_access(
|
|
|
110
117
|
|
|
111
118
|
``admin_scopes`` and ``reader_scopes`` are all-of requirements; an empty one,
|
|
112
119
|
or one with a blank entry, admits nobody. Entries of ``scopes`` that are not
|
|
113
|
-
strings are ignored. ``allow_all_tenants`` lets ``access/*.*`` select every
|
|
120
|
+
strings are ignored (and counted in one warning). ``allow_all_tenants`` lets ``access/*.*`` select every
|
|
114
121
|
client in ``clients``, including a client whose own slug is ambiguous. Never
|
|
115
122
|
raises.
|
|
116
123
|
|
|
@@ -121,7 +128,11 @@ def resolve_admin_access(
|
|
|
121
128
|
clients: resolves ``access/<slug>.*`` scopes to client keys.
|
|
122
129
|
allow_all_tenants: whether ``access/*.*`` selects every client.
|
|
123
130
|
"""
|
|
124
|
-
|
|
131
|
+
all_scopes = list(scopes)
|
|
132
|
+
held = {scope for scope in all_scopes if isinstance(scope, str)}
|
|
133
|
+
if ignored := len(all_scopes) - sum(1 for scope in all_scopes if isinstance(scope, str)):
|
|
134
|
+
# Count only: a malformed claim can only narrow the decision, but operators should see it.
|
|
135
|
+
logger.warning("Ignored %d held scope entries that are not strings", ignored)
|
|
125
136
|
if has_patient_scope(scopes=held):
|
|
126
137
|
return AdminAccess.denied(reason=DenialReason.PATIENT_SCOPE)
|
|
127
138
|
if has_admin_scopes(scopes=held, required_scopes=admin_scopes):
|
|
@@ -79,8 +79,10 @@ class ClientSlugResolver:
|
|
|
79
79
|
not take part in ambiguity checks.
|
|
80
80
|
"""
|
|
81
81
|
keys_by_slug_candidates: dict[str, list[str]] = {}
|
|
82
|
+
skipped_non_string = 0
|
|
82
83
|
for name, key in clients.items():
|
|
83
84
|
if not isinstance(key, str):
|
|
85
|
+
skipped_non_string += 1
|
|
84
86
|
continue
|
|
85
87
|
slug = normalize_slug(slug=str(name))
|
|
86
88
|
clean_key = key.strip()
|
|
@@ -89,6 +91,11 @@ class ClientSlugResolver:
|
|
|
89
91
|
if is_eligible is not None and not is_eligible(str(name), clean_key):
|
|
90
92
|
continue
|
|
91
93
|
keys_by_slug_candidates.setdefault(slug, []).append(clean_key)
|
|
94
|
+
if skipped_non_string:
|
|
95
|
+
logger.warning(
|
|
96
|
+
"Skipped %d client-key entries whose key is not a string; their clients select nothing",
|
|
97
|
+
skipped_non_string,
|
|
98
|
+
)
|
|
92
99
|
keys_by_slug: dict[str, str] = {}
|
|
93
100
|
for slug, keys in keys_by_slug_candidates.items():
|
|
94
101
|
if slug == WILDCARD_SLUG:
|
|
@@ -11,7 +11,7 @@ from oidcauthlib.authorization.client_keys import (
|
|
|
11
11
|
parse_client_keys_strict,
|
|
12
12
|
)
|
|
13
13
|
from oidcauthlib.authorization.client_slugs import ACCESS_SCOPE_PREFIX, WILDCARD_SLUG
|
|
14
|
-
from oidcauthlib.authorization.scopes import PATIENT_SCOPE_PREFIX, normalize_scope
|
|
14
|
+
from oidcauthlib.authorization.scopes import PATIENT_SCOPE_PREFIX, has_blank_scope, normalize_scope
|
|
15
15
|
|
|
16
16
|
# Scopes every token carries; as a reader requirement they would admit everyone.
|
|
17
17
|
GENERIC_SCOPES = frozenset({"openid", "profile", "email", "groups"})
|
|
@@ -31,8 +31,8 @@ def validate_reader_configuration(
|
|
|
31
31
|
) -> None:
|
|
32
32
|
"""Refuse an unsafe reader-tier configuration.
|
|
33
33
|
|
|
34
|
-
A blank or padded entry in either scope list is always refused, because
|
|
35
|
-
match exactly and a blank requirement is satisfiable by a blank held scope. The
|
|
34
|
+
A blank, non-printing or padded entry in either scope list is always refused, because
|
|
35
|
+
scopes match exactly and a blank requirement is satisfiable by a blank held scope. The
|
|
36
36
|
remaining checks are skipped when no reader scopes are set.
|
|
37
37
|
|
|
38
38
|
Args:
|
|
@@ -41,8 +41,8 @@ def validate_reader_configuration(
|
|
|
41
41
|
client_keys_raw: the raw client-key mapping setting.
|
|
42
42
|
|
|
43
43
|
Raises:
|
|
44
|
-
ReaderConfigurationError: when either scope list has a blank
|
|
45
|
-
entry with surrounding whitespace; when reader scopes are set and the client-key
|
|
44
|
+
ReaderConfigurationError: when either scope list has a blank or non-printing
|
|
45
|
+
entry or an entry with surrounding whitespace; when reader scopes are set and the client-key
|
|
46
46
|
mapping fails the strict parser, is empty, or has a name containing
|
|
47
47
|
``*``; a reader scope overlaps an administrator scope, starts with
|
|
48
48
|
``access/`` or ``patient/``, is generic (``openid``, ``profile``,
|
|
@@ -51,8 +51,10 @@ def validate_reader_configuration(
|
|
|
51
51
|
an administrator).
|
|
52
52
|
"""
|
|
53
53
|
for scopes in (reader_scopes, admin_scopes):
|
|
54
|
-
if any(scope != scope.strip()
|
|
55
|
-
raise ReaderConfigurationError(
|
|
54
|
+
if has_blank_scope(scopes=scopes) or any(scope != scope.strip() for scope in scopes):
|
|
55
|
+
raise ReaderConfigurationError(
|
|
56
|
+
"a scope is blank, has characters that do not print, or has surrounding whitespace"
|
|
57
|
+
)
|
|
56
58
|
if not reader_scopes:
|
|
57
59
|
return
|
|
58
60
|
try:
|
|
@@ -15,19 +15,23 @@ def normalize_scope(*, scope: str) -> str:
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
def has_blank_scope(*, scopes: Iterable[str]) -> bool:
|
|
18
|
-
"""True when any scope is empty
|
|
18
|
+
"""True when any scope is not a string, is empty, is whitespace only, or has characters that do not print.
|
|
19
19
|
|
|
20
|
+
Characters that do not print include a zero-width space, a byte-order mark and control
|
|
21
|
+
characters, which look blank in a settings file but are not caught by ``str.strip``.
|
|
20
22
|
A blank required scope, for example the ``[""]`` that ``"".split(",")`` gives for an
|
|
21
23
|
unset setting, is satisfied by any held scope list that contains ``""`` (a token
|
|
22
24
|
scope claim split on single spaces with a double or trailing space does). Callers
|
|
23
25
|
treat a requirement list with a blank entry as unsatisfiable.
|
|
24
26
|
"""
|
|
25
|
-
return any(not scope.strip() for scope in scopes)
|
|
27
|
+
return any(not isinstance(scope, str) or not scope.strip() or not scope.isprintable() for scope in scopes)
|
|
26
28
|
|
|
27
29
|
|
|
28
30
|
def has_patient_scope(*, scopes: Iterable[str]) -> bool:
|
|
29
|
-
"""True when any scope starts with ``patient/`` (trimmed, case-insensitive)."""
|
|
30
|
-
return any(
|
|
31
|
+
"""True when any scope starts with ``patient/`` (trimmed, case-insensitive); non-string entries are ignored."""
|
|
32
|
+
return any(
|
|
33
|
+
isinstance(scope, str) and normalize_scope(scope=scope).startswith(PATIENT_SCOPE_PREFIX) for scope in scopes
|
|
34
|
+
)
|
|
31
35
|
|
|
32
36
|
|
|
33
37
|
def has_admin_scopes(*, scopes: Iterable[str], required_scopes: Collection[str]) -> bool:
|
|
@@ -40,12 +44,12 @@ def has_admin_scopes(*, scopes: Iterable[str], required_scopes: Collection[str])
|
|
|
40
44
|
administrator path applies to the merged scope set.
|
|
41
45
|
|
|
42
46
|
Args:
|
|
43
|
-
scopes: the scopes the caller holds.
|
|
47
|
+
scopes: the scopes the caller holds; non-string entries are ignored.
|
|
44
48
|
required_scopes: every one of these must be held, matched exactly.
|
|
45
49
|
"""
|
|
46
50
|
if not required_scopes or has_blank_scope(scopes=required_scopes):
|
|
47
51
|
return False
|
|
48
|
-
held =
|
|
52
|
+
held = {scope for scope in scopes if isinstance(scope, str)}
|
|
49
53
|
if has_patient_scope(scopes=held):
|
|
50
54
|
return False
|
|
51
55
|
return set(required_scopes).issubset(held)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: oidcauthlib
|
|
3
|
-
Version: 3.1.
|
|
3
|
+
Version: 3.1.2
|
|
4
4
|
Summary: oidcauthlib
|
|
5
5
|
Author-email: Imran Qureshi <imran.qureshi@bwell.com>
|
|
6
6
|
License: Apache-2.0
|
|
@@ -74,7 +74,7 @@ scopes = await manager.get_scopes_from_user_info_async(access_token=token)
|
|
|
74
74
|
|
|
75
75
|
Pure helpers that turn a caller's merged scopes (for example the result of `OidcUserInfoManager`) into a
|
|
76
76
|
tier: `admin` (unrestricted), `reader` (limited to the client keys its `access/<slug>.*` scopes select), or
|
|
77
|
-
denied. The subpackage reads no environment variable, does no I/O and imports nothing else from
|
|
77
|
+
denied. The subpackage reads no environment variable, does no file or network I/O (its only side effect is a standard `logging` warning with a slug or a count) and imports nothing else from
|
|
78
78
|
`oidcauthlib`; the caller verifies the token, looks up the user and passes the configuration in. The
|
|
79
79
|
`access/<slug>.*` and `patient/` scope convention is the FHIR server's, described in its
|
|
80
80
|
[security guide](https://github.com/icanbwell/fhir-server/blob/main/readme/security.md) (section 5); the tier
|
oidcauthlib-3.1.1/VERSION
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
3.1.1
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/middleware/request_scope_middleware.py
RENAMED
|
File without changes
|
{oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/middleware/token_reader_middleware.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/repository/memory/memory_repository.py
RENAMED
|
File without changes
|
|
File without changes
|
{oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/repository/mongo/mongo_repository.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/auth/well_known_configuration/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/container/oidc_authlib_container_factory.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/open_telemetry/filtering_span_exporter.py
RENAMED
|
File without changes
|
{oidcauthlib-3.1.1 → oidcauthlib-3.1.2}/oidcauthlib/open_telemetry/filtering_span_processor.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|