Add example for scopes-based authorization #1303
Merged
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.
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