Skip to content

Commit 202d43a

Browse files
committed
Remove config use of authentication
1 parent 19fb4e5 commit 202d43a

33 files changed

+281
-1207
lines changed

docs/source/explanations/security.md

Lines changed: 33 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ TILED_SINGLE_USER_API_KEY=YOUR_SECRET tiled serve ...
5050
or via the configuration parameter
5151

5252
```yaml
53-
authentication:
54-
single_user_api_key: "..."
53+
single_user_api_key: "..."
5554
```
5655
5756
When the secret is set manually it this way, it is *not* logged in the terminal.
@@ -102,16 +101,14 @@ tiled serve config ...
102101
include the configuration:
103102

104103
```yaml
105-
authentication:
106-
allow_anonymous_access: true
104+
allow_anonymous_access: true
107105
```
108106
109107
This is a complete working example:
110108
111109
```yaml
112110
# config.yml
113-
authentication:
114-
allow_anonymous_access: true
111+
allow_anonymous_access: true
115112
trees:
116113
- path: /
117114
tree: tiled.examples.generated_minimal:tree
@@ -175,20 +172,18 @@ pip install pamela
175172
The configuration file(s) should include:
176173

177174
```yaml
178-
authentication:
179-
authenticator: tiled.authenticators:PAMAuthenticator
175+
authenticator: tiled.authenticators:PAMAuthenticator
180176
```
181177
182178
Here is a complete working example:
183179
184180
```yaml
185181
# pam_config.yml
186-
authentication:
187-
providers:
188-
- authenticator: tiled.authenticators:PAMAuthenticator
189-
# This 'provider' can be any string; it is used to differentiate
190-
# authentication providers when multiple ones are supported.
191-
provider: local
182+
providers:
183+
- authenticator: tiled.authenticators:PAMAuthenticator
184+
# This 'provider' can be any string; it is used to differentiate
185+
# authentication providers when multiple ones are supported.
186+
provider: local
192187
trees:
193188
- path: /
194189
tree: tiled.examples.generated_minimal:tree
@@ -248,19 +243,18 @@ pip install httpx
248243
The configuration file(s) must include the following.
249244

250245
```yaml
251-
authentication:
252-
providers:
253-
- provider: example.com
254-
authenticator: tiled.authenticators:OIDCAuthenticator
255-
args:
256-
# Values should come from your OIDC provider configuration
257-
# The audience claim is checked by the OIDC Client (Tiled)
258-
# It checks that the Authentication header that you are passed has not been intercepted
259-
# And that elevated claims from other services do not apply here
260-
audience: tiled # something unique to ensure received headers are for you
261-
client_id: tiled_client
262-
client_secret: ${OIDC_CLIENT_SECRET} # referencing an environment variable
263-
well_known_uri: example.com/.well-known/openid-configuration
246+
providers:
247+
- provider: example.com
248+
authenticator: tiled.authenticators:OIDCAuthenticator
249+
args:
250+
# Values should come from your OIDC provider configuration
251+
# The audience claim is checked by the OIDC Client (Tiled)
252+
# It checks that the Authentication header that you are passed has not been intercepted
253+
# And that elevated claims from other services do not apply here
254+
audience: tiled # something unique to ensure received headers are for you
255+
client_id: tiled_client
256+
client_secret: ${OIDC_CLIENT_SECRET} # referencing an environment variable
257+
well_known_uri: example.com/.well-known/openid-configuration
264258
```
265259
266260
There are example configurations for ORCID and Google in the directory
@@ -279,15 +273,14 @@ should only for used for development and demos.
279273

280274
```yaml
281275
# dictionary_config.yml
282-
authentication:
283-
providers:
284-
- provider: toy
285-
authenticator: tiled.authenticators:DictionaryAuthenticator
286-
args:
287-
users_to_passwords:
288-
alice: ${ALICE_PASSWORD}
289-
bob: ${BOB_PASSWORD}
290-
cara: ${CARA_PASSWORD}
276+
providers:
277+
- provider: toy
278+
authenticator: tiled.authenticators:DictionaryAuthenticator
279+
args:
280+
users_to_passwords:
281+
alice: ${ALICE_PASSWORD}
282+
bob: ${BOB_PASSWORD}
283+
cara: ${CARA_PASSWORD}
291284
trees:
292285
- path: /
293286
tree: tiled.examples.generated_minimal:tree
@@ -301,10 +294,9 @@ The ``DummyAuthenticator`` accepts *any* username and password combination.
301294
302295
```yaml
303296
# dummy_config.yml
304-
authentication:
305-
providers:
306-
- provider: toy
307-
authenticator: tiled.authenticators:DummyAuthenticator
297+
providers:
298+
- provider: toy
299+
authenticator: tiled.authenticators:DummyAuthenticator
308300
trees:
309301
- path: /
310302
tree: tiled.examples.generated_minimal:tree
@@ -326,8 +318,7 @@ To make such entries visible to *anonymous*, unauthenticated users as well,
326318
include the configuration:
327319

