Skip to content

Auto-populate scope["user"] with BfabricUser in BfabricAuthMiddleware#483

Merged
leoschwarz merged 3 commits intomainfrom
worktree-issue-427
Apr 15, 2026
Merged

Auto-populate scope["user"] with BfabricUser in BfabricAuthMiddleware#483
leoschwarz merged 3 commits intomainfrom
worktree-issue-427

Conversation

@leoschwarz
Copy link
Copy Markdown
Member

  • Add BfabricUser class (Starlette BaseUser protocol) wrapping SessionData
  • Middleware now sets scope["user"] on authenticated requests, so request.user works out of the box
  • Eliminates need for boilerplate CopyUserMiddleware

Closes #427

Add BfabricUser class implementing Starlette's BaseUser protocol that
wraps SessionData and provides is_authenticated, display_name, identity,
session_data, and get_bfabric_client(). The middleware now automatically
sets scope["user"] on authenticated requests, eliminating the need for
boilerplate CopyUserMiddleware in apps.

Closes #427
- Remove session_data property to avoid exposing raw password
- Add login and instance properties for safe access
- Change identity format from "{instance}:{login}" to "{login}@{instance}"
- Add unit tests for BfabricUser
- Update BDD tests to match new API
@leoschwarz leoschwarz merged commit e4ec8f1 into main Apr 15, 2026
4 checks passed
@leoschwarz leoschwarz deleted the worktree-issue-427 branch April 15, 2026 13:09
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.

Mechanism to write the auth into the user scope automatically or easily

1 participant