Skip to content

Commit 6b6d16a

Browse files
adding theorems for 2. and 3. in additional Cedar properties #203 (#861)
Signed-off-by: Victor Nicolet <victornl@amazon.com>
1 parent e27e92c commit 6b6d16a

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

cedar-lean/Cedar/Thm/Authorization.lean

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,30 @@ theorem allowed_iff_explicitly_permitted_and_not_denied (request : Request) (ent
117117
have h₃ := allowed_only_if_explicitly_permitted request entities policies h₁
118118
exact .intro h₃ h₂
119119

120+
/--
121+
A request is denied if and only if it is explicitly denied or it is not explicitly permitted.
122+
-/
123+
theorem denied_iff_explicitly_denied_or_not_permitted (request: Request) (entities : Entities) (policies: Policies) :
124+
(IsExplicitlyForbidden request entities policies ∨ ¬ IsExplicitlyPermitted request entities policies) ↔
125+
(isAuthorized request entities policies).decision = .deny
126+
:= by
127+
apply Iff.intro
128+
· intro h
129+
cases h
130+
case inl => rw [forbid_trumps_permit]; assumption
131+
case inr => rw [default_deny]; assumption
132+
· intro h
133+
by_cases h₁ : (IsExplicitlyForbidden request entities policies)
134+
· exact Or.inl h₁
135+
· right
136+
rw [explicitly_forbidden_iff_satisfying_forbid] at h₁
137+
rw [explicitly_permitted_iff_satisfying_permit]
138+
unfold isAuthorized at h
139+
simp [h₁] at h
140+
split at h
141+
· simp at h
142+
· assumption
143+
120144
/--
121145
Order and duplicate independence: isAuthorized produces the same result
122146
regardless of policy order or duplicates.
@@ -131,4 +155,31 @@ theorem order_and_dup_independent (request : Request) (entities : Entities) (pol
131155
have he := errorPolicies_order_and_dup_independent request entities h
132156
simp [isAuthorized, hf, hp, he]
133157

158+
/--
159+
Adding a permit policy won't change an Allow decision.
160+
-/
161+
theorem unchanged_allow_when_add_permit (request: Request) (entities: Entities) (policies: Policies) (policy₂: Policy) :
162+
policy₂.effect = .permit →
163+
(isAuthorized request entities policies).decision = .allow →
164+
(isAuthorized request entities (policy₂ :: policies)).decision = .allow
165+
:= by
166+
intro h₁ h₂
167+
rw [← allowed_iff_explicitly_permitted_and_not_denied] at *
168+
unfold IsExplicitlyPermitted IsExplicitlyForbidden HasSatisfiedEffect at *
169+
simp [h₂, h₁]
170+
171+
/--
172+
Adding a forbid policy won't change a Deny decision.
173+
-/
174+
theorem unchanged_deny_when_add_forbid (request : Request) (entities: Entities) (policies: Policies) (policy₂: Policy) :
175+
policy₂.effect = .forbid →
176+
(isAuthorized request entities policies).decision = .deny →
177+
(isAuthorized request entities (policy₂ :: policies)).decision = .deny
178+
:= by
179+
intro h₁ h₂
180+
rw [← denied_iff_explicitly_denied_or_not_permitted] at *
181+
unfold IsExplicitlyPermitted IsExplicitlyForbidden HasSatisfiedEffect at *
182+
simp only [not_exists, not_and, Bool.not_eq_true] at h₂
183+
simp only [List.mem_cons, exists_eq_or_imp, h₁, true_and, reduceCtorEq, false_and, false_or, not_exists, not_and, Bool.not_eq_true]
184+
exact h₂.elim (fun hb => Or.inl (Or.inr hb)) Or.inr
134185
end Cedar.Thm

0 commit comments

Comments
 (0)