Skip to content

Commit

Permalink
Add decicated oauth scopes for cedar metadta templates & records
Browse files Browse the repository at this point in the history
  • Loading branch information
cslzchen committed Jan 22, 2024
1 parent 5da6cd4 commit 923bea8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
8 changes: 4 additions & 4 deletions api/cedar_metadata_records/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class CedarMetadataRecordList(JSONAPIBaseView, ListCreateAPIView, ListFilterMixi
drf_permissions.IsAuthenticatedOrReadOnly,
base_permissions.TokenHasScope,
)
required_read_scopes = [CoreScopes.ALWAYS_PUBLIC]
required_write_scopes = [CoreScopes.NODE_BASE_WRITE, CoreScopes.NODE_FILE_WRITE, CoreScopes.NODE_REGISTRATIONS_WRITE]
required_read_scopes = [CoreScopes.CEDAR_METADATA_RECORD_READ]
required_write_scopes = [CoreScopes.CEDAR_METADATA_RECORD_WRITE]

serializer_class = CedarMetadataRecordsCreateSerializer
parser_classes = (JSONAPIMultipleRelationshipsParser, JSONAPIMultipleRelationshipsParserForRegularJSON, )
Expand All @@ -56,8 +56,8 @@ class CedarMetadataRecordDetail(JSONAPIBaseView, RetrieveUpdateDestroyAPIView):
drf_permissions.IsAuthenticatedOrReadOnly,
base_permissions.TokenHasScope,
)
required_read_scopes = [CoreScopes.NODE_BASE_READ, CoreScopes.NODE_FILE_READ, CoreScopes.NODE_REGISTRATIONS_READ]
required_write_scopes = [CoreScopes.NODE_BASE_WRITE, CoreScopes.NODE_FILE_WRITE, CoreScopes.NODE_REGISTRATIONS_WRITE]
required_read_scopes = [CoreScopes.CEDAR_METADATA_RECORD_READ]
required_write_scopes = [CoreScopes.CEDAR_METADATA_RECORD_WRITE]

serializer_class = CedarMetadataRecordsSerializer

Expand Down
2 changes: 1 addition & 1 deletion api/cedar_metadata_templates/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class CedarMetadataTemplateList(JSONAPIBaseView, generics.ListAPIView, ListFilte
drf_permissions.IsAuthenticatedOrReadOnly,
base_permissions.TokenHasScope,
)
required_read_scopes = [CoreScopes.ALWAYS_PUBLIC]
required_read_scopes = [CoreScopes.CEDAR_METADATA_RECORD_READ]
required_write_scopes = [CoreScopes.NULL]

serializer_class = CedarMetadataTemplateSerializer
Expand Down
5 changes: 5 additions & 0 deletions framework/auth/oauth_scopes.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ class CoreScopes(object):

WAFFLE_READ = 'waffle_read'

CEDAR_METADATA_RECORD_READ = 'cedar_metadata_record_read'
CEDAR_METADATA_RECORD_WRITE = 'cedar_metadata_record_write'

NULL = 'null'

# NOTE: Use with extreme caution.
Expand Down Expand Up @@ -316,6 +319,7 @@ class ComposedScopes(object):
+ PREPRINT_ALL_READ\
+ GROUP_READ\
+ (
CoreScopes.CEDAR_METADATA_RECORD_READ,
CoreScopes.MEETINGS_READ,
CoreScopes.INSTITUTION_READ,
CoreScopes.SEARCH,
Expand All @@ -336,6 +340,7 @@ class ComposedScopes(object):
+ PREPRINT_ALL_WRITE\
+ GROUP_WRITE\
+ (
CoreScopes.CEDAR_METADATA_RECORD_WRITE,
CoreScopes.WRITE_COLLECTION_SUBMISSION_ACTION,
CoreScopes.WRITE_COLLECTION_SUBMISSION
)
Expand Down

0 comments on commit 923bea8

Please sign in to comment.