-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CRUD, added scopes, updated compiler
- Loading branch information
Showing
13 changed files
with
401 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
39 changes: 39 additions & 0 deletions
39
installers/auth.example.org/operations/petstore/delete-pet-by-id.edn
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,39 @@ | ||
{:install | ||
{:juxt.site/subject-uri "https://auth.example.org/_site/subjects/system" | ||
:juxt.site/operation-uri "https://auth.example.org/_site/operations/create-operation" | ||
:juxt.site/input | ||
{:xt/id "{{$id}}" | ||
:juxt.site/do-operation-tx-fn "https://auth.example.org/_site/do-operation" | ||
|
||
:juxt.site/prepare | ||
{:juxt.site.sci/program | ||
#juxt.pprint | ||
{:docs (concat (map :xt/id (:juxt.site/current-representations *ctx*)) | ||
[(:xt/id (:juxt.site/resource *ctx*))])}} | ||
|
||
:juxt.site/transact | ||
{:juxt.site.sci/program | ||
#juxt.pprint | ||
(for [doc (:docs *prepare*)] | ||
[:xtdb.api/delete doc])} | ||
|
||
:juxt.site/scope | ||
#{"https://auth.example.org/scopes/petstore/write"} | ||
|
||
:juxt.site/rules | ||
[ | ||
[(allowed? subject operation resource permission) | ||
[subject :juxt.site/user user] | ||
[permission :juxt.site/role role] | ||
[role :juxt.site/type "https://meta.juxt.site/types/role"] | ||
[role-assignment :juxt.site/type "https://meta.juxt.site/types/role-assignment"] | ||
[role-assignment :juxt.site/role role] | ||
[role-assignment :juxt.site/user user]] | ||
|
||
[(allowed? subject operation resource permission) | ||
[subject :juxt.site/application app] | ||
[permission :juxt.site/role role] | ||
[role :juxt.site/type "https://meta.juxt.site/types/role"] | ||
[role-assignment :juxt.site/type "https://meta.juxt.site/types/role-assignment"] | ||
[role-assignment :juxt.site/role role] | ||
[role-assignment :juxt.site/application app]]]}}} |
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
51 changes: 51 additions & 0 deletions
51
installers/auth.example.org/operations/petstore/find-by-tags.edn
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,51 @@ | ||
{:install | ||
{:juxt.site/subject-uri "https://auth.example.org/_site/subjects/system" | ||
:juxt.site/operation-uri "https://auth.example.org/_site/operations/create-operation" | ||
:juxt.site/input | ||
{:xt/id "{{$id}}" | ||
:juxt.site/do-operation-tx-fn "https://auth.example.org/_site/do-operation" | ||
:juxt.site/state | ||
{:juxt.site.sci/program | ||
#juxt.pprint | ||
(let [query-params (:ring.request/query *ctx*) | ||
tags | ||
(if query-params | ||
(-> query-params ring.util.codec/form-decode (get "tags")) | ||
[])] | ||
(->> (xt/q | ||
'{:find [(pull e [*])] | ||
:where [[e :juxt.site/type "https://data.example.org/types/pet"] | ||
[e :tags tags] | ||
[tags :name tag]] | ||
:in [[tag ...]]} | ||
["tag1" "tag3"]) | ||
(map first) | ||
(map (fn [dog] | ||
(reduce-kv | ||
(fn [acc k v] | ||
(if (not= "juxt.site" (namespace k)) | ||
(assoc acc k v) | ||
acc)) | ||
{} | ||
dog))) | ||
(sort-by :xt/id) | ||
(vec) | ||
)) | ||
} | ||
:juxt.site/rules | ||
[ | ||
[(allowed? subject operation resource permission) | ||
[subject :juxt.site/user user] | ||
[permission :juxt.site/role role] | ||
[role :juxt.site/type "https://meta.juxt.site/types/role"] | ||
[role-assignment :juxt.site/type "https://meta.juxt.site/types/role-assignment"] | ||
[role-assignment :juxt.site/role role] | ||
[role-assignment :juxt.site/user user]] | ||
|
||
[(allowed? subject operation resource permission) | ||
[subject :juxt.site/application app] | ||
[permission :juxt.site/role role] | ||
[role :juxt.site/type "https://meta.juxt.site/types/role"] | ||
[role-assignment :juxt.site/type "https://meta.juxt.site/types/role-assignment"] | ||
[role-assignment :juxt.site/role role] | ||
[role-assignment :juxt.site/application app]]]}}} |
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
59 changes: 59 additions & 0 deletions
59
installers/auth.example.org/operations/petstore/update-pet-by-id.edn
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,59 @@ | ||
{:install | ||
{:juxt.site/subject-uri "https://auth.example.org/_site/subjects/system" | ||
:juxt.site/operation-uri "https://auth.example.org/_site/operations/create-operation" | ||
:juxt.site/input | ||
{:xt/id "{{$id}}" | ||
:juxt.site/do-operation-tx-fn "https://auth.example.org/_site/do-operation" | ||
|
||
:juxt.site/prepare | ||
{:juxt.site.sci/program | ||
#juxt.pprint | ||
(let [content-type (-> *ctx* | ||
:juxt.site/received-representation | ||
:juxt.http/content-type) | ||
body (-> *ctx* | ||
:juxt.site/received-representation | ||
:juxt.http/body) | ||
pet-update (case content-type | ||
"application/json" | ||
(some-> | ||
body | ||
(String.) | ||
jsonista.core/read-value-with-keywords) | ||
"application/x-www-form-urlencoded" | ||
(some-> | ||
body | ||
(String.) | ||
ring.util.codec/form-decode | ||
clojure.walk/keywordize-keys))] | ||
(logf (str pet-update)) | ||
{:doc | ||
(into (:juxt.site/resource *ctx*) | ||
pet-update)})} | ||
|
||
:juxt.site/transact | ||
{:juxt.site.sci/program | ||
#juxt.pprint | ||
[[:xtdb.api/put (:doc *prepare*)]]} | ||
|
||
:juxt.site/scope | ||
#{"https://auth.example.org/scopes/petstore/read" | ||
"https://auth.example.org/scopes/petstore/write"} | ||
|
||
:juxt.site/rules | ||
[ | ||
[(allowed? subject operation resource permission) | ||
[subject :juxt.site/user user] | ||
[permission :juxt.site/role role] | ||
[role :juxt.site/type "https://meta.juxt.site/types/role"] | ||
[role-assignment :juxt.site/type "https://meta.juxt.site/types/role-assignment"] | ||
[role-assignment :juxt.site/role role] | ||
[role-assignment :juxt.site/user user]] | ||
|
||
[(allowed? subject operation resource permission) | ||
[subject :juxt.site/application app] | ||
[permission :juxt.site/role role] | ||
[role :juxt.site/type "https://meta.juxt.site/types/role"] | ||
[role-assignment :juxt.site/type "https://meta.juxt.site/types/role-assignment"] | ||
[role-assignment :juxt.site/role role] | ||
[role-assignment :juxt.site/application app]]]}}} |
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,9 @@ | ||
{:deps | ||
["https://auth.example.org/operations/oauth/register-scope" | ||
"https://auth.example.org/permissions/system/oauth/register-scope"] | ||
:install | ||
{:juxt.site/subject-uri "https://auth.example.org/_site/subjects/system" | ||
:juxt.site/operation-uri "https://auth.example.org/operations/oauth/register-scope" | ||
:juxt.site/input | ||
{:xt/id "{{$id}}" | ||
:juxt.site/description "Read stuff"}}} |
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,9 @@ | ||
{:deps | ||
["https://auth.example.org/operations/oauth/register-scope" | ||
"https://auth.example.org/permissions/system/oauth/register-scope"] | ||
:install | ||
{:juxt.site/subject-uri "https://auth.example.org/_site/subjects/system" | ||
:juxt.site/operation-uri "https://auth.example.org/operations/oauth/register-scope" | ||
:juxt.site/input | ||
{:xt/id "{{$id}}" | ||
:juxt.site/description "Write stuff"}}} |
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
Oops, something went wrong.