Skip to content

Commit

Permalink
Migration fix_issuer_id handles also layman.authn.oauth2 value
Browse files Browse the repository at this point in the history
  • Loading branch information
jirik committed Oct 4, 2023
1 parent 8c3eccf commit 07e66b8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#### Schema migrations
- [#868](https://github.com/LayerManager/layman/issues/868) Create new table `map_layer` in prime DB schema.
#### Data migrations
- [#765](https://github.com/LayerManager/layman/issues/765) Fix `issuer_id` value in `users` table that was broken since v1.21.0.
- [#765](https://github.com/LayerManager/layman/issues/765) Fix `issuer_id` values in `users` table that were broken since v1.21.0.
- [#765](https://github.com/LayerManager/layman/issues/765) Remove `authn.txt` files from workspace directories. The same information as in `authn.txt` files is saved in prime DB schema.
- [#868](https://github.com/LayerManager/layman/issues/868) Fill table `map_layer` with relations between maps and [internal layers](doc/models.md#internal-map-layer) (layers published on this Layman instance). Relations to [external layers](doc/models.md#internal-map-layer) (layers of other servers) are not imported into the table.
### Changes
Expand Down
7 changes: 4 additions & 3 deletions src/layman/upgrade/upgrade_v1_22.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ def fix_issuer_id():

query = f'''select distinct issuer_id from {DB_SCHEMA}.users;'''
issuer_id_rows = db_util.run_query(query)
assert len(issuer_id_rows) <= 1, f"More than one issuer_id was found: {[r[0] for r in issuer_id_rows]}"
if issuer_id_rows:
assert issuer_id_rows[0][0] == 'layman.authn.oauth2.liferay', f"Unexpected issuer_id was found: {issuer_id_rows[0][0]}"
found_issuer_ids = {row[0] for row in issuer_id_rows}
known_issuer_ids = {'layman.authn.oauth2.liferay', 'layman.authn.oauth2'}
unknown_issuer_ids = found_issuer_ids - known_issuer_ids
assert len(unknown_issuer_ids) == 0, f"Unknown value(s) of issuer_id found: {unknown_issuer_ids}"

statement = f'''update {DB_SCHEMA}.users set issuer_id = 'layman.authn.oauth2';'''
db_util.run_statement(statement)
Expand Down

0 comments on commit 07e66b8

Please sign in to comment.