328320
```yaml
329-
authentication:
330-
allow_anonymous_access: true
321+
allow_anonymous_access: true
331322
```
332323
333324
See also {doc}`../reference/service-configuration`.

docs/source/how-to/direct-client.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ client = from_context(context)
5656
From a configuration file:
5757

5858
```py
59-
config = parse_configs("path/to/config.yml")
59+
config: Settings = parse_config("path/to/config.yml")
6060
app = build_app_from_config(config)
6161
context = Context.from_app(app)
6262
client = from_context(context)

docs/source/reference/authentication.md

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,9 @@ These are tuned, respectively, by the following configuration parameters,
195195
given in units of seconds. The default values are shown.
196196

197197
```yaml
198-
authentication:
199-
refresh_token_max_age: 604800 # one week
200-
session_max_age: 31536000 # 365 days
201-
access_token_max_age: 900 # 15 minutes
198+
refresh_token_max_age: 604800 # one week
199+
session_max_age: 31536000 # 365 days
200+
access_token_max_age: 900 # 15 minutes
202201
```
203202
204203
and may also be set via the environment:
@@ -237,28 +236,25 @@ With ``python``:
237236
Apply it by including the configuration
238237

239238
```yaml
240-
authentication:
241-
secret_keys:
242-
- "SECRET"
239+
secret_keys:
240+
- "SECRET"
243241
```
244242
245243
or by setting the ``TILED_SECRET_KEYS`` environment variable.
246244
247245
If you prefer, you can extract the keys from the environment like:
248246
249247
```yaml
250-
authentication:
251-
secret_keys:
252-
- "${SECRET}" # will be replaced by the environment variable
248+
secret_keys:
249+
- "${SECRET}" # will be replaced by the environment variable
253250
```
254251
255252
To rotate keys with a smooth transition, provide multiple keys
256253
257254
```yaml
258-
authentication:
259-
secret_keys:
260-
- "NEW_SECRET"
261-
- "OLD_SECRET"
255+
secret_keys:
256+
- "NEW_SECRET"
257+
- "OLD_SECRET"
262258
```
263259
264260
or set ``TILED_SECRET_KEYS`` as a json list, e.g.

docs/source/reference/service.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ See {doc}`../explanations/structures` for more context.
115115
.. autosummary::
116116
:toctree: generated
117117
118-
tiled.config.parse_configs
119-
tiled.config.construct_build_app_kwargs
118+
tiled.config.parse_config
120119
```
121120
## HTTP Server Application
122121

example_configs/google_auth.yml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
# Must set environment variables GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET to run.
2-
authentication:
3-
providers:
4-
- provider: google
5-
authenticator: tiled.authenticators:OIDCAuthenticator
6-
args:
7-
audience: tiled # something unique to ensure received headers are for you
8-
# These values come from https://console.cloud.google.com/apis/credential
9-
client_id: ${GOOGLE_CLIENT_ID}
10-
client_secret: ${GOOGLE_CLIENT_SECRET}
11-
well_known_uri: https://accounts.google.com/.well-known/openid-configuration
12-
confirmation_message: "You have logged in with Google as {id}."
2+
providers:
3+
- provider: google
4+
authenticator: tiled.authenticators:OIDCAuthenticator
5+
args:
6+
audience: tiled # something unique to ensure received headers are for you
7+
# These values come from https://console.cloud.google.com/apis/credential
8+
client_id: ${GOOGLE_CLIENT_ID}
9+
client_secret: ${GOOGLE_CLIENT_SECRET}
10+
well_known_uri: https://accounts.google.com/.well-known/openid-configuration
11+
confirmation_message: "You have logged in with Google as {id}."
1312
trees:
1413
# Just some arbitrary example data...
1514
# The point of this example is the authenticaiton above.
Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
1-
authentication:
2-
providers:
3-
- provider: one
4-
authenticator: tiled.authenticators:DictionaryAuthenticator
5-
args:
6-
users_to_passwords:
7-
alice: ${ALICE_PASSWORD}
8-
bob: ${BOB_PASSWORD}
9-
cara: ${CARA_PASSWORD}
10-
- provider: two
11-
authenticator: tiled.authenticators:DictionaryAuthenticator
12-
args:
13-
users_to_passwords:
14-
alice: ${ALICE_PASSWORD}
15-
bob: ${BOB_PASSWORD}
16-
cara: ${CARA_PASSWORD}
17-
- provider: three
18-
authenticator: tiled.authenticators:DictionaryAuthenticator
19-
args:
20-
users_to_passwords:
21-
alice: ${ALICE_PASSWORD}
22-
bob: ${BOB_PASSWORD}
23-
cara: ${CARA_PASSWORD}
1+
providers:
2+
- provider: one
3+
authenticator: tiled.authenticators:DictionaryAuthenticator
4+
args:
5+
users_to_passwords:
6+
alice: ${ALICE_PASSWORD}
7+
bob: ${BOB_PASSWORD}
8+
cara: ${CARA_PASSWORD}
9+
- provider: two
10+
authenticator: tiled.authenticators:DictionaryAuthenticator
11+
args:
12+
users_to_passwords:
13+
alice: ${ALICE_PASSWORD}
14+
bob: ${BOB_PASSWORD}
15+
cara: ${CARA_PASSWORD}
16+
- provider: three
17+
authenticator: tiled.authenticators:DictionaryAuthenticator
18+
args:
19+
users_to_passwords:
20+
alice: ${ALICE_PASSWORD}
21+
bob: ${BOB_PASSWORD}
22+
cara: ${CARA_PASSWORD}
2423
trees:
2524
- path: /
2625
tree: tiled.examples.toy_authentication:tree

