Skip to content

docs: Document scope design and AND semantics (#3267)#601

Open
abdulawalarif wants to merge 3 commits into
serverpod:mainfrom
abdulawalarif:feature/3267-document-scopes
Open

docs: Document scope design and AND semantics (#3267)#601
abdulawalarif wants to merge 3 commits into
serverpod:mainfrom
abdulawalarif:feature/3267-document-scopes

Conversation

@abdulawalarif

Copy link
Copy Markdown

Summary

Addresses serverpod/serverpod#3267.

Expands the Authorization on endpoints section in The basics to explain how Serverpod scopes are intended to be used and why multiple scopes are combined with AND logic.

Changes in docs/06-concepts/11-authentication/02-basics.md:

  • Clarifies that scopes are independent capabilities with no inheritance (Scope.admin does not imply other scopes).
  • Documents the difference between requireLogin and requiredScopes, including that non-empty requiredScopes always requires authentication.
  • Adds a How scopes combine subsection with a user-management example (analytics vs edit endpoints) to motivate AND semantics.
  • Expands Managing scopes with token snapshot behavior and guidance on revoking tokens for active sessions and streams.
  • Updates Custom scopes to tie custom scope constants back to AND evaluation and endpoint inheritance.
  • Adds HTTP responses documenting 401 (unauthenticated) vs 403 (insufficient scopes).

Also fixes a missing newline before the User authentication heading.

Test plan

@Swiftaxe Swiftaxe left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for a good PR on this @abdulawalarif!

I added some comments, mostly nits about improving clarity and simplification.

Comment thread docs/06-concepts/11-authentication/02-basics.md Outdated
Comment thread docs/06-concepts/11-authentication/02-basics.md Outdated
Comment thread docs/06-concepts/11-authentication/02-basics.md Outdated
Comment thread docs/06-concepts/11-authentication/02-basics.md Outdated
Comment thread docs/06-concepts/11-authentication/02-basics.md Outdated
@override
Set<Scope> get requiredScopes => {
Scope.admin,
const Scope('userWrite'),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Custom scopes are introduced in this code example, and below on line 157, before the section "Custom Scopes" which introduces it to the reader.

  2. These two examples show creating scopes using a magic string, while the Custom Scopes section teaches the reader to define constants in a class.

Please change the order so Custom Scopes gets introduced first and consider the constant vs magic string examples.

abdulawalarif and others added 2 commits June 16, 2026 13:50
Reorder custom scope examples, simplify wording, and remove em dashes per style guide.

Co-authored-by: Cursor <cursoragent@cursor.com>
@abdulawalarif

Copy link
Copy Markdown
Author

@Swiftaxe All feedback addressed: em dashes removed, wording simplified, Custom scopes moved before How scopes combine with constant-based examples.

@Swiftaxe Swiftaxe left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @abdulawalarif! Looks neat!

@abdulawalarif

Copy link
Copy Markdown
Author

Hey, Alexander!
Just checking in, do you need anything else from me, or will you merge it soon?
@Swiftaxe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants