Phase 5: Authorization and Policy Enforcement - #9
Merged
pcharbon70 merged 5 commits intoMar 19, 2026
Merged
Conversation
Defined Ash policies for UI resources: - Common policy checks (user_active, user_role, screen_owner, environment) - UI.Screen policies (read, mount, create, update, destroy) - UI.Element policies (visibility, modification) - UI.Binding policies (evaluation, modification, data source access) - Cross-resource policy checks (can_read_source, can_write_source, etc.) - Tests for policy definitions
Implemented policy checking at runtime: - Mount authorization checking with redirect - Action authorization before execution - Data source read/write access checking - Policy result caching with TTL - Cache invalidation for user/resource changes - User extraction from LiveView socket - Authorization telemetry emission - Tests for runtime authorization
Created DSL extensions for common UI authorization patterns: - visible_if/2 for element visibility policies - editable_if/2 for element editability policies - accessible_if/2 for resource access policies - can_read_source/1 and can_write_source/1 for binding sources - can_access_field/2 and can_execute_action/2 helpers - Policy builders (build_visibility_policy, build_editability_policy, etc.) - all_of/1 and any_of/1 for combining policies - not_/1 for negating policies - time_policy/2 and environment_policy/1 helpers - Policy documentation helpers - Tests for policy DSL
Implemented user-friendly authorization errors: - AuthorizationError exception with resource, action, policy, reason fields - Error constructors (unauthenticated, forbidden, inactive) - User-friendly message formatting - Debug message formatting for logging - HTTP status code mapping (401, 403) - Translation support (English, Spanish, French, German) - Custom error page per resource - Login redirect detection - Recoverable error detection - Tests for error handling
Added comprehensive integration tests for Phase 5: - Mount authorization scenarios (authorized user, unauthorized redirect, unauthenticated login redirect) - Action authorization scenarios (authorized execution, unauthorized errors, policy details, partial authorization) - Data source authorization scenarios (authorized data display, unauthorized placeholder, no data leak, cross-resource) - Policy caching scenarios (cache hits, resource invalidation, role invalidation, TTL respect) - End-to-end authorization flows - Error integration scenarios - Policy integration scenarios - Common policy checks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Implements Ash policy integration for UI resource access control and action authorization.
Section 5.1 - Policy Definitions
Section 5.2 - Runtime Authorization
Section 5.3 - Policy DSL Extensions
Section 5.4 - Error Handling
Section 5.5 - Integration Tests
Test plan