Skip to content

Commit 2df58a5

Browse files
committed
Refactor Settings object
1 parent ca8f4bb commit 2df58a5

22 files changed

+171
-232
lines changed

docs/source/explanations/security.md

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -169,18 +169,13 @@ using a username and password. It requires one additional dependency:
169169
pip install pamela
170170
```
171171

172-
The configuration file(s) should include:
173-
174-
```yaml
175-
authenticator: tiled.authenticators:PAMAuthenticator
176-
```
177-
178172
Here is a complete working example:
179173

180174
```yaml
181175
# pam_config.yml
182-
providers:
183-
- authenticator: tiled.authenticators:PAMAuthenticator
176+
authenticators:
177+
- authenticator:
178+
type: tiled.authenticators:PAMAuthenticator
184179
# This 'provider' can be any string; it is used to differentiate
185180
# authentication providers when multiple ones are supported.
186181
provider: local
@@ -243,10 +238,10 @@ pip install httpx
243238
The configuration file(s) must include the following.
244239

245240
```yaml
246-
providers:
241+
authenticators:
247242
- provider: example.com
248-
authenticator: tiled.authenticators:OIDCAuthenticator
249-
args:
243+
authenticator:
244+
type: tiled.authenticators:OIDCAuthenticator
250245
# Values should come from your OIDC provider configuration
251246
# The audience claim is checked by the OIDC Client (Tiled)
252247
# It checks that the Authentication header that you are passed has not been intercepted
@@ -273,10 +268,10 @@ should only for used for development and demos.
273268

274269
```yaml
275270
# dictionary_config.yml
276-
providers:
271+
authenticators:
277272
- provider: toy
278-
authenticator: tiled.authenticators:DictionaryAuthenticator
279-
args:
273+
authenticator:
274+
type: tiled.authenticators:DictionaryAuthenticator
280275
users_to_passwords:
281276
alice: ${ALICE_PASSWORD}
282277
bob: ${BOB_PASSWORD}
@@ -294,9 +289,10 @@ The ``DummyAuthenticator`` accepts *any* username and password combination.
294289
295290
```yaml
296291
# dummy_config.yml
297-
providers:
292+
authenticators:
298293
- provider: toy
299-
authenticator: tiled.authenticators:DummyAuthenticator
294+
authenticator:
295+
type: tiled.authenticators:DummyAuthenticator
300296
trees:
301297
- path: /
302298
tree: tiled.examples.generated_minimal:tree

example_configs/google_auth.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Must set environment variables GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET to run.
2-
providers:
2+
authenticators:
33
- provider: google
4-
authenticator: tiled.authenticators:OIDCAuthenticator
5-
args:
4+
authenticator:
5+
type: tiled.authenticators:OIDCAuthenticator
66
audience: tiled # something unique to ensure received headers are for you
77
# These values come from https://console.cloud.google.com/apis/credential
88
client_id: ${GOOGLE_CLIENT_ID}

example_configs/multiple_providers.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
providers:
1+
authenticators:
22
- provider: one
3-
authenticator: tiled.authenticators:DictionaryAuthenticator
4-
args:
3+
authenticator:
4+
type: tiled.authenticators:DictionaryAuthenticator
55
users_to_passwords:
66
alice: ${ALICE_PASSWORD}
77
bob: ${BOB_PASSWORD}
88
cara: ${CARA_PASSWORD}
99
- provider: two
10-
authenticator: tiled.authenticators:DictionaryAuthenticator
11-
args:
10+
authenticator:
11+
type: tiled.authenticators:DictionaryAuthenticator
1212
users_to_passwords:
1313
alice: ${ALICE_PASSWORD}
1414
bob: ${BOB_PASSWORD}
1515
cara: ${CARA_PASSWORD}
1616
- provider: three
17-
authenticator: tiled.authenticators:DictionaryAuthenticator
18-
args:
17+
authenticator:
18+
type: tiled.authenticators:DictionaryAuthenticator
1919
users_to_passwords:
2020
alice: ${ALICE_PASSWORD}
2121
bob: ${BOB_PASSWORD}

example_configs/orcid_auth.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Must set environment variables ORCID_CLIENT_ID and ORCID_CLIENT_SECRET to run.
2-
providers:
2+
authenticators:
33
- provider: orcid
4-
authenticator: tiled.authenticators:OIDCAuthenticator
5-
args:
4+
authenticator:
5+
type: tiled.authenticators:OIDCAuthenticator
66
audience: tiled # something unique to ensure received headers are for you
77
# These values come from https://orcid.org/developer-tools
88
client_id: ${ORCID_CLIENT_ID}

example_configs/saml.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Use this configuration with this demo docker container as the idp.
22

33
# docker run --name=testsamlidp_idp -p 8080:8080 -p 8443:8443 -e SIMPLESAMLPHP_SP_ENTITY_ID=http://localhost:8000 -e SIMPLESAMLPHP_SP_ASSERTION_CONSUMER_SERVICE=http://localhost:8000/auth/provider/saml/code -e SIMPLESAMLPHP_SP_SINGLE_LOGOUT_SERVICE=http://localhost:8000/ -d kristophjunge/test-saml-idp
4-
providers:
4+
authenticators:
55
- provider: saml
6-
authenticator: tiled.authenticators:SAMLAuthenticator
7-
args:
6+
authenticator:
7+
type: tiled.authenticators:SAMLAuthenticator
88
attribute_name: "email"
99
saml_settings:
1010
strict: False

example_configs/simple_oidc/config.yml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,15 @@
44
# - OIDC_BASE_URL (e.g. http://localhost:9000)
55
# and update 'public_keys' section below to match values at http://localhost:9000/certs
66
#
7-
authentication:
8-
providers:
9-
- provider: simple_oidc
10-
authenticator: tiled.authenticators:OIDCAuthenticator
11-
args:
12-
audience: ${OIDC_CLIENT_ID}
13-
client_id: ${OIDC_CLIENT_ID}
14-
client_secret: ${OIDC_CLIENT_SECRET}
15-
well_known_uri: "${OIDC_BASE_URL}/.well-known/openid-configuration"
16-
confirmation_message: "You have logged in with Simple OIDC as {id}."
7+
authenticators:
8+
- provider: simple_oidc
9+
authenticator:
10+
type: tiled.authenticators:OIDCAuthenticator
11+
audience: ${OIDC_CLIENT_ID}
12+
client_id: ${OIDC_CLIENT_ID}
13+
client_secret: ${OIDC_CLIENT_SECRET}
14+
well_known_uri: "${OIDC_BASE_URL}/.well-known/openid-configuration"
15+
confirmation_message: "You have logged in with Simple OIDC as {id}."
1716
trees:
1817
# Just some arbitrary example data...
1918
# The point of this example is the authenticaiton above.

example_configs/toy_authentication.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
providers:
1+
authenticators:
22
- provider: toy
3-
authenticator: tiled.authenticators:DictionaryAuthenticator
4-
args:
3+
authenticator:
4+
type: tiled.authenticators:DictionaryAuthenticator
55
users_to_passwords:
66
alice: ${ALICE_PASSWORD}
77
bob: ${BOB_PASSWORD}

tiled/_tests/test_access_control.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ def context(tmpdir_module):
7979
"authenticators": [
8080
{
8181
"provider": "toy",
82-
"authenticator": "tiled.authenticators:DictionaryAuthenticator",
83-
"args": {
82+
"authenticator": {
83+
"type": "tiled.authenticators:DictionaryAuthenticator",
8484
"users_to_passwords": {
8585
"alice": "secret1",
8686
"bob": "secret2",
8787
"admin": "admin",
88-
}
88+
},
8989
},
9090
}
9191
],
@@ -358,11 +358,11 @@ def test_service_principal_access(tmpdir):
358358
"authenticators": [
359359
{
360360
"provider": "toy",
361-
"authenticator": "tiled.authenticators:DictionaryAuthenticator",
362-
"args": {
361+
"authenticator": {
362+
"type": "tiled.authenticators:DictionaryAuthenticator",
363363
"users_to_passwords": {
364364
"admin": "admin",
365-
}
365+
},
366366
},
367367
}
368368
],

tiled/_tests/test_authentication.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ def config(sqlite_or_postgresql_database_uri):
4343
"authenticators": [
4444
{
4545
"provider": "toy",
46-
"authenticator": "tiled.authenticators:DictionaryAuthenticator",
47-
"args": {"users_to_passwords": {"alice": "secret1", "bob": "secret2"}},
46+
"authenticator": {
47+
"type": "tiled.authenticators:DictionaryAuthenticator",
48+
"users_to_passwords": {"alice": "secret1", "bob": "secret2"},
49+
},
4850
}
4951
],
5052
"database": {
@@ -260,15 +262,17 @@ def test_multiple_providers(enter_username_password, config, monkeypatch):
260262
[
261263
{
262264
"provider": "second",
263-
"authenticator": "tiled.authenticators:DictionaryAuthenticator",
264-
"args": {"users_to_passwords": {"cara": "secret3", "doug": "secret4"}},
265+
"authenticator": {
266+
"type": "tiled.authenticators:DictionaryAuthenticator",
267+
"users_to_passwords": {"cara": "secret3", "doug": "secret4"},
268+
},
265269
},
266270
{
267271
"provider": "third",
268-
"authenticator": "tiled.authenticators:DictionaryAuthenticator",
269-
"args": {
272+
"authenticator": {
273+
"type": "tiled.authenticators:DictionaryAuthenticator",
270274
# Duplicate 'cara' username.
271-
"users_to_passwords": {"cara": "secret5", "emilia": "secret6"}
275+
"users_to_passwords": {"cara": "secret5", "emilia": "secret6"},
272276
},
273277
},
274278
],
@@ -292,15 +296,17 @@ def test_multiple_providers_name_collision(config):
292296
config["authenticators"] = [
293297
{
294298
"provider": "some_name",
295-
"authenticator": "tiled.authenticators:DictionaryAuthenticator",
296-
"args": {"users_to_passwords": {"cara": "secret3", "doug": "secret4"}},
299+
"authenticator": {
300+
"type": "tiled.authenticators:DictionaryAuthenticator",
301+
"users_to_passwords": {"cara": "secret3", "doug": "secret4"},
302+
},
297303
},
298304
{
299305
"provider": "some_name", # duplicate!
300-
"authenticator": "tiled.authenticators:DictionaryAuthenticator",
301-
"args": {
306+
"authenticator": {
307+
"type": "tiled.authenticators:DictionaryAuthenticator",
302308
# Duplicate 'cara' username.
303-
"users_to_passwords": {"cara": "secret5", "emilia": "secret6"}
309+
"users_to_passwords": {"cara": "secret5", "emilia": "secret6"},
304310
},
305311
},
306312
]

tiled/_tests/test_catalog.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,13 +375,13 @@ async def test_access_control(tmpdir):
375375
"authenticators": [
376376
{
377377
"provider": "toy",
378-
"authenticator": "tiled.authenticators:DictionaryAuthenticator",
379-
"args": {
378+
"authenticator": {
379+
"type": "tiled.authenticators:DictionaryAuthenticator",
380380
"users_to_passwords": {
381381
"alice": "secret1",
382382
"bob": "secret2",
383383
"admin": "admin",
384-
}
384+
},
385385
},
386386
}
387387
],

0 commit comments

Comments
 (0)