example_configs/orcid_auth.yml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
# Must set environment variables ORCID_CLIENT_ID and ORCID_CLIENT_SECRET to run.
2-
authentication:
3-
providers:
4-
- provider: orcid
5-
authenticator: tiled.authenticators:OIDCAuthenticator
6-
args:
7-
audience: tiled # something unique to ensure received headers are for you
8-
# These values come from https://orcid.org/developer-tools
9-
client_id: ${ORCID_CLIENT_ID}
10-
client_secret: ${ORCID_CLIENT_SECRET}
11-
well_known_uri: https://orcid.org/.well-known/openid-configuration
12-
confirmation_message: "You have logged in with ORCID as {id}."
2+
providers:
3+
- provider: orcid
4+
authenticator: tiled.authenticators:OIDCAuthenticator
5+
args:
6+
audience: tiled # something unique to ensure received headers are for you
7+
# These values come from https://orcid.org/developer-tools
8+
client_id: ${ORCID_CLIENT_ID}
9+
client_secret: ${ORCID_CLIENT_SECRET}
10+
well_known_uri: https://orcid.org/.well-known/openid-configuration
11+
confirmation_message: "You have logged in with ORCID as {id}."
1312
trees:
1413
# Just some arbitrary example data...
1514
# The point of this example is the authenticaiton above.

