oidcauthlib 3.1.0__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.0/oidcauthlib.egg-info → oidcauthlib-3.1.2}/PKG-INFO +11 -4
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/README.md +10 -3
- oidcauthlib-3.1.2/VERSION +1 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/authorization/__init__.py +5 -3
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/authorization/admin_access.py +37 -8
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/authorization/client_keys.py +9 -4
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/authorization/client_slugs.py +28 -7
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/authorization/reader_configuration.py +25 -8
- oidcauthlib-3.1.2/oidcauthlib/authorization/scopes.py +55 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2/oidcauthlib.egg-info}/PKG-INFO +11 -4
- oidcauthlib-3.1.0/VERSION +0 -1
- oidcauthlib-3.1.0/oidcauthlib/authorization/scopes.py +0 -30
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/LICENSE +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/MANIFEST.in +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/__init__.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/__init__.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/auth_helper.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/auth_manager.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/cache/__init__.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/cache/oauth_cache.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/cache/oauth_memory_cache.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/cache/oauth_mongo_cache.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/config/__init__.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/config/auth_config.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/config/auth_config_reader.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/dcr/__init__.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/dcr/dcr_client.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/dcr/dcr_manager.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/dcr/dcr_registration.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/exceptions/__init__.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/exceptions/authorization_bearer_token_expired_exception.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/exceptions/authorization_bearer_token_invalid_exception.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/exceptions/authorization_bearer_token_missing_exception.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/exceptions/authorization_needed_exception.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/fastapi_auth_manager.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/middleware/__init__.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/middleware/request_scope_middleware.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/middleware/token_reader_middleware.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/models/__init__.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/models/auth.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/models/base_db_model.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/models/cache_item.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/models/client_key_set.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/models/token.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/repository/__init__.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/repository/base_repository.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/repository/memory/__init__.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/repository/memory/memory_repository.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/repository/mongo/__init__.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/repository/mongo/mongo_repository.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/repository/repository_factory.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/routers/__init__.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/routers/auth_router.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/token_reader.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/userinfo/__init__.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/userinfo/oidc_userinfo_manager.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/well_known_configuration/__init__.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/well_known_configuration/auth_server_metadata.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/well_known_configuration/auth_server_metadata_discovery.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/well_known_configuration/well_known_configuration_cache.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/well_known_configuration/well_known_configuration_cache_result.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/well_known_configuration/well_known_configuration_manager.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/cache_gate/__init__.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/cache_gate/advisory_lock.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/cache_gate/version_gate.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/container/__init__.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/container/oidc_authlib_container_factory.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/open_telemetry/__init__.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/open_telemetry/attribute_names.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/open_telemetry/configurator.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/open_telemetry/filtering_sampler.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/open_telemetry/filtering_span_exporter.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/open_telemetry/filtering_span_processor.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/open_telemetry/otel_setup.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/open_telemetry/span_names.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/py.typed +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/storage/__init__.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/storage/cache_to_collection_mapper.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/storage/memory_storage_factory.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/storage/mongo_gridfs_db.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/storage/mongo_gridfs_exception.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/storage/mongo_storage_factory.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/storage/storage_factory.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/storage/storage_factory_creator.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/utilities/__init__.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/utilities/cached.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/utilities/environment/__init__.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/utilities/environment/abstract_environment_variables.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/utilities/environment/oidc_environment_variables.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/utilities/logger/__init__.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/utilities/logger/log_levels.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/utilities/logger/logging_response.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/utilities/logger/logging_transport.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/utilities/mongo_url_utils.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib/utilities/url_validator.py +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib.egg-info/SOURCES.txt +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib.egg-info/dependency_links.txt +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib.egg-info/requires.txt +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/oidcauthlib.egg-info/top_level.txt +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/pyproject.toml +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/setup.cfg +0 -0
- {oidcauthlib-3.1.0 → oidcauthlib-3.1.2}/tests/test_mongo_url_utils.py +0 -0
- {oidcauthlib-3.1.0 → 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,8 +74,11 @@ 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
|
|
78
|
-
`oidcauthlib`; the caller verifies the token, looks up the user and passes the configuration in.
|
|
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
|
+
`oidcauthlib`; the caller verifies the token, looks up the user and passes the configuration in. The
|
|
79
|
+
`access/<slug>.*` and `patient/` scope convention is the FHIR server's, described in its
|
|
80
|
+
[security guide](https://github.com/icanbwell/fhir-server/blob/main/readme/security.md) (section 5); the tier
|
|
81
|
+
model is recorded in [ADR 0001](adrs/0001-authorization-tiers-from-scopes.md).
|
|
79
82
|
|
|
80
83
|
```python
|
|
81
84
|
from oidcauthlib.authorization import (
|
|
@@ -110,7 +113,11 @@ access = resolve_admin_access(
|
|
|
110
113
|
`reader`; anything else is denied with a `DenialReason`. An empty admin or reader requirement admits nobody.
|
|
111
114
|
- **Slugs:** `access/<slug>.*` selects the client whose name, stripped and casefolded, equals the slug. Two
|
|
112
115
|
names that casefold alike make the slug ambiguous and it selects nothing. The suffix must be exactly `.*`.
|
|
113
|
-
`access/*.*` selects every client only when `allow_all_tenants=True
|
|
116
|
+
`access/*.*` selects every client only when `allow_all_tenants=True`, including a client whose own slug is
|
|
117
|
+
ambiguous. An ambiguous slug is logged by slug only, through the standard `logging` module (the package
|
|
118
|
+
configures no logger of its own).
|
|
119
|
+
- **Blank scopes:** an admin or reader scope list that is empty, or has a blank entry, admits nobody, and
|
|
120
|
+
`validate_reader_configuration` refuses a blank or padded entry in either list.
|
|
114
121
|
- **No default for "all tenants":** `allowed_client_keys` is `None` only for `admin`. A reader always has a
|
|
115
122
|
non-empty set and a denied caller always has `frozenset()`, so a denial can never be read as unrestricted.
|
|
116
123
|
`AdminAccess` enforces this when it is constructed.
|
|
@@ -46,8 +46,11 @@ 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
|
|
50
|
-
`oidcauthlib`; the caller verifies the token, looks up the user and passes the configuration in.
|
|
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
|
+
`oidcauthlib`; the caller verifies the token, looks up the user and passes the configuration in. The
|
|
51
|
+
`access/<slug>.*` and `patient/` scope convention is the FHIR server's, described in its
|
|
52
|
+
[security guide](https://github.com/icanbwell/fhir-server/blob/main/readme/security.md) (section 5); the tier
|
|
53
|
+
model is recorded in [ADR 0001](adrs/0001-authorization-tiers-from-scopes.md).
|
|
51
54
|
|
|
52
55
|
```python
|
|
53
56
|
from oidcauthlib.authorization import (
|
|
@@ -82,7 +85,11 @@ access = resolve_admin_access(
|
|
|
82
85
|
`reader`; anything else is denied with a `DenialReason`. An empty admin or reader requirement admits nobody.
|
|
83
86
|
- **Slugs:** `access/<slug>.*` selects the client whose name, stripped and casefolded, equals the slug. Two
|
|
84
87
|
names that casefold alike make the slug ambiguous and it selects nothing. The suffix must be exactly `.*`.
|
|
85
|
-
`access/*.*` selects every client only when `allow_all_tenants=True
|
|
88
|
+
`access/*.*` selects every client only when `allow_all_tenants=True`, including a client whose own slug is
|
|
89
|
+
ambiguous. An ambiguous slug is logged by slug only, through the standard `logging` module (the package
|
|
90
|
+
configures no logger of its own).
|
|
91
|
+
- **Blank scopes:** an admin or reader scope list that is empty, or has a blank entry, admits nobody, and
|
|
92
|
+
`validate_reader_configuration` refuses a blank or padded entry in either list.
|
|
86
93
|
- **No default for "all tenants":** `allowed_client_keys` is `None` only for `admin`. A reader always has a
|
|
87
94
|
non-empty set and a denied caller always has `frozenset()`, so a denial can never be read as unrestricted.
|
|
88
95
|
`AdminAccess` enforces this when it is constructed.
|
|
@@ -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,8 +16,9 @@ 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
|
-
from dataclasses import dataclass
|
|
21
|
+
from dataclasses import dataclass, field
|
|
21
22
|
from enum import StrEnum
|
|
22
23
|
|
|
23
24
|
from oidcauthlib.authorization.client_slugs import (
|
|
@@ -25,10 +26,15 @@ from oidcauthlib.authorization.client_slugs import (
|
|
|
25
26
|
ClientSlugResolver,
|
|
26
27
|
slug_from_access_scope,
|
|
27
28
|
)
|
|
28
|
-
from oidcauthlib.authorization.scopes import has_admin_scopes, has_patient_scope
|
|
29
|
+
from oidcauthlib.authorization.scopes import has_admin_scopes, has_blank_scope, has_patient_scope
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
logger = logging.getLogger(__name__)
|
|
29
33
|
|
|
30
34
|
|
|
31
35
|
class AdminTier(StrEnum):
|
|
36
|
+
"""The tier a granted caller holds; a denied caller has no tier."""
|
|
37
|
+
|
|
32
38
|
ADMIN = "admin"
|
|
33
39
|
READER = "reader"
|
|
34
40
|
|
|
@@ -58,10 +64,17 @@ class AdminAccess:
|
|
|
58
64
|
"""
|
|
59
65
|
|
|
60
66
|
tier: AdminTier | None
|
|
61
|
-
|
|
67
|
+
# repr=False: client keys identify tenants and stay out of logs and tracebacks.
|
|
68
|
+
allowed_client_keys: frozenset[str] | None = field(repr=False)
|
|
62
69
|
denial_reason: DenialReason | None
|
|
63
70
|
|
|
64
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")
|
|
75
|
+
if self.allowed_client_keys is not None and not isinstance(self.allowed_client_keys, frozenset):
|
|
76
|
+
# A mutable set would let a caller widen the decision after it was made.
|
|
77
|
+
object.__setattr__(self, "allowed_client_keys", frozenset(self.allowed_client_keys))
|
|
65
78
|
if self.tier is AdminTier.READER and not self.allowed_client_keys:
|
|
66
79
|
raise ValueError("a reader needs a non-empty set of client keys it may read")
|
|
67
80
|
if self.tier is AdminTier.ADMIN and self.allowed_client_keys is not None:
|
|
@@ -74,10 +87,12 @@ class AdminAccess:
|
|
|
74
87
|
|
|
75
88
|
@classmethod
|
|
76
89
|
def admin(cls) -> "AdminAccess":
|
|
90
|
+
"""An unrestricted administrator."""
|
|
77
91
|
return cls(tier=AdminTier.ADMIN, allowed_client_keys=None, denial_reason=None)
|
|
78
92
|
|
|
79
93
|
@classmethod
|
|
80
94
|
def reader(cls, *, allowed_client_keys: frozenset[str]) -> "AdminAccess":
|
|
95
|
+
"""A tenant reader limited to ``allowed_client_keys`` (which must not be empty)."""
|
|
81
96
|
return cls(
|
|
82
97
|
tier=AdminTier.READER,
|
|
83
98
|
allowed_client_keys=allowed_client_keys,
|
|
@@ -86,6 +101,7 @@ class AdminAccess:
|
|
|
86
101
|
|
|
87
102
|
@classmethod
|
|
88
103
|
def denied(cls, *, reason: DenialReason) -> "AdminAccess":
|
|
104
|
+
"""A denied caller: no tier, an empty key set and the ``reason``."""
|
|
89
105
|
return cls(tier=None, allowed_client_keys=frozenset(), denial_reason=reason)
|
|
90
106
|
|
|
91
107
|
|
|
@@ -99,17 +115,30 @@ def resolve_admin_access(
|
|
|
99
115
|
) -> AdminAccess:
|
|
100
116
|
"""The tier ``scopes`` (the merged token and userinfo scopes) grant.
|
|
101
117
|
|
|
102
|
-
``admin_scopes`` and ``reader_scopes`` are all-of requirements; an empty one
|
|
103
|
-
admits nobody.
|
|
104
|
-
in ``
|
|
118
|
+
``admin_scopes`` and ``reader_scopes`` are all-of requirements; an empty one,
|
|
119
|
+
or one with a blank entry, admits nobody. Entries of ``scopes`` that are not
|
|
120
|
+
strings are ignored (and counted in one warning). ``allow_all_tenants`` lets ``access/*.*`` select every
|
|
121
|
+
client in ``clients``, including a client whose own slug is ambiguous. Never
|
|
122
|
+
raises.
|
|
123
|
+
|
|
124
|
+
Args:
|
|
125
|
+
scopes: the merged token and userinfo scopes of the caller.
|
|
126
|
+
admin_scopes: every one of these must be held for the administrator tier.
|
|
127
|
+
reader_scopes: every one of these must be held for the reader tier.
|
|
128
|
+
clients: resolves ``access/<slug>.*`` scopes to client keys.
|
|
129
|
+
allow_all_tenants: whether ``access/*.*`` selects every client.
|
|
105
130
|
"""
|
|
106
|
-
|
|
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)
|
|
107
136
|
if has_patient_scope(scopes=held):
|
|
108
137
|
return AdminAccess.denied(reason=DenialReason.PATIENT_SCOPE)
|
|
109
138
|
if has_admin_scopes(scopes=held, required_scopes=admin_scopes):
|
|
110
139
|
return AdminAccess.admin()
|
|
111
140
|
# An empty requirement would admit everyone (``issubset`` of the empty set).
|
|
112
|
-
if not reader_scopes or not set(reader_scopes).issubset(held):
|
|
141
|
+
if not reader_scopes or has_blank_scope(scopes=reader_scopes) or not set(reader_scopes).issubset(held):
|
|
113
142
|
return AdminAccess.denied(reason=DenialReason.NOT_A_READER)
|
|
114
143
|
slugs = {slug for scope in held if (slug := slug_from_access_scope(scope=scope)) is not None}
|
|
115
144
|
if not slugs:
|
|
@@ -13,7 +13,6 @@ Error messages name the rule that failed, never a client name or a key.
|
|
|
13
13
|
"""
|
|
14
14
|
|
|
15
15
|
import json
|
|
16
|
-
from typing import Any
|
|
17
16
|
|
|
18
17
|
|
|
19
18
|
class ClientKeysFormatError(ValueError):
|
|
@@ -25,6 +24,9 @@ def parse_client_keys_lenient(*, raw: str) -> dict[str, str]:
|
|
|
25
24
|
|
|
26
25
|
An empty value gives ``{}``. A JSON object parses as is; invalid JSON falls
|
|
27
26
|
back to comma parsing. In the comma form, an entry without ``=`` is dropped.
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
raw: the setting's value, a JSON object or a comma-separated ``name=key`` list.
|
|
28
30
|
"""
|
|
29
31
|
if not raw:
|
|
30
32
|
return {}
|
|
@@ -45,6 +47,9 @@ def parse_client_keys_lenient(*, raw: str) -> dict[str, str]:
|
|
|
45
47
|
def parse_client_keys_strict(*, raw: str) -> dict[str, str]:
|
|
46
48
|
"""Parse the mapping and refuse anything the lenient parser would repair.
|
|
47
49
|
|
|
50
|
+
Args:
|
|
51
|
+
raw: the setting's value, a JSON object or a comma-separated ``name=key`` list.
|
|
52
|
+
|
|
48
53
|
Raises:
|
|
49
54
|
ClientKeysFormatError: invalid JSON (no fall-back to comma parsing), a
|
|
50
55
|
JSON value that is not an object of strings, duplicate JSON keys, a
|
|
@@ -71,12 +76,12 @@ def parse_client_keys_strict(*, raw: str) -> dict[str, str]:
|
|
|
71
76
|
|
|
72
77
|
|
|
73
78
|
def _json_pairs(text: str) -> list[tuple[str, str]]:
|
|
79
|
+
# The caller passes text that starts with "{", so a successful parse is always an
|
|
80
|
+
# object, and ``object_pairs_hook`` gives its (name, value) pairs in order.
|
|
74
81
|
try:
|
|
75
|
-
parsed:
|
|
82
|
+
parsed: list[tuple[str, object]] = json.loads(text, object_pairs_hook=lambda pairs: pairs)
|
|
76
83
|
except json.JSONDecodeError as exc:
|
|
77
84
|
raise ClientKeysFormatError("the value is not valid JSON") from exc
|
|
78
|
-
if not isinstance(parsed, list):
|
|
79
|
-
raise ClientKeysFormatError("the JSON value is not an object")
|
|
80
85
|
pairs: list[tuple[str, str]] = []
|
|
81
86
|
for position, (name, key) in enumerate(parsed, start=1):
|
|
82
87
|
if not isinstance(key, str):
|
|
@@ -13,6 +13,8 @@ from collections.abc import Callable, Mapping
|
|
|
13
13
|
from dataclasses import dataclass, field
|
|
14
14
|
from types import MappingProxyType
|
|
15
15
|
|
|
16
|
+
from oidcauthlib.authorization.scopes import normalize_scope
|
|
17
|
+
|
|
16
18
|
logger = logging.getLogger(__name__)
|
|
17
19
|
|
|
18
20
|
ACCESS_SCOPE_PREFIX = "access/"
|
|
@@ -23,7 +25,7 @@ WILDCARD_SLUG = "*"
|
|
|
23
25
|
|
|
24
26
|
def normalize_slug(*, slug: str) -> str:
|
|
25
27
|
"""Strip and casefold a slug or a client name so they compare equal."""
|
|
26
|
-
return slug
|
|
28
|
+
return normalize_scope(scope=slug)
|
|
27
29
|
|
|
28
30
|
|
|
29
31
|
def slug_from_access_scope(*, scope: str) -> str | None:
|
|
@@ -32,8 +34,11 @@ def slug_from_access_scope(*, scope: str) -> str | None:
|
|
|
32
34
|
``access/tenant.*`` gives ``tenant`` and ``access/*.*`` gives ``*``. The suffix
|
|
33
35
|
must be exactly ``.*``: ``access/demo.read``, ``access/*.read``, ``access/demo``
|
|
34
36
|
and an empty slug (``access/.*``) all give ``None``.
|
|
37
|
+
|
|
38
|
+
Args:
|
|
39
|
+
scope: any scope string.
|
|
35
40
|
"""
|
|
36
|
-
normalized = scope
|
|
41
|
+
normalized = normalize_scope(scope=scope)
|
|
37
42
|
if not normalized.startswith(ACCESS_SCOPE_PREFIX):
|
|
38
43
|
return None
|
|
39
44
|
if not normalized.endswith(ACCESS_SCOPE_SUFFIX):
|
|
@@ -45,10 +50,16 @@ def slug_from_access_scope(*, scope: str) -> str | None:
|
|
|
45
50
|
|
|
46
51
|
@dataclass(frozen=True)
|
|
47
52
|
class ClientSlugResolver:
|
|
48
|
-
"""Slug to its one client key, and every eligible client key.
|
|
53
|
+
"""Slug to its one client key, and every eligible client key.
|
|
49
54
|
|
|
50
|
-
|
|
51
|
-
|
|
55
|
+
``all_keys`` is what ``access/*.*`` selects when a caller opts in. It holds every
|
|
56
|
+
eligible client's key, including the keys of clients whose slug is ambiguous (which
|
|
57
|
+
``keys_for`` refuses one by one). Client keys identify tenants, so both fields stay
|
|
58
|
+
out of ``repr``.
|
|
59
|
+
"""
|
|
60
|
+
|
|
61
|
+
keys_by_slug: Mapping[str, str] = field(default_factory=lambda: MappingProxyType({}), repr=False)
|
|
62
|
+
all_keys: frozenset[str] = field(default=frozenset(), repr=False)
|
|
52
63
|
|
|
53
64
|
@classmethod
|
|
54
65
|
def from_client_keys(
|
|
@@ -60,21 +71,31 @@ class ClientSlugResolver:
|
|
|
60
71
|
"""Build the resolver from a ``name -> key`` map.
|
|
61
72
|
|
|
62
73
|
Args:
|
|
63
|
-
clients: the client-key mapping. Entries with a blank name or key
|
|
74
|
+
clients: the client-key mapping. Entries with a blank name or key, or a
|
|
75
|
+
key that is not a string (for example a JSON ``null`` or number), are
|
|
64
76
|
skipped.
|
|
65
77
|
is_eligible: optional strategy ``(name, key) -> bool``. A client it
|
|
66
78
|
rejects is in neither ``keys_by_slug`` nor ``all_keys``, and does
|
|
67
79
|
not take part in ambiguity checks.
|
|
68
80
|
"""
|
|
69
81
|
keys_by_slug_candidates: dict[str, list[str]] = {}
|
|
82
|
+
skipped_non_string = 0
|
|
70
83
|
for name, key in clients.items():
|
|
84
|
+
if not isinstance(key, str):
|
|
85
|
+
skipped_non_string += 1
|
|
86
|
+
continue
|
|
71
87
|
slug = normalize_slug(slug=str(name))
|
|
72
|
-
clean_key =
|
|
88
|
+
clean_key = key.strip()
|
|
73
89
|
if not slug or not clean_key:
|
|
74
90
|
continue
|
|
75
91
|
if is_eligible is not None and not is_eligible(str(name), clean_key):
|
|
76
92
|
continue
|
|
77
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
|
+
)
|
|
78
99
|
keys_by_slug: dict[str, str] = {}
|
|
79
100
|
for slug, keys in keys_by_slug_candidates.items():
|
|
80
101
|
if slug == WILDCARD_SLUG:
|
|
@@ -11,10 +11,12 @@ 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
|
|
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"})
|
|
18
|
+
# A reader scope with this suffix would read like the all-tenants access scope.
|
|
19
|
+
WILDCARD_SCOPE_SUFFIX = "*.*"
|
|
18
20
|
|
|
19
21
|
|
|
20
22
|
class ReaderConfigurationError(ValueError):
|
|
@@ -27,10 +29,20 @@ def validate_reader_configuration(
|
|
|
27
29
|
admin_scopes: Sequence[str],
|
|
28
30
|
client_keys_raw: str,
|
|
29
31
|
) -> None:
|
|
30
|
-
"""Refuse an unsafe reader-tier configuration.
|
|
32
|
+
"""Refuse an unsafe reader-tier configuration.
|
|
33
|
+
|
|
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
|
+
remaining checks are skipped when no reader scopes are set.
|
|
37
|
+
|
|
38
|
+
Args:
|
|
39
|
+
reader_scopes: the scopes that together grant the reader tier.
|
|
40
|
+
admin_scopes: the scopes that together grant the administrator tier.
|
|
41
|
+
client_keys_raw: the raw client-key mapping setting.
|
|
31
42
|
|
|
32
43
|
Raises:
|
|
33
|
-
ReaderConfigurationError: when
|
|
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
|
|
34
46
|
mapping fails the strict parser, is empty, or has a name containing
|
|
35
47
|
``*``; a reader scope overlaps an administrator scope, starts with
|
|
36
48
|
``access/`` or ``patient/``, is generic (``openid``, ``profile``,
|
|
@@ -38,6 +50,11 @@ def validate_reader_configuration(
|
|
|
38
50
|
starts with ``access/`` (a reader holding ``access/*.*`` would then be
|
|
39
51
|
an administrator).
|
|
40
52
|
"""
|
|
53
|
+
for scopes in (reader_scopes, admin_scopes):
|
|
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
|
+
)
|
|
41
58
|
if not reader_scopes:
|
|
42
59
|
return
|
|
43
60
|
try:
|
|
@@ -50,9 +67,9 @@ def validate_reader_configuration(
|
|
|
50
67
|
raise ReaderConfigurationError(
|
|
51
68
|
f"a client name contains '{WILDCARD_SLUG}', which collides with the wildcard slug"
|
|
52
69
|
)
|
|
53
|
-
admin_normalized = {scope
|
|
70
|
+
admin_normalized = {normalize_scope(scope=scope) for scope in admin_scopes}
|
|
54
71
|
for scope in reader_scopes:
|
|
55
|
-
normalized = scope
|
|
72
|
+
normalized = normalize_scope(scope=scope)
|
|
56
73
|
if normalized in admin_normalized:
|
|
57
74
|
raise ReaderConfigurationError("a reader scope overlaps an administrator scope")
|
|
58
75
|
if normalized.startswith(ACCESS_SCOPE_PREFIX) or normalized.startswith(PATIENT_SCOPE_PREFIX):
|
|
@@ -61,9 +78,9 @@ def validate_reader_configuration(
|
|
|
61
78
|
)
|
|
62
79
|
if normalized in GENERIC_SCOPES:
|
|
63
80
|
raise ReaderConfigurationError("a reader scope is a generic scope every token carries")
|
|
64
|
-
if normalized.endswith(
|
|
65
|
-
raise ReaderConfigurationError("a reader scope ends in '
|
|
66
|
-
if any(scope
|
|
81
|
+
if normalized.endswith(WILDCARD_SCOPE_SUFFIX):
|
|
82
|
+
raise ReaderConfigurationError(f"a reader scope ends in '{WILDCARD_SCOPE_SUFFIX}'")
|
|
83
|
+
if any(normalize_scope(scope=scope).startswith(ACCESS_SCOPE_PREFIX) for scope in admin_scopes):
|
|
67
84
|
raise ReaderConfigurationError(
|
|
68
85
|
f"an administrator scope starts with '{ACCESS_SCOPE_PREFIX}': "
|
|
69
86
|
"a reader holding the wildcard access scope would be an administrator"
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"""Scope predicates: the patient deny and the all-of match on required scopes."""
|
|
2
|
+
|
|
3
|
+
from collections.abc import Collection, Iterable
|
|
4
|
+
|
|
5
|
+
# A token carrying any patient-scoped grant is a patient or patient-app token and
|
|
6
|
+
# is never an administrator, even if it also holds an administrator scope. The
|
|
7
|
+
# check is a prefix match on the trimmed, casefolded scope, so ``Patient/*.read``
|
|
8
|
+
# matches but ``Patient.read`` (no slash) does not.
|
|
9
|
+
PATIENT_SCOPE_PREFIX = "patient/"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def normalize_scope(*, scope: str) -> str:
|
|
13
|
+
"""Strip and casefold a scope so scopes that differ only by padding or case compare equal."""
|
|
14
|
+
return scope.strip().casefold()
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def has_blank_scope(*, scopes: Iterable[str]) -> bool:
|
|
18
|
+
"""True when any scope is not a string, is empty, is whitespace only, or has characters that do not print.
|
|
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``.
|
|
22
|
+
A blank required scope, for example the ``[""]`` that ``"".split(",")`` gives for an
|
|
23
|
+
unset setting, is satisfied by any held scope list that contains ``""`` (a token
|
|
24
|
+
scope claim split on single spaces with a double or trailing space does). Callers
|
|
25
|
+
treat a requirement list with a blank entry as unsatisfiable.
|
|
26
|
+
"""
|
|
27
|
+
return any(not isinstance(scope, str) or not scope.strip() or not scope.isprintable() for scope in scopes)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def has_patient_scope(*, scopes: Iterable[str]) -> bool:
|
|
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
|
+
)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def has_admin_scopes(*, scopes: Iterable[str], required_scopes: Collection[str]) -> bool:
|
|
38
|
+
"""True when ``scopes`` holds every required scope exactly and no ``patient/`` scope.
|
|
39
|
+
|
|
40
|
+
An empty ``required_scopes`` is always False: ``set().issubset(anything)`` is
|
|
41
|
+
True, so an empty requirement (for example an unset setting) would otherwise
|
|
42
|
+
admit every verified token. A requirement list with a blank entry is False for
|
|
43
|
+
the same reason (see ``has_blank_scope``). This is the one check every
|
|
44
|
+
administrator path applies to the merged scope set.
|
|
45
|
+
|
|
46
|
+
Args:
|
|
47
|
+
scopes: the scopes the caller holds; non-string entries are ignored.
|
|
48
|
+
required_scopes: every one of these must be held, matched exactly.
|
|
49
|
+
"""
|
|
50
|
+
if not required_scopes or has_blank_scope(scopes=required_scopes):
|
|
51
|
+
return False
|
|
52
|
+
held = {scope for scope in scopes if isinstance(scope, str)}
|
|
53
|
+
if has_patient_scope(scopes=held):
|
|
54
|
+
return False
|
|
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,8 +74,11 @@ 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
|
|
78
|
-
`oidcauthlib`; the caller verifies the token, looks up the user and passes the configuration in.
|
|
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
|
+
`oidcauthlib`; the caller verifies the token, looks up the user and passes the configuration in. The
|
|
79
|
+
`access/<slug>.*` and `patient/` scope convention is the FHIR server's, described in its
|
|
80
|
+
[security guide](https://github.com/icanbwell/fhir-server/blob/main/readme/security.md) (section 5); the tier
|
|
81
|
+
model is recorded in [ADR 0001](adrs/0001-authorization-tiers-from-scopes.md).
|
|
79
82
|
|
|
80
83
|
```python
|
|
81
84
|
from oidcauthlib.authorization import (
|
|
@@ -110,7 +113,11 @@ access = resolve_admin_access(
|
|
|
110
113
|
`reader`; anything else is denied with a `DenialReason`. An empty admin or reader requirement admits nobody.
|
|
111
114
|
- **Slugs:** `access/<slug>.*` selects the client whose name, stripped and casefolded, equals the slug. Two
|
|
112
115
|
names that casefold alike make the slug ambiguous and it selects nothing. The suffix must be exactly `.*`.
|
|
113
|
-
`access/*.*` selects every client only when `allow_all_tenants=True
|
|
116
|
+
`access/*.*` selects every client only when `allow_all_tenants=True`, including a client whose own slug is
|
|
117
|
+
ambiguous. An ambiguous slug is logged by slug only, through the standard `logging` module (the package
|
|
118
|
+
configures no logger of its own).
|
|
119
|
+
- **Blank scopes:** an admin or reader scope list that is empty, or has a blank entry, admits nobody, and
|
|
120
|
+
`validate_reader_configuration` refuses a blank or padded entry in either list.
|
|
114
121
|
- **No default for "all tenants":** `allowed_client_keys` is `None` only for `admin`. A reader always has a
|
|
115
122
|
non-empty set and a denied caller always has `frozenset()`, so a denial can never be read as unrestricted.
|
|
116
123
|
`AdminAccess` enforces this when it is constructed.
|
oidcauthlib-3.1.0/VERSION
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
3.1.0
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"""Scope predicates: the patient deny and the all-of match on required scopes."""
|
|
2
|
-
|
|
3
|
-
from collections.abc import Collection, Iterable
|
|
4
|
-
|
|
5
|
-
# A token carrying any patient-scoped grant is a patient or patient-app token and
|
|
6
|
-
# is never an administrator, even if it also holds an administrator scope. The
|
|
7
|
-
# check is a prefix match on the trimmed, casefolded scope, so ``Patient/*.read``
|
|
8
|
-
# matches but ``Patient.read`` (no slash) does not.
|
|
9
|
-
PATIENT_SCOPE_PREFIX = "patient/"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
def has_patient_scope(*, scopes: Iterable[str]) -> bool:
|
|
13
|
-
"""True when any scope starts with ``patient/`` (trimmed, case-insensitive)."""
|
|
14
|
-
return any(scope.strip().casefold().startswith(PATIENT_SCOPE_PREFIX) for scope in scopes)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
def has_admin_scopes(*, scopes: Iterable[str], required_scopes: Collection[str]) -> bool:
|
|
18
|
-
"""True when ``scopes`` holds every required scope exactly and no ``patient/`` scope.
|
|
19
|
-
|
|
20
|
-
An empty ``required_scopes`` is always False: ``set().issubset(anything)`` is
|
|
21
|
-
True, so an empty requirement (for example an unset setting) would otherwise
|
|
22
|
-
admit every verified token. This is the one check every administrator path
|
|
23
|
-
applies to the merged scope set.
|
|
24
|
-
"""
|
|
25
|
-
if not required_scopes:
|
|
26
|
-
return False
|
|
27
|
-
held = set(scopes)
|
|
28
|
-
if has_patient_scope(scopes=held):
|
|
29
|
-
return False
|
|
30
|
-
return set(required_scopes).issubset(held)
|
|
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.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/middleware/request_scope_middleware.py
RENAMED
|
File without changes
|
{oidcauthlib-3.1.0 → 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.0 → oidcauthlib-3.1.2}/oidcauthlib/auth/repository/memory/memory_repository.py
RENAMED
|
File without changes
|
|
File without changes
|
{oidcauthlib-3.1.0 → 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.0 → 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
|
{oidcauthlib-3.1.0 → 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.0 → oidcauthlib-3.1.2}/oidcauthlib/open_telemetry/filtering_span_exporter.py
RENAMED
|
File without changes
|
{oidcauthlib-3.1.0 → 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
|