Skip to content

Commit

Permalink
DA v2: fix glossaries permissions and refactor catalog module (#731)
Browse files Browse the repository at this point in the history
### Feature or Bugfix
- Bugfix
- Refactoring

### Detail
- moved glossaries permissions from core to module.catalog
- refractored catalog module to follow services, resolvers, db layer
design
- fix list_term_associations
- remove Columns from glossaries registry --> they cannot be tagged
- clean up unused code in glossaries

### Relates
V2.0.0 release

### Security
Please answer the questions below briefly where applicable, or write
`N/A`. Based on
[OWASP 10](https://owasp.org/Top10/en/).

`N/A` 
- Does this PR introduce or modify any input fields or queries - this
includes
fetching data from storage outside the application (e.g. a database, an
S3 bucket)?
  - Is the input sanitized?
- What precautions are you taking before deserializing the data you
consume?
  - Is injection prevented by parametrizing queries?
  - Have you ensured no `eval` or similar functions are used?
- Does this PR introduce any functionality or component that requires
authorization?
- How have you ensured it respects the existing AuthN/AuthZ mechanisms?
  - Are you logging failed auth attempts?
- Are you using or adding any cryptographic features?
  - Do you use a standard proven implementations?
  - Are the used keys controlled by the customer? Where are they stored?
- Are you introducing any new policies/roles/users?
  - Have you used the least-privilege principle? How?


By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
  • Loading branch information
dlpzx authored Sep 11, 2023
1 parent 75171c0 commit 9158691
Show file tree
Hide file tree
Showing 24 changed files with 563 additions and 863 deletions.
19 changes: 0 additions & 19 deletions backend/dataall/core/permissions/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"""
MANAGE_GROUPS = 'MANAGE_GROUPS'
MANAGE_ENVIRONMENT = 'MANAGE_ENVIRONMENT'
MANAGE_GLOSSARIES = 'MANAGE_GLOSSARIES'
MANAGE_ENVIRONMENTS = 'MANAGE_ENVIRONMENTS'
MANAGE_ORGANIZATIONS = 'MANAGE_ORGANIZATIONS'

Expand Down Expand Up @@ -94,34 +93,17 @@
REMOVE_ENVIRONMENT_CONSUMPTION_ROLE
]

"""
GLOSSARIES
"""
CREATE_CATEGORY = 'CREATE_CATEGORY'
CREATE_TERM = 'CREATE_TERM'
UPDATE_NODE = 'UPDATE_NODE'
DELETE_GLOSSARY = 'DELETE_GLOSSARY'
APPROVE_ASSOCIATION = 'APPROVE_ASSOCIATION'
GLOSSARY_ALL = [
CREATE_CATEGORY,
CREATE_TERM,
UPDATE_NODE,
DELETE_GLOSSARY,
APPROVE_ASSOCIATION,
]
"""
TENANT ALL
"""

TENANT_ALL = [
MANAGE_GLOSSARIES,
MANAGE_GROUPS,
MANAGE_ENVIRONMENTS,
MANAGE_ORGANIZATIONS,
]

TENANT_ALL_WITH_DESC = {k: k for k in TENANT_ALL}
TENANT_ALL_WITH_DESC[MANAGE_GLOSSARIES] = 'Manage glossaries'
TENANT_ALL_WITH_DESC[MANAGE_ENVIRONMENTS] = 'Manage environments'
TENANT_ALL_WITH_DESC[MANAGE_GROUPS] = 'Manage teams'
TENANT_ALL_WITH_DESC[MANAGE_ORGANIZATIONS] = 'Manage organizations'
Expand All @@ -141,7 +123,6 @@
ORGANIZATION_ALL
+ ENVIRONMENT_ALL
+ CONSUMPTION_ROLE_ALL
+ GLOSSARY_ALL
+ NETWORK_ALL
)

Expand Down
29 changes: 2 additions & 27 deletions backend/dataall/modules/catalog/api/mutations.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from dataall.base.api import gql
from dataall.modules.catalog.api.resolvers import (
create_glossary, update_node, delete_node, create_category, create_term, link_term,
request_link, approve_term_association, dismiss_term_association
create_glossary, update_node, delete_node, create_category, create_term,
approve_term_association, dismiss_term_association
)


Expand Down Expand Up @@ -62,30 +62,6 @@
type=gql.Integer,
)


linkTerm = gql.MutationField(
name='linkTerm',
resolver=link_term,
args=[
gql.Argument(name='nodeUri', type=gql.NonNullableType(gql.String)),
gql.Argument(name='targetUri', type=gql.NonNullableType(gql.String)),
gql.Argument(name='targetType', type=gql.NonNullableType(gql.String)),
],
type=gql.Ref('GlossaryTermLink'),
)

requestLink = gql.MutationField(
name='requestLink',
resolver=request_link,
args=[
gql.Argument(name='nodeUri', type=gql.NonNullableType(gql.String)),
gql.Argument(name='targetUri', type=gql.NonNullableType(gql.String)),
gql.Argument(name='targetType', type=gql.NonNullableType(gql.String)),
],
type=gql.Ref('GlossaryTermLink'),
)


createTerm = gql.MutationField(
name='createTerm',
type=gql.Ref('Term'),
Expand Down Expand Up @@ -113,7 +89,6 @@
args=[gql.Argument(name='nodeUri', type=gql.NonNullableType(gql.String))],
)


approveTermAssociation = gql.MutationField(
name='approveTermAssociation',
type=gql.Boolean,
Expand Down
59 changes: 2 additions & 57 deletions backend/dataall/modules/catalog/api/queries.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dataall.base.api import gql
from dataall.modules.catalog.api.resolvers import (
get_node, list_glossaries, search_terms, hierarchical_search, get_link, list_asset_linked_terms
get_node, list_glossaries, search_glossary,
)

getGlossary = gql.QueryField(
Expand All @@ -10,72 +10,17 @@
type=gql.Ref('Glossary'),
)


getCategory = gql.QueryField(
name='getCategory',
resolver=get_node,
args=[gql.Argument(name='nodeUri', type=gql.NonNullableType(gql.String))],
type=gql.Ref('Category'),
)


getTerm = gql.QueryField(
name='getTerm',
resolver=get_node,
args=[gql.Argument(name='nodeUri', type=gql.NonNullableType(gql.String))],
type=gql.Ref('Term'),
)

listGlossaries = gql.QueryField(
name='listGlossaries',
type=gql.Ref('GlossarySearchResult'),
args=[gql.Argument(name='filter', type=gql.Ref('GlossaryFilter'))],
resolver=list_glossaries,
)


SearchTerms = gql.QueryField(
name='searchTerms',
doc='Search glossary terms',
type=gql.Ref('TermSearchResult'),
args=[gql.Argument(name='filter', type=gql.Ref('TermFilter'))],
resolver=search_terms,
)


searchGlossaryHierarchy = gql.QueryField(
name='searchGlossaryHierarchy',
doc='Search glossary terms in the hierarchy',
type=gql.Ref('GlossaryChildrenSearchResult'),
args=[gql.Argument(name='filter', type=gql.Ref('TermFilter'))],
resolver=hierarchical_search,
)


SearchGlossary = gql.QueryField(
name='searchGlossary',
doc='Search glossary ',
type=gql.Ref('GlossaryChildrenSearchResult'),
args=[gql.Argument(name='filter', type=gql.Ref('GlossaryNodeSearchFilter'))],
resolver=search_terms,
)


getGlossaryTermLink = gql.QueryField(
name='getGlossaryTermLink',
doc='Returns a TermLink from its linkUri',
type=gql.Ref('GlossaryTermLink'),
resolver=get_link,
args=[gql.Argument(name='linkUri', type=gql.NonNullableType(gql.String))],
)

listAssetLinkedTerms = gql.QueryField(
name='listAssetLinkedTerms',
doc='return all terms associated with a data asset',
args=[
gql.Argument(name='uri', type=gql.NonNullableType(gql.String)),
gql.Argument(name='filter', type=gql.Ref('GlossaryTermTargetFilter')),
],
resolver=list_asset_linked_terms,
type=gql.Ref('TermLinkSearchResults'),
resolver=search_glossary,
)
Loading

0 comments on commit 9158691

Please sign in to comment.