Skip to content
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

Add example for scopes-based authorization #1303

Merged
merged 1 commit into from Sep 4, 2023
Merged

Conversation

bkoelman
Copy link
Member

@bkoelman bkoelman commented Sep 3, 2023

This PR adds an example for using scopes-based authorization in a generic way.

For simplicity in this sample, accessing relationships requires access to both the left and right sides of the relationship. An alternative approach could be to define relationship-specific scopes, such as read:relationship:movies-genre. Another limitation of this sample is that it only supports access checks on resource types. For example, consider a resource type TodoItem that contains an owner (type Person) and an assignee (type Person). Now it's not possible to allow fetching/updating the assignee while preventing to fetch/update the owner.

Just so you know, this is only a sample. Personally, I'd never use such fine-grained scopes because it quickly becomes an administrative nightmare. What I would do is define scopes around functional areas (like the GitHub API does), and then directly annotate controller action methods with them.

Closes #1300.

QUALITY CHECKLIST

@bkoelman bkoelman mentioned this pull request Sep 3, 2023
@bkoelman bkoelman force-pushed the auth-scopes-example branch 3 times, most recently from 3333817 to c1f4742 Compare September 3, 2023 22:08
@codecov
Copy link

codecov bot commented Sep 3, 2023

Codecov Report

Merging #1303 (968e35b) into master (396123c) will not change coverage.
The diff coverage is n/a.

❗ Current head 968e35b differs from pull request most recent head 9691a04. Consider uploading reports for the commit 9691a04 to get more accurate results

@@           Coverage Diff           @@
##           master    #1303   +/-   ##
=======================================
  Coverage   96.82%   96.82%           
=======================================
  Files          21       21           
  Lines         598      598           
=======================================
  Hits          579      579           
  Misses         19       19           

@bkoelman bkoelman marked this pull request as ready for review September 4, 2023 00:14
@bkoelman bkoelman merged commit f38a812 into master Sep 4, 2023
1 check passed
@bkoelman bkoelman deleted the auth-scopes-example branch September 4, 2023 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Authorization example
1 participant