scim2-server 0.8.3__tar.gz → 0.8.5__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.
- {scim2_server-0.8.3 → scim2_server-0.8.5}/PKG-INFO +1 -1
- {scim2_server-0.8.3 → scim2_server-0.8.5}/pyproject.toml +5 -4
- {scim2_server-0.8.3 → scim2_server-0.8.5}/pyproject.toml.orig +5 -4
- {scim2_server-0.8.3 → scim2_server-0.8.5}/scim2_server/applications/asgi.py +7 -1
- {scim2_server-0.8.3 → scim2_server-0.8.5}/scim2_server/applications/base.py +16 -1
- {scim2_server-0.8.3 → scim2_server-0.8.5}/scim2_server/applications/wsgi.py +7 -1
- scim2_server-0.8.5/scim2_server/testserver/application.py +114 -0
- {scim2_server-0.8.3 → scim2_server-0.8.5}/scim2_server/testserver/cli.py +27 -11
- scim2_server-0.8.3/scim2_server/testserver/application.py +0 -48
- {scim2_server-0.8.3 → scim2_server-0.8.5}/LICENSE +0 -0
- {scim2_server-0.8.3 → scim2_server-0.8.5}/README.md +0 -0
- {scim2_server-0.8.3 → scim2_server-0.8.5}/scim2_server/__init__.py +0 -0
- {scim2_server-0.8.3 → scim2_server-0.8.5}/scim2_server/applications/__init__.py +0 -0
- {scim2_server-0.8.3 → scim2_server-0.8.5}/scim2_server/bulk.py +0 -0
- {scim2_server-0.8.3 → scim2_server-0.8.5}/scim2_server/conditions.py +0 -0
- {scim2_server-0.8.3 → scim2_server-0.8.5}/scim2_server/cursor.py +0 -0
- {scim2_server-0.8.3 → scim2_server-0.8.5}/scim2_server/errors.py +0 -0
- {scim2_server-0.8.3 → scim2_server-0.8.5}/scim2_server/handler.py +0 -0
- {scim2_server-0.8.3 → scim2_server-0.8.5}/scim2_server/memory.py +0 -0
- {scim2_server-0.8.3 → scim2_server-0.8.5}/scim2_server/py.typed +0 -0
- {scim2_server-0.8.3 → scim2_server-0.8.5}/scim2_server/requests.py +0 -0
- {scim2_server-0.8.3 → scim2_server-0.8.5}/scim2_server/resources/default-resource-types.json +0 -0
- {scim2_server-0.8.3 → scim2_server-0.8.5}/scim2_server/resources/default-schemas.json +0 -0
- {scim2_server-0.8.3 → scim2_server-0.8.5}/scim2_server/resources/default-service-provider-config.json +0 -0
- {scim2_server-0.8.3 → scim2_server-0.8.5}/scim2_server/responses.py +0 -0
- {scim2_server-0.8.3 → scim2_server-0.8.5}/scim2_server/routing.py +0 -0
- {scim2_server-0.8.3 → scim2_server-0.8.5}/scim2_server/service.py +0 -0
- {scim2_server-0.8.3 → scim2_server-0.8.5}/scim2_server/storage.py +0 -0
- {scim2_server-0.8.3 → scim2_server-0.8.5}/scim2_server/testing.py +0 -0
- {scim2_server-0.8.3 → scim2_server-0.8.5}/scim2_server/testserver/__init__.py +0 -0
- {scim2_server-0.8.3 → scim2_server-0.8.5}/scim2_server/testserver/precis.py +0 -0
- {scim2_server-0.8.3 → scim2_server-0.8.5}/scim2_server/utils.py +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
[build-system]
|
|
2
|
-
requires = ["uv_build>=0.12.13,<0.
|
|
2
|
+
requires = ["uv_build>=0.12.13,<0.14.0"]
|
|
3
3
|
build-backend = "uv_build"
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "scim2-server"
|
|
7
|
-
version = "0.8.
|
|
7
|
+
version = "0.8.5"
|
|
8
8
|
description = "SCIM server core for any storage and web framework"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
keywords = [
|
|
@@ -65,8 +65,8 @@ dev = [
|
|
|
65
65
|
"aiosqlite>=0.22.1",
|
|
66
66
|
"precis-i18n>=1.1.2",
|
|
67
67
|
"mypy>=2.3.1",
|
|
68
|
-
"scim2-client>=0.
|
|
69
|
-
"scim2-tester>=0.
|
|
68
|
+
"scim2-client>=0.14.0",
|
|
69
|
+
"scim2-tester[testing]>=0.6.2",
|
|
70
70
|
"werkzeug>=3.0.3",
|
|
71
71
|
"cryptography>=50.0.1",
|
|
72
72
|
]
|
|
@@ -159,6 +159,7 @@ docstring-code-format = true
|
|
|
159
159
|
addopts = "--doctest-modules --doctest-glob='*.rst' --ignore=doc/conf.py"
|
|
160
160
|
pythonpath = ["doc/_examples"]
|
|
161
161
|
doctest_optionflags = "ALLOW_UNICODE IGNORE_EXCEPTION_DETAIL ELLIPSIS"
|
|
162
|
+
filterwarnings = ["error::scim2_tester.testing.ScimDeviationWarning"]
|
|
162
163
|
|
|
163
164
|
[tool.tox]
|
|
164
165
|
requires = ["tox>=4.19"]
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
[build-system]
|
|
2
|
-
requires = ["uv_build>=0.12.13,<0.
|
|
2
|
+
requires = ["uv_build>=0.12.13,<0.14.0"]
|
|
3
3
|
build-backend = "uv_build"
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "scim2-server"
|
|
7
|
-
version = "0.8.
|
|
7
|
+
version = "0.8.5"
|
|
8
8
|
description = "SCIM server core for any storage and web framework"
|
|
9
9
|
authors = [
|
|
10
10
|
{name="Yaal Coop", email="contact@yaal.coop"},
|
|
@@ -62,8 +62,8 @@ dev = [
|
|
|
62
62
|
"aiosqlite>=0.22.1",
|
|
63
63
|
"precis-i18n>=1.1.2",
|
|
64
64
|
"mypy>=2.3.1",
|
|
65
|
-
"scim2-client>=0.
|
|
66
|
-
"scim2-tester>=0.
|
|
65
|
+
"scim2-client>=0.14.0",
|
|
66
|
+
"scim2-tester[testing]>=0.6.2",
|
|
67
67
|
"werkzeug>=3.0.3",
|
|
68
68
|
"cryptography>=50.0.1",
|
|
69
69
|
]
|
|
@@ -148,6 +148,7 @@ docstring-code-format = true
|
|
|
148
148
|
addopts = "--doctest-modules --doctest-glob='*.rst' --ignore=doc/conf.py"
|
|
149
149
|
pythonpath = ["doc/_examples"]
|
|
150
150
|
doctest_optionflags= "ALLOW_UNICODE IGNORE_EXCEPTION_DETAIL ELLIPSIS"
|
|
151
|
+
filterwarnings = ["error::scim2_tester.testing.ScimDeviationWarning"]
|
|
151
152
|
|
|
152
153
|
[tool.tox]
|
|
153
154
|
requires = ["tox>=4.19"]
|
|
@@ -32,6 +32,8 @@ class ASGIApplication(BaseApplication):
|
|
|
32
32
|
:param storage: The storage of the resources.
|
|
33
33
|
:param provider: The description of the service.
|
|
34
34
|
:param service: The service serving the requests, built upon ``provider``.
|
|
35
|
+
:param propagate_exceptions: Whether an unexpected exception reaches the
|
|
36
|
+
caller of the application, instead of answering 500.
|
|
35
37
|
"""
|
|
36
38
|
|
|
37
39
|
def __init__(
|
|
@@ -39,8 +41,10 @@ class ASGIApplication(BaseApplication):
|
|
|
39
41
|
storage: AsyncScimStorage,
|
|
40
42
|
provider: ScimProvider,
|
|
41
43
|
service: ScimService | None = None,
|
|
44
|
+
*,
|
|
45
|
+
propagate_exceptions: bool = False,
|
|
42
46
|
):
|
|
43
|
-
super().__init__(provider, service)
|
|
47
|
+
super().__init__(provider, service, propagate_exceptions=propagate_exceptions)
|
|
44
48
|
self.storage = storage
|
|
45
49
|
self.handler = AsyncScimHandler(self.service, storage)
|
|
46
50
|
|
|
@@ -106,6 +110,8 @@ class ASGIApplication(BaseApplication):
|
|
|
106
110
|
try:
|
|
107
111
|
response = await self.dispatch_request(request)
|
|
108
112
|
except Exception as exception:
|
|
113
|
+
if self._propagates(exception):
|
|
114
|
+
raise
|
|
109
115
|
response = self.handle_exception(request, exception)
|
|
110
116
|
return self.finalize_response(request, response)
|
|
111
117
|
|
|
@@ -23,17 +23,32 @@ class BaseApplication:
|
|
|
23
23
|
:class:`~scim2_server.service.ScimService` of ``provider`` by default,
|
|
24
24
|
whose secret comes from the ``SCIM2_SERVER_SECRET`` environment
|
|
25
25
|
variable.
|
|
26
|
+
:param propagate_exceptions: Whether an unexpected exception reaches the
|
|
27
|
+
caller of the application, instead of answering 500. The
|
|
28
|
+
:class:`~scim2_models.SCIMException` still answer a SCIM error. Enable
|
|
29
|
+
it in tests, to see the traceback of a bug.
|
|
26
30
|
"""
|
|
27
31
|
|
|
28
|
-
def __init__(
|
|
32
|
+
def __init__(
|
|
33
|
+
self,
|
|
34
|
+
provider: ScimProvider,
|
|
35
|
+
service: ScimService | None = None,
|
|
36
|
+
*,
|
|
37
|
+
propagate_exceptions: bool = False,
|
|
38
|
+
):
|
|
29
39
|
self.provider = provider
|
|
30
40
|
self.service = (
|
|
31
41
|
service
|
|
32
42
|
if service is not None
|
|
33
43
|
else ScimService(provider, secret=os.environ.get("SCIM2_SERVER_SECRET"))
|
|
34
44
|
)
|
|
45
|
+
self.propagate_exceptions = propagate_exceptions
|
|
35
46
|
self.log = logging.getLogger("scim2_server")
|
|
36
47
|
|
|
48
|
+
def _propagates(self, exception: Exception) -> bool:
|
|
49
|
+
"""Tell whether an exception raised while serving a request reaches the caller."""
|
|
50
|
+
return self.propagate_exceptions and not isinstance(exception, SCIMException)
|
|
51
|
+
|
|
37
52
|
@staticmethod
|
|
38
53
|
def split_path(path: str) -> str:
|
|
39
54
|
"""Return the path of a request, relative to the root URL of the SCIM endpoints.
|
|
@@ -47,6 +47,8 @@ class WSGIApplication(BaseApplication):
|
|
|
47
47
|
:param storage: The storage of the resources.
|
|
48
48
|
:param provider: The description of the service.
|
|
49
49
|
:param service: The service serving the requests, built upon ``provider``.
|
|
50
|
+
:param propagate_exceptions: Whether an unexpected exception reaches the
|
|
51
|
+
caller of the application, instead of answering 500.
|
|
50
52
|
"""
|
|
51
53
|
|
|
52
54
|
def __init__(
|
|
@@ -54,8 +56,10 @@ class WSGIApplication(BaseApplication):
|
|
|
54
56
|
storage: ScimStorage,
|
|
55
57
|
provider: ScimProvider,
|
|
56
58
|
service: ScimService | None = None,
|
|
59
|
+
*,
|
|
60
|
+
propagate_exceptions: bool = False,
|
|
57
61
|
):
|
|
58
|
-
super().__init__(provider, service)
|
|
62
|
+
super().__init__(provider, service, propagate_exceptions=propagate_exceptions)
|
|
59
63
|
self.storage = storage
|
|
60
64
|
self.handler = ScimHandler(self.service, storage)
|
|
61
65
|
|
|
@@ -122,6 +126,8 @@ class WSGIApplication(BaseApplication):
|
|
|
122
126
|
try:
|
|
123
127
|
response = self.dispatch_request(request)
|
|
124
128
|
except Exception as exception:
|
|
129
|
+
if self._propagates(exception):
|
|
130
|
+
raise
|
|
125
131
|
response = self.handle_exception(request, exception)
|
|
126
132
|
return self.finalize_response(request, response)
|
|
127
133
|
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"""The SCIM application of the ``scim2-server`` command."""
|
|
2
|
+
|
|
3
|
+
import base64
|
|
4
|
+
import binascii
|
|
5
|
+
import hmac
|
|
6
|
+
from collections.abc import Iterable
|
|
7
|
+
|
|
8
|
+
from scim2_models import AuthenticationScheme
|
|
9
|
+
from scim2_models import External
|
|
10
|
+
from scim2_models import Reference
|
|
11
|
+
from scim2_models import ScimProvider
|
|
12
|
+
from scim2_models import ServiceProviderConfig
|
|
13
|
+
from scim2_models import UnauthorizedException
|
|
14
|
+
|
|
15
|
+
from scim2_server.applications.wsgi import WSGIApplication
|
|
16
|
+
from scim2_server.requests import ScimRequest
|
|
17
|
+
from scim2_server.service import ScimService
|
|
18
|
+
from scim2_server.storage import ScimStorage
|
|
19
|
+
|
|
20
|
+
BEARER_TOKEN_SCHEME = AuthenticationScheme(
|
|
21
|
+
type=AuthenticationScheme.Type.oauthbearertoken,
|
|
22
|
+
name="bearer_token",
|
|
23
|
+
description="HTTP Bearer Token",
|
|
24
|
+
spec_uri=Reference[External]("https://datatracker.ietf.org/doc/html/rfc6750"),
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
BASIC_SCHEME = AuthenticationScheme(
|
|
28
|
+
type=AuthenticationScheme.Type.httpbasic,
|
|
29
|
+
name="basic",
|
|
30
|
+
description="HTTP Basic",
|
|
31
|
+
spec_uri=Reference[External]("https://datatracker.ietf.org/doc/html/rfc7617"),
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def announce_authentication_schemes(
|
|
36
|
+
config: ServiceProviderConfig, bearer_token: bool, basic: bool
|
|
37
|
+
) -> None:
|
|
38
|
+
"""Add the schemes of the accepted credentials to a service provider configuration.
|
|
39
|
+
|
|
40
|
+
Without credentials, the application accepts any bearer token. If the
|
|
41
|
+
configuration has no scheme then, it announces the bearer token scheme,
|
|
42
|
+
because the ``authenticationSchemes`` attribute is required
|
|
43
|
+
(:rfc:`RFC 7643 §5 <7643#section-5>`).
|
|
44
|
+
"""
|
|
45
|
+
schemes = list(config.authentication_schemes or [])
|
|
46
|
+
if bearer_token or not (basic or schemes):
|
|
47
|
+
schemes.append(BEARER_TOKEN_SCHEME)
|
|
48
|
+
if basic:
|
|
49
|
+
schemes.append(BASIC_SCHEME)
|
|
50
|
+
config.authentication_schemes = schemes
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def _equals(value: str, expected: str) -> bool:
|
|
54
|
+
return hmac.compare_digest(value.encode(), expected.encode())
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def decode_basic_credentials(value: str) -> tuple[str, str] | None:
|
|
58
|
+
"""Return the user and the password of Basic credentials, or None if they are malformed."""
|
|
59
|
+
try:
|
|
60
|
+
decoded = base64.b64decode(value, validate=True).decode()
|
|
61
|
+
except (binascii.Error, UnicodeDecodeError):
|
|
62
|
+
return None
|
|
63
|
+
user, separator, password = decoded.partition(":")
|
|
64
|
+
if not separator:
|
|
65
|
+
return None
|
|
66
|
+
return user, password
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class StaticCredentialsApplication(WSGIApplication):
|
|
70
|
+
"""A SCIM application that only accepts static bearer tokens and Basic credentials.
|
|
71
|
+
|
|
72
|
+
Without token nor credentials, it accepts every request. List
|
|
73
|
+
:data:`BEARER_TOKEN_SCHEME` and :data:`BASIC_SCHEME` in the service
|
|
74
|
+
provider configuration, so that the 401 responses carry a
|
|
75
|
+
:mdn:`WWW-Authenticate` header.
|
|
76
|
+
"""
|
|
77
|
+
|
|
78
|
+
def __init__(
|
|
79
|
+
self,
|
|
80
|
+
storage: ScimStorage,
|
|
81
|
+
provider: ScimProvider,
|
|
82
|
+
service: ScimService | None = None,
|
|
83
|
+
bearer_tokens: Iterable[str] = (),
|
|
84
|
+
basic_credentials: Iterable[tuple[str, str]] = (),
|
|
85
|
+
):
|
|
86
|
+
super().__init__(storage, provider, service)
|
|
87
|
+
self.bearer_tokens = list(bearer_tokens)
|
|
88
|
+
self.basic_credentials = list(basic_credentials)
|
|
89
|
+
|
|
90
|
+
def check_auth(self, request: ScimRequest) -> None:
|
|
91
|
+
"""Refuse a request without one of the bearer tokens or Basic credentials."""
|
|
92
|
+
if not self.bearer_tokens and not self.basic_credentials:
|
|
93
|
+
return
|
|
94
|
+
scheme, _, value = (request.header("Authorization") or "").partition(" ")
|
|
95
|
+
if scheme.lower() == "bearer" and self.is_valid_token(value):
|
|
96
|
+
return
|
|
97
|
+
if scheme.lower() == "basic" and self.are_valid_credentials(value):
|
|
98
|
+
return
|
|
99
|
+
raise UnauthorizedException
|
|
100
|
+
|
|
101
|
+
def is_valid_token(self, token: str) -> bool:
|
|
102
|
+
"""Tell whether a token is one of the bearer tokens."""
|
|
103
|
+
return any(_equals(token, expected) for expected in self.bearer_tokens)
|
|
104
|
+
|
|
105
|
+
def are_valid_credentials(self, value: str) -> bool:
|
|
106
|
+
"""Tell whether encoded Basic credentials are among the accepted ones."""
|
|
107
|
+
credentials = decode_basic_credentials(value)
|
|
108
|
+
if credentials is None:
|
|
109
|
+
return False
|
|
110
|
+
user, password = credentials
|
|
111
|
+
return any(
|
|
112
|
+
_equals(user, expected_user) and _equals(password, expected_password)
|
|
113
|
+
for expected_user, expected_password in self.basic_credentials
|
|
114
|
+
)
|
|
@@ -20,8 +20,8 @@ from scim2_server.applications.wsgi import ForwardedHeaders
|
|
|
20
20
|
from scim2_server.applications.wsgi import TenantDispatcher
|
|
21
21
|
from scim2_server.memory import InMemoryStorage
|
|
22
22
|
from scim2_server.service import ScimService
|
|
23
|
-
from scim2_server.testserver.application import
|
|
24
|
-
from scim2_server.testserver.application import
|
|
23
|
+
from scim2_server.testserver.application import StaticCredentialsApplication
|
|
24
|
+
from scim2_server.testserver.application import announce_authentication_schemes
|
|
25
25
|
from scim2_server.utils import load_default_resource_types
|
|
26
26
|
from scim2_server.utils import load_default_schemas
|
|
27
27
|
from scim2_server.utils import load_default_service_provider_config
|
|
@@ -55,6 +55,14 @@ def dump_resources(storage: InMemoryStorage) -> list[dict[str, Any]]:
|
|
|
55
55
|
return [r.model_dump() for r in storage.resources]
|
|
56
56
|
|
|
57
57
|
|
|
58
|
+
def basic_credentials(value: str) -> tuple[str, str]:
|
|
59
|
+
"""Split the ``USER:PASSWORD`` value of the ``--basic-auth`` option."""
|
|
60
|
+
user, separator, password = value.partition(":")
|
|
61
|
+
if not separator:
|
|
62
|
+
raise argparse.ArgumentTypeError("expected USER:PASSWORD")
|
|
63
|
+
return user, password
|
|
64
|
+
|
|
65
|
+
|
|
58
66
|
def build_parser() -> argparse.ArgumentParser:
|
|
59
67
|
"""Build the parser of the ``scim2-server`` command."""
|
|
60
68
|
parser = argparse.ArgumentParser(
|
|
@@ -88,7 +96,16 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
88
96
|
action="append",
|
|
89
97
|
metavar="TOKEN",
|
|
90
98
|
help="Accept a static bearer token, and announce the bearer token scheme. "
|
|
91
|
-
"Can be repeated.
|
|
99
|
+
"Can be repeated.",
|
|
100
|
+
)
|
|
101
|
+
parser.add_argument(
|
|
102
|
+
"--basic-auth",
|
|
103
|
+
action="append",
|
|
104
|
+
type=basic_credentials,
|
|
105
|
+
metavar="USER:PASSWORD",
|
|
106
|
+
help="Accept HTTP Basic credentials, and announce the Basic scheme. "
|
|
107
|
+
"Can be repeated. Without --bearer-token nor --basic-auth, the server "
|
|
108
|
+
"accepts every request.",
|
|
92
109
|
)
|
|
93
110
|
parser.add_argument(
|
|
94
111
|
"--precis",
|
|
@@ -172,11 +189,9 @@ def main() -> None:
|
|
|
172
189
|
json.load(args.service_provider_config)
|
|
173
190
|
)
|
|
174
191
|
|
|
175
|
-
|
|
176
|
-
config.
|
|
177
|
-
|
|
178
|
-
BEARER_TOKEN_SCHEME,
|
|
179
|
-
]
|
|
192
|
+
announce_authentication_schemes(
|
|
193
|
+
config, bool(args.bearer_token), bool(args.basic_auth)
|
|
194
|
+
)
|
|
180
195
|
|
|
181
196
|
policy = None
|
|
182
197
|
if args.precis:
|
|
@@ -206,16 +221,17 @@ def main() -> None:
|
|
|
206
221
|
|
|
207
222
|
storages: dict[str | None, InMemoryStorage] = {}
|
|
208
223
|
|
|
209
|
-
def make_application(tenant: str | None = None) ->
|
|
224
|
+
def make_application(tenant: str | None = None) -> StaticCredentialsApplication:
|
|
210
225
|
storages[tenant] = InMemoryStorage()
|
|
211
|
-
return
|
|
226
|
+
return StaticCredentialsApplication(
|
|
212
227
|
storages[tenant],
|
|
213
228
|
provider,
|
|
214
229
|
service=service,
|
|
215
230
|
bearer_tokens=args.bearer_token or [],
|
|
231
|
+
basic_credentials=args.basic_auth or [],
|
|
216
232
|
)
|
|
217
233
|
|
|
218
|
-
def make_tenant_application(tenant: str) ->
|
|
234
|
+
def make_tenant_application(tenant: str) -> StaticCredentialsApplication | None:
|
|
219
235
|
if not args.dynamic_tenants and tenant not in args.tenant:
|
|
220
236
|
return None
|
|
221
237
|
return make_application(tenant)
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"""The SCIM application of the ``scim2-server`` command."""
|
|
2
|
-
|
|
3
|
-
from collections.abc import Iterable
|
|
4
|
-
|
|
5
|
-
from scim2_models import AuthenticationScheme
|
|
6
|
-
from scim2_models import External
|
|
7
|
-
from scim2_models import Reference
|
|
8
|
-
from scim2_models import ScimProvider
|
|
9
|
-
from scim2_models import UnauthorizedException
|
|
10
|
-
|
|
11
|
-
from scim2_server.applications.wsgi import WSGIApplication
|
|
12
|
-
from scim2_server.requests import ScimRequest
|
|
13
|
-
from scim2_server.service import ScimService
|
|
14
|
-
from scim2_server.storage import ScimStorage
|
|
15
|
-
|
|
16
|
-
BEARER_TOKEN_SCHEME = AuthenticationScheme(
|
|
17
|
-
type=AuthenticationScheme.Type.oauthbearertoken,
|
|
18
|
-
name="bearer_token",
|
|
19
|
-
description="HTTP Bearer Token",
|
|
20
|
-
spec_uri=Reference[External]("https://datatracker.ietf.org/doc/html/rfc6750"),
|
|
21
|
-
)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
class BearerTokenApplication(WSGIApplication):
|
|
25
|
-
"""A SCIM application that only accepts static bearer tokens.
|
|
26
|
-
|
|
27
|
-
Without token, it accepts every request. List
|
|
28
|
-
:data:`BEARER_TOKEN_SCHEME` in the service provider configuration, so
|
|
29
|
-
that the 401 responses carry a :mdn:`WWW-Authenticate` header.
|
|
30
|
-
"""
|
|
31
|
-
|
|
32
|
-
def __init__(
|
|
33
|
-
self,
|
|
34
|
-
storage: ScimStorage,
|
|
35
|
-
provider: ScimProvider,
|
|
36
|
-
service: ScimService | None = None,
|
|
37
|
-
bearer_tokens: Iterable[str] = (),
|
|
38
|
-
):
|
|
39
|
-
super().__init__(storage, provider, service)
|
|
40
|
-
self.bearer_tokens = set(bearer_tokens)
|
|
41
|
-
|
|
42
|
-
def check_auth(self, request: ScimRequest) -> None:
|
|
43
|
-
"""Refuse a request without one of the bearer tokens."""
|
|
44
|
-
if not self.bearer_tokens:
|
|
45
|
-
return
|
|
46
|
-
scheme, _, token = (request.header("Authorization") or "").partition(" ")
|
|
47
|
-
if scheme.lower() != "bearer" or token not in self.bearer_tokens:
|
|
48
|
-
raise UnauthorizedException
|
|
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
|
{scim2_server-0.8.3 → scim2_server-0.8.5}/scim2_server/resources/default-resource-types.json
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
|