example_configs/saml.yml

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
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-
authentication:
5-
providers:
6-
- provider: saml
7-
authenticator: tiled.authenticators:SAMLAuthenticator
8-
args:
9-
attribute_name: "email"
10-
saml_settings:
11-
strict: False
12-
debug: False
13-
idp:
14-
entityId: "http://localhost:8080/simplesaml/saml2/idp/metadata.php"
15-
singleSignOnService:
16-
url: "http://localhost:8080/simplesaml/saml2/idp/SSOService.php"
17-
binding: "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"
18-
singleLogoutService:
19-
url: "http://localhost:8080/simplesaml/saml2/idp/SingleLogoutService.php"
20-
binding: "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"
21-
x509cert: "MIIDXTCCAkWgAwIBAgIJALmVVuDWu4NYMA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQwHhcNMTYxMjMxMTQzNDQ3WhcNNDgwNjI1MTQzNDQ3WjBFMQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzUCFozgNb1h1M0jzNRSCjhOBnR+uVbVpaWfXYIR+AhWDdEe5ryY+CgavOg8bfLybyzFdehlYdDRgkedEB/GjG8aJw06l0qF4jDOAw0kEygWCu2mcH7XOxRt+YAH3TVHa/Hu1W3WjzkobqqqLQ8gkKWWM27fOgAZ6GieaJBN6VBSMMcPey3HWLBmc+TYJmv1dbaO2jHhKh8pfKw0W12VM8P1PIO8gv4Phu/uuJYieBWKixBEyy0lHjyixYFCR12xdh4CA47q958ZRGnnDUGFVE1QhgRacJCOZ9bd5t9mr8KLaVBYTCJo5ERE8jymab5dPqe5qKfJsCZiqWglbjUo9twIDAQABo1AwTjAdBgNVHQ4EFgQUxpuwcs/CYQOyui+r1G+3KxBNhxkwHwYDVR0jBBgwFoAUxpuwcs/CYQOyui+r1G+3KxBNhxkwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAAiWUKs/2x/viNCKi3Y6blEuCtAGhzOOZ9EjrvJ8+COH3Rag3tVBWrcBZ3/uhhPq5gy9lqw4OkvEws99/5jFsX1FJ6MKBgqfuy7yh5s1YfM0ANHYczMmYpZeAcQf2CGAaVfwTTfSlzNLsF2lW/ly7yapFzlYSJLGoVE+OHEu8g5SlNACUEfkXw+5Eghh+KzlIN7R6Q7r2ixWNFBC/jWf7NKUfJyX8qIG5md1YUeT6GBW9Bm2/1/RiO24JTaYlfLdKK9TYb8sG5B+OLab2DImG99CJ25RkAcSobWNF5zD0O6lgOo3cEdB/ksCq3hmtlC/DlLZ/D8CJ+7VuZnS1rR2naQ=="
22-
sp:
23-
entityId: "http://localhost:8000/api"
24-
assertionConsumerService:
25-
url: "http://localhost:8000/api/auth/provider/saml/code"
26-
binding: "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
27-
x509cert: ""
4+
providers:
5+
- provider: saml
6+
authenticator: tiled.authenticators:SAMLAuthenticator
7+
args:
8+
attribute_name: "email"
9+
saml_settings:
10+
strict: False
11+
debug: False
12+
idp:
13+
entityId: "http://localhost:8080/simplesaml/saml2/idp/metadata.php"
14+
singleSignOnService:
15+
url: "http://localhost:8080/simplesaml/saml2/idp/SSOService.php"
16+
binding: "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"
17+
singleLogoutService:
18+
url: "http://localhost:8080/simplesaml/saml2/idp/SingleLogoutService.php"
19+
binding: "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"
20+
x509cert: "MIIDXTCCAkWgAwIBAgIJALmVVuDWu4NYMA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQwHhcNMTYxMjMxMTQzNDQ3WhcNNDgwNjI1MTQzNDQ3WjBFMQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzUCFozgNb1h1M0jzNRSCjhOBnR+uVbVpaWfXYIR+AhWDdEe5ryY+CgavOg8bfLybyzFdehlYdDRgkedEB/GjG8aJw06l0qF4jDOAw0kEygWCu2mcH7XOxRt+YAH3TVHa/Hu1W3WjzkobqqqLQ8gkKWWM27fOgAZ6GieaJBN6VBSMMcPey3HWLBmc+TYJmv1dbaO2jHhKh8pfKw0W12VM8P1PIO8gv4Phu/uuJYieBWKixBEyy0lHjyixYFCR12xdh4CA47q958ZRGnnDUGFVE1QhgRacJCOZ9bd5t9mr8KLaVBYTCJo5ERE8jymab5dPqe5qKfJsCZiqWglbjUo9twIDAQABo1AwTjAdBgNVHQ4EFgQUxpuwcs/CYQOyui+r1G+3KxBNhxkwHwYDVR0jBBgwFoAUxpuwcs/CYQOyui+r1G+3KxBNhxkwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAAiWUKs/2x/viNCKi3Y6blEuCtAGhzOOZ9EjrvJ8+COH3Rag3tVBWrcBZ3/uhhPq5gy9lqw4OkvEws99/5jFsX1FJ6MKBgqfuy7yh5s1YfM0ANHYczMmYpZeAcQf2CGAaVfwTTfSlzNLsF2lW/ly7yapFzlYSJLGoVE+OHEu8g5SlNACUEfkXw+5Eghh+KzlIN7R6Q7r2ixWNFBC/jWf7NKUfJyX8qIG5md1YUeT6GBW9Bm2/1/RiO24JTaYlfLdKK9TYb8sG5B+OLab2DImG99CJ25RkAcSobWNF5zD0O6lgOo3cEdB/ksCq3hmtlC/DlLZ/D8CJ+7VuZnS1rR2naQ=="
21+
sp:
22+
entityId: "http://localhost:8000/api"
23+
assertionConsumerService:
24+
url: "http://localhost:8000/api/auth/provider/saml/code"
25+
binding: "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
26+
x509cert: ""
2827
trees:
2928
- path: /
3029
tree: tiled.examples.toy_authentication:tree

example_configs/single_catalog_single_user.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
authentication:
2-
# The default is false. Set to true to enable any HTTP client that can
3-
# connect to _read_. An API key is still required to write.
4-
allow_anonymous_access: false
1+
# The default is false. Set to true to enable any HTTP client that can
2+
# connect to _read_. An API key is still required to write.
3+
allow_anonymous_access: false
54
trees:
65
- path: /
76
tree: catalog
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
authentication:
2-
single_user_api_key: ${TILED_SINGLE_USER_API_KEY}
1+
single_user_api_key: ${TILED_SINGLE_USER_API_KEY}
32
trees:
43
- tree: tiled.examples.generated_minimal:tree
54
path: /

0 commit comments

Comments
 (0)