Skip to content

Commit 63ff9ad

Browse files
Merge pull request #130 from jverswijver/oidc_integration
OIDC integration
2 parents 07dc0ee + 3696703 commit 63ff9ad

File tree

7 files changed

+249
-104
lines changed

7 files changed

+249
-104
lines changed

CHANGELOG.md

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,92 +3,123 @@
33
Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) convention.
44

55
## [0.5.1] - 2022-09-27
6+
67
### Added
8+
79
- Schema templating for insert queries using query params PR #131
10+
- Add support for OIDC login flow PR #130 (#125)
811

912
## [0.5.0] - 2022-09-21
13+
1014
### Fixed
15+
1116
- Bugs with returning UUID and NaN values PR #128
1217

1318
### Added
19+
1420
- Support schemas with a `-` by specifying instead with `__` in dynamic spec PR #128
1521
- Support for new `antd-table` component. Prior `table` component will be deprecated in the next minor release. PR #128
1622
- Support for InsertComponent
1723

1824
## [0.4.1] - 2022-03-24
25+
1926
### Fixed
27+
2028
- Bug with otumat version not being tied to the latest PR #119
2129

2230
## [0.4.0] - 2022-03-18
31+
2332
### Fixed
33+
2434
- Bug with `order_by` not applying from fetch args PR #117
2535

2636
### Added
37+
2738
- Support for new `slider` and `dropdown-query` components PR #118
2839
- Numpy parser for `component_interface.py` to remove numpy types for json serialization PR #118
2940
- Support for loginless mode PR #118
3041

3142
## [0.3.0] - 2022-01-21
43+
3244
### Changed
45+
3346
- Hot-reload mechanism to use `otumat watch` PR #116
3447
- Renamed environment variable defining spec sheet to `PHARUS_SPEC_PATH` PR #116
3548

3649
### Added
37-
- Autoformatting strategy using `black` PR #116
50+
51+
- Autoformatting strategy using `black` PR #116
3852
- Support for sci-viz components `metadata`, `image`, `dynamic grid` PR #116
3953
- `component interface` for users to be able to load their own custom interface for sci-viz PR #116
4054

4155
### Fixed
56+
4257
- Various bugs related to datetime PR #116
4358

4459
## [0.2.3] - 2021-11-18
60+
4561
### Added
62+
4663
- Support for plot component PR #155
4764
- Fetch argument specification in `dj_query` PR #155
4865

4966
## [0.2.2] - 2021-11-10
67+
5068
### Fixed
69+
5170
- Optimize dynamic api virtual modules. PR #113
5271

5372
## [0.2.1] - 2021-11-08
73+
5474
### Fixed
75+
5576
- Error with retrieving the module's installation root path. PR #112
5677

