-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/flyway atlas read only user #2342
Open
rkboyce
wants to merge
6
commits into
OHDSI:master
Choose a base branch
from
vinci-ohdsi:fix/flyway-atlas-read-only-user
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c3e01d1
fix to the Atlas resd-restricted role to add permissions for all appr…
rkboyce 700ee82
file path name fix
rkboyce 939ef57
fix: remove all * permissions from role 15
pieterlukasse fc7b296
fix: add missing read permissions to PermissionSchema classes
pieterlukasse 80c9780
Merge pull request #8 from pieterlukasse/patch-4
rkboyce 5b91043
Merge pull request #7 from pieterlukasse/patch-3
rkboyce File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
155 changes: 155 additions & 0 deletions
155
...ion/postgresql/V2.14.1.20240130082100__fix_atlas_read_restricted_role_and_permissions.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
-- When using role 15, remember to remove the role "source user" from all users. | ||
-- See also https://github.com/OHDSI/WebAPI/wiki/Read-restricted-Configuration | ||
|
||
delete from ${ohdsiSchema}.sec_role_permission where role_id = 15; | ||
|
||
INSERT INTO ${ohdsiSchema}.sec_role_permission (role_id, permission_id) | ||
with vocab_source as ( | ||
select source_key | ||
from ${ohdsiSchema}.source s | ||
inner join ${ohdsiSchema}.source_daimon sd on s.source_id = sd.source_id | ||
where sd.daimon_type = 1 | ||
), vocab_perms as ( | ||
select distinct concat(l,m,r) perm | ||
from ( | ||
select * | ||
from (values | ||
('vocabulary:') | ||
) t1 (l) | ||
cross join | ||
( select source_key | ||
from vocab_source | ||
) t2 (m) | ||
cross join | ||
(values | ||
(':*:get'), | ||
(':compare:post'), | ||
(':concept:*:ancestorAndDescendant:get'), | ||
(':concept:*:get'), | ||
(':concept:*:related:get'), | ||
(':included-concepts:count:post'), | ||
(':lookup:identifiers:ancestors:post'), | ||
(':lookup:identifiers:post'), | ||
(':lookup:mapped:post'), | ||
(':lookup:recommended:post'), | ||
(':lookup:sourcecodes:post'), | ||
(':optimize:post'), | ||
(':resolveConceptSetExpression:post'), | ||
(':search:*:get'), | ||
(':search:post') | ||
) t3 (r) | ||
) combined | ||
), | ||
source_perms as ( | ||
select distinct concat(ls,ms,rs) perm | ||
from ( | ||
select * | ||
from (values | ||
('source:') | ||
) t11 (ls) | ||
cross join | ||
( select source_key | ||
from vocab_source | ||
) t22 (ms) | ||
cross join | ||
(values | ||
(':access') | ||
) t33 (rs) | ||
) combined | ||
), | ||
generate_perms as ( | ||
select distinct concat(lg,mg,rg) perm | ||
from ( | ||
select * | ||
from (values | ||
('cohortdefinition:*:generate:') | ||
) t111 (lg) | ||
cross join | ||
( select source_key | ||
from vocab_source | ||
) t222 (mg) | ||
cross join | ||
(values | ||
(':get') | ||
) t333 (rg) | ||
) combined | ||
) | ||
SELECT DISTINCT 15 role_id, permission_id | ||
FROM ${ohdsiSchema}.sec_role_permission srp | ||
INNER JOIN ${ohdsiSchema}.sec_permission sp ON srp.permission_id = sp.id | ||
WHERE | ||
sp.value IN (select perm from vocab_perms) | ||
or | ||
sp.value IN (select perm from source_perms) | ||
or | ||
sp.value IN (select perm from generate_perms) | ||
or | ||
sp.value IN | ||
( | ||
'cohort-characterization:byTags:post', | ||
'cohort-characterization:check:post', | ||
'cohort-characterization:get', | ||
'cohort-characterization:import:post', | ||
'cohort-characterization:post', | ||
'cohortanalysis:get', | ||
'cohortanalysis:post', | ||
'cohortdefinition:byTags:post', | ||
'cohortdefinition:check:post', | ||
'cohortdefinition:checkv2:post', | ||
'cohortdefinition:get', | ||
'cohortdefinition:post', | ||
'cohortdefinition:printfriendly:cohort:post', | ||
'cohortdefinition:printfriendly:conceptsets:post', | ||
'cohortdefinition:sql:post', | ||
'comparativecohortanalysis:get', | ||
'comparativecohortanalysis:post', | ||
'conceptset:byTags:post', | ||
'conceptset:check:post', | ||
'conceptset:get', | ||
'conceptset:post', | ||
'configuration:edit:ui', | ||
'estimation:check:post', | ||
'estimation:get', | ||
'estimation:import:post', | ||
'estimation:post', | ||
'executionservice:execution:run:post', | ||
'feasibility:get', | ||
'feature-analysis:aggregates:get', | ||
'feature-analysis:get', | ||
'feature-analysis:post', | ||
'ir:byTags:post', | ||
'ir:check:post', | ||
'ir:design:post', | ||
'ir:get', | ||
'ir:post', | ||
'ir:sql:post', | ||
'job:execution:get', | ||
'job:get', | ||
'notifications:get', | ||
'notifications:viewed:get', | ||
'notifications:viewed:post', | ||
'pathway-analysis:byTags:post', | ||
'pathway-analysis:check:post', | ||
'pathway-analysis:get', | ||
'pathway-analysis:import:post', | ||
'pathway-analysis:post', | ||
'plp:get', | ||
'plp:post', | ||
'prediction:get', | ||
'prediction:import:post', | ||
'prediction:post', | ||
'reusable:byTags:post', | ||
'reusable:get', | ||
'reusable:post', | ||
'source:daimon:priority:get', | ||
'source:priorityVocabulary:get', | ||
'sqlrender:translate:post', | ||
'tag:get', | ||
'tag:multiAssign:post', | ||
'tag:multiUnassign:post', | ||
'tag:post', | ||
'tag:search:get', | ||
'cohortdefinition:*:exists:get', -- weird one...but is needed / used by UI before saving a new cohortdefinition.... | ||
'conceptset:*:exists:get', -- weird one...but is needed / used by UI before saving a new conceptset.... | ||
) | ||
; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
feedback from Chris ^ ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one issue with this is that permissions like
vocabulary:*:search:*:get
do not yet exist in thesec_permission
table, so these would first have to be added as well (maybe as a first step of this migration script).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point, and that would be needed otherwise it won't find any permission IDs to assign to the role.