-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
162 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// inspired by https://www.cedarpolicy.com/blog/cedar-for-kubernetes | ||
forbid ( | ||
principal is k8s::User, | ||
action in [k8s::Action::"list", k8s::Action::"update"], | ||
resource is k8s::Resource | ||
) when { | ||
principal in k8s::Group::"block-list" | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<span class="hljs-comment">// inspired by https://www.cedarpolicy.com/blog/cedar-for-kubernetes</span> | ||
<span class="hljs-keyword">forbid</span> <span class="hljs-punctuation">(</span> | ||
<span class="hljs-variable">principal</span> <span class="hljs-operator">is</span> <span class="hljs-title class_">k8s::User</span><span class="hljs-punctuation">,</span> | ||
<span class="hljs-variable">action</span> <span class="hljs-operator">in</span> <span class="hljs-punctuation">[</span><span class="hljs-title class_">k8s::Action</span>::<span class="hljs-string">"list"</span><span class="hljs-punctuation">,</span> <span class="hljs-title class_">k8s::Action</span>::<span class="hljs-string">"update"</span><span class="hljs-punctuation">]</span><span class="hljs-punctuation">,</span> | ||
<span class="hljs-variable">resource</span> <span class="hljs-operator">is</span> <span class="hljs-title class_">k8s::Resource</span> | ||
<span class="hljs-punctuation">)</span> <span class="hljs-keyword">when</span> <span class="hljs-punctuation">{</span> | ||
<span class="hljs-variable">principal</span> <span class="hljs-operator">in</span> <span class="hljs-title class_">k8s::Group</span>::<span class="hljs-string">"block-list"</span> | ||
<span class="hljs-punctuation">}</span><span class="hljs-punctuation">;</span> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
// you "must" be 54" tall to ride (wink) | ||
@id("54\" rule") // 54" is 4' 6" | ||
@id("54\" rule") // 54" is 4' 6" | ||
forbid (principal, action, resource) | ||
when { resource.restriction == "54\"" && principal.height < 54 }; | ||
when | ||
{ | ||
resource.restriction == "54\"" && | ||
principal.height < 54 && | ||
principal.attrSet.contains({ | ||
"key": "height", | ||
"values": ["54\"", "4' 6\""] | ||
}) | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
<span class="hljs-comment">// you "must" be 54" tall to ride (wink)</span> | ||
@id<span class="hljs-punctuation">(</span><span class="hljs-string">"54\" rule"</span><span class="hljs-punctuation">)</span> <span class="hljs-comment">// 54" is 4' 6" </span> | ||
@id<span class="hljs-punctuation">(</span><span class="hljs-string">"54\" rule"</span><span class="hljs-punctuation">)</span> <span class="hljs-comment">// 54" is 4' 6"</span> | ||
<span class="hljs-keyword">forbid</span> <span class="hljs-punctuation">(</span><span class="hljs-variable">principal</span><span class="hljs-punctuation">,</span> <span class="hljs-variable">action</span><span class="hljs-punctuation">,</span> <span class="hljs-variable">resource</span><span class="hljs-punctuation">)</span> | ||
<span class="hljs-keyword">when</span> <span class="hljs-punctuation">{</span> <span class="hljs-variable">resource</span><span class="hljs-punctuation">.</span>restriction <span class="hljs-operator">==</span> <span class="hljs-string">"54\""</span> <span class="hljs-operator">&&</span> <span class="hljs-variable">principal</span><span class="hljs-punctuation">.</span>height <span class="hljs-operator"><</span> <span class="hljs-number">54</span> <span class="hljs-punctuation">}</span><span class="hljs-punctuation">;</span> | ||
<span class="hljs-keyword">when</span> | ||
<span class="hljs-punctuation">{</span> | ||
<span class="hljs-variable">resource</span><span class="hljs-punctuation">.</span>restriction <span class="hljs-operator">==</span> <span class="hljs-string">"54\""</span> <span class="hljs-operator">&&</span> | ||
<span class="hljs-variable">principal</span><span class="hljs-punctuation">.</span>height <span class="hljs-operator"><</span> <span class="hljs-number">54</span> <span class="hljs-operator">&&</span> | ||
<span class="hljs-variable">principal</span><span class="hljs-punctuation">.</span>attrSet<span class="hljs-punctuation">.</span><span class="hljs-title function_ invoke__">contains</span><span class="hljs-punctuation">(</span><span class="hljs-punctuation">{</span> | ||
<span class="hljs-string">"key"</span>: <span class="hljs-string">"height"</span><span class="hljs-punctuation">,</span> | ||
<span class="hljs-string">"values"</span>: <span class="hljs-punctuation">[</span><span class="hljs-string">"54\""</span><span class="hljs-punctuation">,</span> <span class="hljs-string">"4' 6\""</span><span class="hljs-punctuation">]</span> | ||
<span class="hljs-punctuation">}</span><span class="hljs-punctuation">)</span> | ||
<span class="hljs-punctuation">}</span><span class="hljs-punctuation">;</span> |
This file contains 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
This file contains 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