5778
## [0.2.0] - 2021-11-02
79+
5880
### Added
81+
5982
- Dynamic api generation from spec sheet.(#103, #104, #105, #107, #108, #110) PR #106, #109
6083
- `dynamic_api_gen.py` Python script that generates `dynamic_api.py`.
6184
- Add Tests for the new dynamic api.
6285
- `server.py` now loads the routes generated dynamically from `dynamic_api.py` when it is present.
6386

6487
## [0.1.0] - 2021-03-31
88+
6589
### Added
90+
6691
- Local database instance pre-populated with sample data for `dev` Docker Compose environment. PR #99
6792
- Capability to insert multiple, update multiple, and delete multiple. PR #99
6893
- Allow dependency restriction to include secondary attributes from parent table. PR #99
6994

7095
### Changed
96+
7197
- Update `datajoint` to newly released `0.13.0`. PR #97
7298
- Rename service `pharus` to `pharus-docs` in `docs` Docker Compose environment to allow simulataneous development. PR #99
7399
- Update NGINX reverse proxy image reference. PR #99
74100
- Refactored API design to align with common REST resource naming convention. (#38) PR #99
75101
- Hide classes and methods that are internal and subject to change. PR #99
76102

77103
### Removed
104+
78105
- `InvalidDeleteRequest` exception is no longer available as it is now allowed to delete more than 1 record at a time. PR #99
79106

80107
### Fixed
108+
81109
- `uuid` types not properly restricted on `GET /record`, `DELETE /record`, and `GET /dependency`. PR #102
82110

83111
## [0.1.0b2] - 2021-03-12
84112

85113
### Fixed
114+
86115
- Fixed behavior where using list_table with a nonexistent schema_name creates it instead of returning an error message (#65) PR #63
87116

88117
### Changed
118+
89119
- Contribution policy to follow directly the general DataJoint Contribution Guideline. (#91) PR #94, #95
90120

91121
### Added
122+
92123
- Issue templates for bug reports and enhancement requests. PR #94, #95
93124
- Docker environment for documentation build. (#92) PR #94, #95
94125
- Add Sphinx-based documentation source and fix parsing issues. (#92) PR #94, #95
@@ -97,29 +128,36 @@ Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and
97128
## [0.1.0b0] - 2021-02-26
98129

99130
### Security
131+
100132
- Documentation with detail regarding warning on bearer token. (#83) PR #88
101133

102134
### Fixed
135+
103136
- Incorrect virtual module reference of `schema_virtual_module` in table metadata. (#85) PR #88
104137

105138
### Added
139+
106140
- Docker `dev` environment that supports hot reloading. PR #79
107141
- Documentation on setting up environments within `docker-compose` header. PR #79
108142
- `cascade` option for `/delete_tuple` route. (#86) PR #88
109143
- When delete with `cascade=False` fails due to foreign key relations, returns a HTTP error code of `409 Conflict` with a JSON body containing specifics of 1st child. (#86) PR #88
110144

111145
### Changed
146+
112147
- Replaced `DJConnector.snake_to_camel_case` usage with `datajoint.utils.to_camel_case`. PR #88
113148
- Default behavior for `/delete_tuple` now deletes without cascading. (#86) PR #88
114149
- Consolidated `pytest` fixtures into `__init__.py` to facilitate reuse. PR #88
115150
- Modify dependency check to not perform deep check and use accessible fk relations only. (#89) PR #90
116151
- Update nginx image to pull from datajoint organization. (#80) PR #90
117152

118153
### Removed
154+
119155
- Docker `base` environment to simplify dependencies. PR #79
120156

121157
## [0.1.0a5] - 2021-02-18
158+
122159
### Added
160+
123161
- List schemas method.
124162
- List tables method.
125163
- Data entry, update, delete, and view operations for DataJoint table tiers: `dj.Manual`, `dj.Lookup`.
@@ -128,6 +166,8 @@ Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and
128166
- Support for DataJoint attribute types: `varchar`, `int`, `float`, `datetime`, `date`, `time`, `decimal`, `uuid`.
129167
- Check dependency utility to determine child table references.
130168

169+
[0.5.1]: https://github.com/datajoint/pharus/compare/0.5.0...0.5.1
170+
[0.5.0]: https://github.com/datajoint/pharus/compare/0.4.1...0.5.0
131171
[0.4.1]: https://github.com/datajoint/pharus/compare/0.4.0...0.4.1
132172
[0.4.0]: https://github.com/datajoint/pharus/compare/0.3.0...0.4.0
133173
[0.3.0]: https://github.com/datajoint/pharus/compare/0.2.3...0.3.0
@@ -138,4 +178,4 @@ Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and
138178
[0.1.0]: https://github.com/datajoint/pharus/compare/0.1.0b2...0.1.0
139179
[0.1.0b2]: https://github.com/datajoint/pharus/compare/0.1.0b0...0.1.0b2
140180
[0.1.0b0]: https://github.com/datajoint/pharus/compare/0.1.0a5...0.1.0b0
141-
[0.1.0a5]: https://github.com/datajoint/pharus/releases/tag/0.1.0a5
181+
[0.1.0a5]: https://github.com/datajoint/pharus/releases/tag/0.1.0a5

docker-compose-dev.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ services:
2727
environment:
2828
- FLASK_ENV=development # enables logging to console from Flask
2929
- PHARUS_SPEC_PATH=tests/init/test_dynamic_api_spec.yaml # for dynamic api spec
30+
# --- only needed if you need OIDC compatability ---
31+
- PHARUS_OIDC_CLIENT_SECRET
32+
- PHARUS_OIDC_CLIENT_ID
33+
- PHARUS_OIDC_REDIRECT_URI
34+
- PHARUS_OIDC_CODE_VERIFIER
35+
- PHARUS_OIDC_TOKEN_URL
36+
- PHARUS_OIDC_PUBLIC_KEY
37+
- PHARUS_OIDC_SUBJECT_KEY=preferred_username
3038
volumes:
3139
- ./pharus:/opt/conda/lib/python3.8/site-packages/pharus
3240
command: pharus

pharus/component_interface.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,13 @@ def dumps(cls, obj):
4646

4747

4848
class FetchComponent:
49-
def __init__(self, name, component_config, static_config, jwt_payload: dict):
49+
def __init__(
50+
self,
51+
name,
52+
component_config,
53+
static_config,
54+
connect_creds: dict,
55+
):
5056
lcls = locals()
5157
self.name = name
5258
if static_config:
@@ -68,15 +74,14 @@ def __init__(self, name, component_config, static_config, jwt_payload: dict):
6874
self.dj_restriction = lcls["restriction"]
6975
else:
7076
self.dj_restriction = lambda: dict()
71-
7277
self.vm_list = [
7378
dj.VirtualModule(
7479
s,
7580
s,
7681
connection=dj.conn(
77-
host=jwt_payload["databaseAddress"],
78-
user=jwt_payload["username"],
79-
password=jwt_payload["password"],
82+
host=connect_creds["databaseAddress"],
83+
user=connect_creds["username"],
84+
password=connect_creds["password"],
8085
reset=True,
8186
),
8287
)
@@ -124,7 +129,12 @@ class InsertComponent:
124129
fields_route_format = "{route}/fields"
125130

126131
def __init__(
127-
self, name, component_config, static_config, payload, jwt_payload: dict
132+
self,
133+
name,
134+
component_config,
135+
static_config,
136+
payload,
137+
connect_creds: dict,
128138
):
129139
self.name = name
130140
self.payload = payload
@@ -141,9 +151,9 @@ def __init__(
141151
self.type = component_config["type"]
142152
self.route = component_config["route"]
143153
self.connection = dj.conn(
144-
host=jwt_payload["databaseAddress"],
145-
user=jwt_payload["username"],
146-
password=jwt_payload["password"],
154+
host=connect_creds["databaseAddress"],
155+
user=connect_creds["username"],
156+
password=connect_creds["password"],
147157
reset=True,
148158
)
149159
self.fields_map = component_config.get("map")

pharus/dynamic_api_gen.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ def populate_api():
2828
2929
@app.route('{route}', methods=['{rest_verb}'])
3030
@protected_route
31-
def {method_name}(jwt_payload: dict) -> dict:
31+
def {method_name}(connect_creds: dict) -> dict:
3232
3333
if request.method in ['{rest_verb}']:
3434
try:
3535
component_instance = type_map['{component_type}'](name='{component_name}',
3636
component_config={component},
3737
static_config={static_config},
38-
jwt_payload=jwt_payload,
38+
connect_creds=connect_creds,
3939
{payload})
4040
return component_instance.{method_name_type}()
4141
except Exception as e:
@@ -46,7 +46,7 @@ def {method_name}(jwt_payload: dict) -> dict:
4646
@app.route('{route}', methods=['{rest_verb}'])
4747
def {method_name}() -> dict:
4848
if request.method in ['{rest_verb}']:
49-
jwt_payload = dict(
49+
connect_creds = dict(
5050
databaseAddress=os.environ["PHARUS_HOST"],
5151
username=os.environ["PHARUS_USER"],
5252
password=os.environ["PHARUS_PASSWORD"],
@@ -55,7 +55,7 @@ def {method_name}() -> dict:
5555
component_instance = type_map['{component_type}'](name='{component_name}',
5656
component_config={component},
5757
static_config={static_config},
58-
jwt_payload=jwt_payload,
58+
connect_creds=connect_creds,
5959
{payload})
6060
return component_instance.{method_name_type}()
6161
except Exception as e:

0 commit comments

Comments
 (0)