Skip to content

Add permissions and claims fields to User model#172

Open
ztripez wants to merge 1 commit intomusic-assistant:mainfrom
ztripez:feature/user-permissions-claims
Open

Add permissions and claims fields to User model#172
ztripez wants to merge 1 commit intomusic-assistant:mainfrom
ztripez:feature/user-permissions-claims

Conversation

@ztripez
Copy link

@ztripez ztripez commented Feb 27, 2026

Summary

  • Adds permissions: list[str] and claims: dict[str, Any] fields to the User dataclass
  • Supports the claims-based permission system being added in server PR #2892

Fields

  • permissions — holds permission scope strings (e.g. library:read, players:control). Set by the server's auth layer after JWT decode or role-based generation. Replaces the getattr(user, "_permissions") hack with a proper model attribute.
  • claims — holds arbitrary JWT claims for future OIDC provider integration and provider-contributed custom claims (e.g. spotify:premium, tidal:subscription_tier).

Backward Compatibility

Both fields use field(default_factory=...) so they default to empty. Existing serialized User objects deserialize without issue — no breaking changes.

Support the claims-based permission system (server PR #2892).

- permissions: list[str] — holds permission scope strings (e.g. 'library:read',
  'players:control') set by the auth layer after JWT decode or role-based generation.
- claims: dict[str, Any] — holds arbitrary JWT claims for future OIDC provider
  integration and provider-contributed custom claims.

Both default to empty, so existing serialized User objects deserialize without issue.
Comment on lines +42 to +43
permissions: list[str] = field(default_factory=list)
claims: dict[str, Any] = field(default_factory=dict)
Copy link
Member

Choose a reason for hiding this comment

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

Would this be something you register per user or per role or even per token ?

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