Skip to content

Commit bb183f2

Browse files
authored
Update OIDC handling and add policies (#57)
* Update OIDC handling * Update documentation * Update settings
1 parent 563a2cb commit bb183f2

16 files changed

+711
-155
lines changed

docs/package/api/app.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* [register\_well\_known](#openeo_fastapi.api.app.OpenEOApi.register_well_known)
66
* [register\_get\_capabilities](#openeo_fastapi.api.app.OpenEOApi.register_get_capabilities)
77
* [register\_get\_conformance](#openeo_fastapi.api.app.OpenEOApi.register_get_conformance)
8+
* [register\_get\_credentials\_oidc](#openeo_fastapi.api.app.OpenEOApi.register_get_credentials_oidc)
89
* [register\_get\_file\_formats](#openeo_fastapi.api.app.OpenEOApi.register_get_file_formats)
910
* [register\_get\_health](#openeo_fastapi.api.app.OpenEOApi.register_get_health)
1011
* [register\_get\_user\_info](#openeo_fastapi.api.app.OpenEOApi.register_get_user_info)
@@ -85,6 +86,16 @@ def register_get_conformance()
8586

8687
Register endpoint for api conformance (GET /conformance).
8788

89+
<a id="openeo_fastapi.api.app.OpenEOApi.register_get_credentials_oidc"></a>
90+
91+
#### register\_get\_credentials\_oidc
92+
93+
```python
94+
def register_get_credentials_oidc()
95+
```
96+
97+
Register endpoint for api conformance (GET /conformance).
98+
8899
<a id="openeo_fastapi.api.app.OpenEOApi.register_get_file_formats"></a>
89100

90101
#### register\_get\_file\_formats
@@ -404,4 +415,3 @@ def __attrs_post_init__()
404415
```
405416

406417
Post-init hook responsible for setting up the application upon instantiation of the class.
407-

docs/package/cli.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Defining group for executor CLI.
2727

2828
```python
2929
@click.command()
30-
@click.option('--path', default=None, type=str)
30+
@click.option("--path", default=None, type=str)
3131
def new(path)
3232
```
3333

docs/package/client/settings.md

+35-5
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
* [OPENEO\_PREFIX](#openeo_fastapi.client.settings.AppSettings.OPENEO_PREFIX)
1111
* [OIDC\_URL](#openeo_fastapi.client.settings.AppSettings.OIDC_URL)
1212
* [OIDC\_ORGANISATION](#openeo_fastapi.client.settings.AppSettings.OIDC_ORGANISATION)
13-
* [OIDC\_ROLES](#openeo_fastapi.client.settings.AppSettings.OIDC_ROLES)
13+
* [OIDC\_POLICIES](#openeo_fastapi.client.settings.AppSettings.OIDC_POLICIES)
1414
* [STAC\_VERSION](#openeo_fastapi.client.settings.AppSettings.STAC_VERSION)
1515
* [STAC\_API\_URL](#openeo_fastapi.client.settings.AppSettings.STAC_API_URL)
1616
* [STAC\_COLLECTIONS\_WHITELIST](#openeo_fastapi.client.settings.AppSettings.STAC_COLLECTIONS_WHITELIST)
1717
* [ensure\_endswith\_slash](#openeo_fastapi.client.settings.AppSettings.ensure_endswith_slash)
18+
* [split\_oidc\_policies\_str\_to\_list](#openeo_fastapi.client.settings.AppSettings.split_oidc_policies_str_to_list)
1819
* [Config](#openeo_fastapi.client.settings.AppSettings.Config)
1920

2021
<a id="openeo_fastapi.client.settings"></a>
@@ -73,19 +74,37 @@ The OpenEO prefix to be used when creating the endpoint urls.
7374

7475
#### OIDC\_URL
7576

76-
The URL of the OIDC provider used to authenticate tokens against.
77+
The policies to be used for authenticated users with the backend, if not set, any usser with a valid token from the issuer is accepted.
7778

7879
<a id="openeo_fastapi.client.settings.AppSettings.OIDC_ORGANISATION"></a>
7980

8081
#### OIDC\_ORGANISATION
8182

8283
The abbreviation of the OIDC provider's organisation name, e.g. egi.
8384

84-
<a id="openeo_fastapi.client.settings.AppSettings.OIDC_ROLES"></a>
85+
<a id="openeo_fastapi.client.settings.AppSettings.OIDC_POLICIES"></a>
8586

86-
#### OIDC\_ROLES
87+
#### OIDC\_POLICIES
8788

88-
The OIDC roles to check against when authenticating a user.
89+
The OIDC policies to check against when authorizing a user. If not provided, all users with a valid token from the issuer will be admitted.
90+
91+
"&&" Is used to denote the addition of another policy.
92+
Policies in the list should be structures as "key, value".
93+
The key referers to some value that is expected to be found in the OIDC userinfo request.
94+
The value referes to some value that is then checked for presence in the values found at the key location.
95+
96+
**Example**:
97+
98+
```
99+
{
100+
101+
"groups" : [ "/staff" ]
102+
}
103+
104+
A valid policy to allow members from the group staff would be, "groups, /staff". This would be the value provided to OIDC_POLICIES.
105+
106+
If you wanted to include users from another group called "/trial", the updated value to OIDC_POLICIES would be, "groups, /staff && groups, /trial"
107+
```
89108
90109
<a id="openeo_fastapi.client.settings.AppSettings.STAC_VERSION"></a>
91110
@@ -116,6 +135,17 @@ def ensure_endswith_slash(cls, v: str) -> str
116135

117136
Ensure the STAC_API_URL ends with a trailing slash.
118137

138+
<a id="openeo_fastapi.client.settings.AppSettings.split_oidc_policies_str_to_list"></a>
139+
140+
#### split\_oidc\_policies\_str\_to\_list
141+
142+
```python
143+
@validator("OIDC_POLICIES", pre=True)
144+
def split_oidc_policies_str_to_list(cls, v: str) -> str
145+
```
146+
147+
Ensure the OIDC_POLICIES are split and formatted correctly.
148+
119149
<a id="openeo_fastapi.client.settings.AppSettings.Config"></a>
120150

121151
## Config Objects

docs/setup.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Getting Started
22

3-
Everything on this page is all you need to go from 0 to having your OpenEO Api server running locally.
3+
Everything on this page is all you need to go from 0 to having your OpenEO Api server running locally.
44

55
## Environment Setup
66

@@ -65,19 +65,19 @@ Set the target metadata. In this example, I am importing from the **/psql/models
6565

6666
## Set the environment variables
6767

68-
These variables need to be set in the environment of the deployment. Those marked required need to be set, and those set False, have some default value that only needs to be provided
68+
These variables need to be set in the environment of the deployment. Those marked required need to be set, and those set False, have some default value that only needs to be provided
6969

7070
| Variable | Description | Required |
7171
| -------- | ------- | ------- |
72-
| API_DNS | The domain name hosting the API. | True |
72+
| API_DNS | The domain name hosting the API. | True |
7373
| API_TLS | Whether the API http scheme should be http or https. | True |
74-
| API_TITLE | The API title to be provided to FastAPI. | True |
74+
| API_TITLE | The API title to be provided to FastAPI. | True |
7575
| API_DESCRIPTION | The API description to be provided to FastAPI. | True |
7676
| OPENEO_VERSION | The OpenEO Api specification version supported in this deployment of the API. Defaults to "1.1.0". | False |
7777
| OPENEO_PREFIX | The OpenEO prefix to be used when creating the endpoint urls. Defaults to the value of the openeo_version | True |
7878
| OIDC_URL | The URL of the OIDC provider used to authenticate tokens against. | True |
7979
| OIDC_ORGANISATION | The abbreviation of the OIDC provider's organisation name. | True |
80-
| OIDC_ROLES | The OIDC roles to check against when authenticating a user. | False |
80+
| OIDC_POLICIES | The OIDC policies user to check to authorize a user. | False |
8181
| STAC_VERSION | The STAC Version that is being supported by this deployments data discovery endpoints. Defaults to "1.0.0". | False |
8282
| STAC_API_URL | The STAC URL of the catalogue that the application deployment will proxy to. | True |
8383
| STAC_COLLECTIONS_WHITELIST | The collection ids to filter by when proxying to the Stac catalogue. | False |
@@ -88,6 +88,7 @@ These variables need to be set in the environment of the deployment. Those marke
8888
| POSTGRES_DB | The name of the databse being used on the host. | True |
8989
| ALEMBIC_DIR | The path to the alembic directory for applying revisions. | True |
9090

91+
9192
## Deploy the application.
9293

9394
1. Revise the database.

0 commit comments

Comments
 (0)