Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data auth sep 2 #40

Merged
merged 8 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion installers/auth.example.org/applications/insite.edn
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
:juxt.site/resource-server "https://data.example.org"
:juxt.site/redirect-uris ["https://surveyor.apps.com/oauth-redirect.html"]
:juxt.site/scope #{"https://auth.example.org/scopes/system/read"
"https://auth.example.org/scopes/system/self-identification"}}}}
"https://data.example.org/_site/scopes/system/self-identification"}}}}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
{:optional true}
[:maybe
[:set
[:re "https://auth.example.org/scopes/.+?(,https://auth.example.org/scopes/.+?)*"]]]]]
[:re "(https://auth.example.org/scopes/.+?(,https://auth.example.org/scopes/.+?)*|https://data.example.org/_site/scopes/.+?(,https://data.example.org/_site/scopes/.+?)*)"]]]]]

;; TODO: Check that scope actually exists

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{:deps
["https://auth.example.org/operations/whoami"]
["https://data.example.org/_site/operations/whoami"]
:install
{:juxt.site/subject-uri "https://auth.example.org/_site/subjects/system"
:juxt.site/operation-uri "https://auth.example.org/_site/operations/grant-permission"
:juxt.site/input
{:xt/id "{{$id}}"
:juxt.site/operation-uri "https://auth.example.org/operations/whoami"
:juxt.site/operation-uri "https://data.example.org/_site/operations/whoami"
:juxt.site/user "https://data.example.org/_site/users/{{username}}"}}}
131 changes: 68 additions & 63 deletions installers/bundles.edn
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,10 @@
:juxt.site/description "An API to discover and install OpenAPIs"
:juxt.site/installers
[ ;; Openapis
{:juxt.site/base-uri "https://auth.example.org"
:juxt.site/installer-path "/operations/get-openapis"}
{:juxt.site/base-uri "https://auth.example.org"
:juxt.site/installer-path "/operations/post-openapi"}
{:juxt.site/base-uri "https://data.example.org"
:juxt.site/installer-path "/_site/operations/get-openapis"}
{:juxt.site/base-uri "https://data.example.org"
:juxt.site/installer-path "/_site/operations/post-openapi"}

;; Endpoints
{:juxt.site/base-uri "https://data.example.org"
Expand All @@ -225,30 +225,29 @@
:juxt.site/installer-path "/_site/openapis.edn"}

;; Permissions
{:juxt.site/base-uri "https://auth.example.org"
:juxt.site/installer-path "/permissions/by-role/{{role}}/{{operation}}"
{:juxt.site/base-uri "https://data.example.org"
:juxt.site/installer-path "/_site/permissions/by-role/{{role}}/{{operation}}"
:juxt.site/parameters {"role" "SiteAdmin"
"operation" "put-openapi-document"}}

;; Used by System API
{:juxt.site/base-uri "https://auth.example.org"
:juxt.site/installer-path "/operations/get-openapi-document"}
{:juxt.site/base-uri "https://auth.example.org"
:juxt.site/installer-path "/permissions/get-openapi-document"}

{:juxt.site/base-uri "https://auth.example.org"
:juxt.site/installer-path "/operations/put-openapi-document"}
{:juxt.site/base-uri "https://data.example.org"
:juxt.site/installer-path "/_site/operations/get-openapi-document"}
{:juxt.site/base-uri "https://data.example.org"
:juxt.site/installer-path "/_site/permissions/get-openapi-document"}

{:juxt.site/base-uri "https://auth.example.org"
:juxt.site/installer-path "/permissions/system/put-openapi-document"}
{:juxt.site/base-uri "https://data.example.org"
:juxt.site/installer-path "/_site/operations/put-openapi-document"}
{:juxt.site/base-uri "https://data.example.org"
:juxt.site/installer-path "/_site/permissions/put-openapi-document"}

{:juxt.site/base-uri "https://auth.example.org"
:juxt.site/installer-path "/permissions/by-role/{{role}}/{{operation}}"
{:juxt.site/base-uri "https://data.example.org"
:juxt.site/installer-path "/_site/permissions/by-role/{{role}}/{{operation}}"
:juxt.site/parameters {"role" "SiteAdmin"
"operation" "post-openapi"}}

{:juxt.site/base-uri "https://auth.example.org"
:juxt.site/installer-path "/permissions/by-role/{{role}}/{{operation}}"
{:juxt.site/base-uri "https://data.example.org"
:juxt.site/installer-path "/_site/permissions/by-role/{{role}}/{{operation}}"
:juxt.site/parameters {"role" "SiteAdmin"
"operation" "get-openapis"}}]}

Expand All @@ -270,13 +269,11 @@
{:juxt.site/title "Users API"
:juxt.site/description "Users API"
:juxt.site/installers
[
;; HTML
[ ;; HTML
{:juxt.site/base-uri "https://data.example.org"
:juxt.site/installer-path "/_site/templates/document-base.html"}
{:juxt.site/base-uri "https://data.example.org"
:juxt.site/installer-path "/_site/templates/fetch-html-content.html"}

;; Endpoints
{:juxt.site/base-uri "https://data.example.org"
:juxt.site/installer-path "/_site/users"}
Expand All @@ -287,26 +284,27 @@
{:juxt.site/base-uri "https://data.example.org"
:juxt.site/installer-path "/_site/users.html"}
{:juxt.site/base-uri "https://data.example.org"
:juxt.site/installer-path "/_site/users/{username}"}

;; Role assignments
;; SiteAdmin role
{:juxt.site/base-uri "https://auth.example.org"
:juxt.site/installer-path "/permissions/by-role/{{role}}/{{operation}}"
:juxt.site/parameters {"role" "SiteAdmin"
"operation" "get-users"}}
{:juxt.site/base-uri "https://auth.example.org"
:juxt.site/installer-path "/permissions/by-role/{{role}}/{{operation}}"
:juxt.site/parameters {"role" "SiteAdmin"
"operation" "get-user"}}
:juxt.site/installer-path "/_site/users/{username}"}]}

"juxt/site/users-api-permissions"
{:juxt.site/title "Users API Permissions"
:juxt.site/description "Users API Permissions"
:juxt.site/installers
[
{:juxt.site/base-uri "https://auth.example.org"
:juxt.site/installer-path "/permissions/by-role/{{role}}/{{operation}}"
:juxt.site/parameters {"role" "SiteAdmin"
"operation" "put-user"}}

:juxt.site/installer-path "/permissions/by-role/{{role}}/{{operation}}"
:juxt.site/parameters {"role" "SiteAdmin"
"operation" "get-users"}}
{:juxt.site/base-uri "https://auth.example.org"
:juxt.site/installer-path "/permissions/by-role/{{role}}/{{operation}}"
:juxt.site/parameters {"role" "SiteAdmin"
"operation" "get-user"}}
{:juxt.site/base-uri "https://auth.example.org"
:juxt.site/installer-path "/permissions/by-role/{{role}}/{{operation}}"
:juxt.site/parameters {"role" "SiteAdmin"
"operation" "put-user"}}
;; SiteBootstrap role
;; It is necessary for bootstrapping to be able to create a user

;; We could use our permission to install-bundle but the user of
;; the users API is more convenient for specifying ad-hoc
;; parameters.
Expand Down Expand Up @@ -338,16 +336,23 @@
{:juxt.site/base-uri "https://auth.example.org"
:juxt.site/installer-path "/operations/oauth/get-applications"}

;; SiteAdmin
{:juxt.site/base-uri "https://auth.example.org"
:juxt.site/installer-path "/permissions/by-role/{{role}}/{{operation}}"
:juxt.site/parameters {"role" "SiteAdmin" "operation" "oauth/get-applications"}}
]}

"juxt/site/applications-endpoint"
{:juxt.site/title "Apps API endpoint"
:juxt.site/description "Applications API endpoint"
:juxt.site/installers
[
;; Endpoints
{:juxt.site/base-uri "https://data.example.org"
:juxt.site/installer-path "/_site/applications"}
{:juxt.site/base-uri "https://data.example.org"
:juxt.site/installer-path "/_site/applications.json"}

;; SiteAdmin
{:juxt.site/base-uri "https://auth.example.org"
:juxt.site/installer-path "/permissions/by-role/{{role}}/{{operation}}"
:juxt.site/parameters {"role" "SiteAdmin" "operation" "oauth/get-applications"}}

]}

Expand All @@ -357,10 +362,10 @@
:juxt.site/installers
[
;; Operations
{:juxt.site/base-uri "https://auth.example.org"
:juxt.site/installer-path "/operations/get-operations"}
{:juxt.site/base-uri "https://auth.example.org"
:juxt.site/installer-path "/permissions/get-operations"}
{:juxt.site/base-uri "https://data.example.org"
:juxt.site/installer-path "/_site/operations/get-operations"}
{:juxt.site/base-uri "https://data.example.org"
:juxt.site/installer-path "/_site/permissions/get-operations"}

;; Endpoints
{:juxt.site/base-uri "https://data.example.org"
Expand All @@ -376,26 +381,26 @@
{:juxt.site/title "Whoami API"
:juxt.site/description "Whoami API"
:juxt.site/installers
[{:juxt.site/base-uri "https://auth.example.org"
:juxt.site/installer-path "/scopes/system/self-identification"}
{:juxt.site/base-uri "https://auth.example.org"
:juxt.site/installer-path "/operations/whoami"}
[{:juxt.site/base-uri "https://data.example.org"
:juxt.site/installer-path "/_site/scopes/system/self-identification"}
{:juxt.site/base-uri "https://data.example.org"
:juxt.site/installer-path "/_site/operations/whoami"}
{:juxt.site/base-uri "https://data.example.org"
:juxt.site/installer-path "/_site/whoami"}
{:juxt.site/base-uri "https://data.example.org"
:juxt.site/installer-path "/_site/whoami.json"}
{:juxt.site/base-uri "https://data.example.org"
:juxt.site/installer-path "/_site/whoami.edn"}
{:juxt.site/base-uri "https://auth.example.org"
:juxt.site/installer-path "/operations/get-access-token"}
{:juxt.site/base-uri "https://auth.example.org"
:juxt.site/installer-path "/permissions/get-access-token"}
{:juxt.site/base-uri "https://data.example.org"
:juxt.site/installer-path "/_site/operations/get-access-token"}
{:juxt.site/base-uri "https://data.example.org"
:juxt.site/installer-path "/_site/permissions/get-access-token"}
{:juxt.site/base-uri "https://data.example.org"
:juxt.site/installer-path "/_site/access-token"}
{:juxt.site/base-uri "https://data.example.org"
:juxt.site/installer-path "/_site/access-token.txt"}
{:juxt.site/base-uri "https://auth.example.org"
:juxt.site/installer-path "/permissions/whoami"}]}
{:juxt.site/base-uri "https://data.example.org"
:juxt.site/installer-path "/_site/permissions/whoami"}]}

;; TODO: Shouldn't SystemAPI be broken up into individual endpoints?
#_"juxt/site/system-api"
Expand Down Expand Up @@ -816,8 +821,8 @@
"juxt/site/browser-client"
{:juxt.site/title "Browser client"
:juxt.site/installers
[{:juxt.site/base-uri "https://auth.example.org"
:juxt.site/installer-path "/applications/browser"}
[{:juxt.site/base-uri "https://data.example.org"
:juxt.site/installer-path "/_site/applications/browser"}
{:juxt.site/base-uri "https://data.example.org"
:juxt.site/installer-path "/_site/browser/browser-oauth-redirect.html"}]}

Expand Down Expand Up @@ -1096,8 +1101,8 @@

"juxt/site/testing/basic-auth-protected-resource"
{:juxt.site/installers
[{:juxt.site/base-uri "https://auth.example.org" :juxt.site/installer-path "/operations/testing/basic-auth-protected-resource-operation"}
{:juxt.site/base-uri "https://auth.example.org" :juxt.site/installer-path "/permissions/testing/basic-auth-protected-resource-operation"}
[{:juxt.site/base-uri "https://data.example.org" :juxt.site/installer-path "/_site/testing/operations/basic-auth-protected-resource-operation"}
{:juxt.site/base-uri "https://data.example.org" :juxt.site/installer-path "/_site/testing/permissions/basic-auth-protected-resource-operation"}
{:juxt.site/base-uri "https://data.example.org" :juxt.site/installer-path "/_site/testing/basic-auth-protected-resource"}
{:juxt.site/base-uri "https://data.example.org" :juxt.site/installer-path "/_site/testing/client-credentials-protected-resource"}
]}
Expand All @@ -1110,7 +1115,7 @@
"juxt/site/testing/test-admin-client"
{:juxt.site/description "A client, with the SiteAdmin role, for use in tests"
:juxt.site/installers
[{:juxt.site/base-uri "https://auth.example.test" :juxt.site/installer-path "/applications/test-admin-client"}
[{:juxt.site/base-uri "https://data.example.test" :juxt.site/installer-path "/_site/applications/test-admin-client"}
{:juxt.site/base-uri "https://data.example.org"
:juxt.site/installer-path "/_site/application-role-assignments/{{clientid}}-{{rolename}}"
:juxt.site/parameters {"clientid" "test-admin-client" "rolename" "SiteAdmin"}}]}}
4 changes: 2 additions & 2 deletions installers/data.example.org/_site/access-token.edn
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{:deps
["https://auth.example.org/operations/get-access-token"
["https://data.example.org/_site/operations/get-access-token"
"https://auth.example.org/protection-spaces/bearer"]
:install
{:juxt.site/subject-uri "https://auth.example.org/_site/subjects/system"
Expand All @@ -11,7 +11,7 @@

:juxt.site/methods
{:get
{:juxt.site/operation-uri "https://auth.example.org/operations/get-access-token"
{:juxt.site/operation-uri "https://data.example.org/_site/operations/get-access-token"
:openapi.v3/metadata {"tags" ["Introspection"]
"summary" "Show the access token as text so it can be saved"}}}

Expand Down
4 changes: 2 additions & 2 deletions installers/data.example.org/_site/access-token.txt.edn
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{:deps
["https://data.example.org/_site/access-token"
"https://auth.example.org/operations/get-access-token"]
"https://data.example.org/_site/operations/get-access-token"]
:install
{:juxt.site/subject-uri "https://auth.example.org/_site/subjects/system"
:juxt.site/operation-uri "https://auth.example.org/operations/put-resource"
:juxt.site/input
{:xt/id "{{$id}}"
:juxt.site/methods
{:get {:juxt.site/operation-uri "https://auth.example.org/operations/get-access-token"}}
{:get {:juxt.site/operation-uri "https://data.example.org/_site/operations/get-access-token"}}
:juxt.site/variant-of "https://data.example.org/_site/access-token"
:juxt.http/content-type "text/plain;charset=us-ascii"

Expand Down
12 changes: 6 additions & 6 deletions installers/data.example.org/_site/openapi.json.edn
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{:deps
["https://auth.example.org/operations/put-openapi-document"]
["https://data.example.org/_site/operations/put-openapi-document"]
:install
{:juxt.site/subject-uri "https://auth.example.org/_site/subjects/system"
:juxt.site/operation-uri "https://auth.example.org/operations/put-openapi-document"
:juxt.site/operation-uri "https://data.example.org/_site/operations/put-openapi-document"
:juxt.site/input
{:xt/id "{{$id}}"

Expand Down Expand Up @@ -41,27 +41,27 @@ Some useful links:
{"authorizationUrl" "https://auth.example.org/oauth/authorize"
"scopes"
{"https://auth.example.org/scopes/system/read" "Read system info"
"https://auth.example.org/scopes/system/self-identification" "Self identification"
"https://data.example.org/_site/scopes/system/self-identification" "Self identification"
"https://auth.example.org/scopes/system/write" "Administer system"}
"tokenUrl" "https://auth.example.org/oauth/token"}

"clientCredentials"
{"scopes"
{"https://auth.example.org/scopes/system/read" "Read system info"
"https://auth.example.org/scopes/system/self-identification" "Self identification"
"https://data.example.org/_site/scopes/system/self-identification" "Self identification"
"https://auth.example.org/scopes/system/write" "Administer system"}
"tokenUrl" "https://auth.example.org/oauth/token"}

"implicit"
{"authorizationUrl" "https://auth.example.org/oauth/authorize"
"scopes"
{"https://auth.example.org/scopes/system/read" "Read system info"
"https://auth.example.org/scopes/system/self-identification" "Self identification"
"https://data.example.org/_site/scopes/system/self-identification" "Self identification"
"https://auth.example.org/scopes/system/write" "Administer system"}}

"password"
{"scopes"
{"https://auth.example.org/scopes/system/read" "Read system info"
"https://auth.example.org/scopes/system/self-identification" "Self identification"
"https://data.example.org/_site/scopes/system/self-identification" "Self identification"
"https://auth.example.org/scopes/system/write" "Administer system"}
"tokenUrl" "https://auth.example.org/oauth/token"}}}}}}}}}
8 changes: 4 additions & 4 deletions installers/data.example.org/_site/openapis.edn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{:deps
["https://auth.example.org/operations/get-openapis"
"https://auth.example.org/operations/post-openapi"
["https://data.example.org/_site/operations/get-openapis"
"https://data.example.org/_site/operations/post-openapi"
"https://auth.example.org/protection-spaces/bearer"]
:install
{:juxt.site/subject-uri "https://auth.example.org/_site/subjects/system"
Expand All @@ -12,14 +12,14 @@

:juxt.site/methods
{:get
{:juxt.site/operation-uri "https://auth.example.org/operations/get-openapis"
{:juxt.site/operation-uri "https://data.example.org/_site/operations/get-openapis"
:openapi.v3/metadata {"tags" ["OpenAPIs"]
"summary" "Get OpenAPIs"}}

:post
{:juxt.site/operation-uri
;; TODO: Rename to register-users
"https://auth.example.org/operations/post-openapi"
"https://data.example.org/_site/operations/post-openapi"
:openapi.v3/metadata
{"tags" ["OpenAPIs"]
"summary" "Install an OpenAPI"
Expand Down
4 changes: 2 additions & 2 deletions installers/data.example.org/_site/openapis.edn.edn
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{:deps
["https://data.example.org/_site/openapis"
"https://auth.example.org/operations/get-openapis"]
"https://data.example.org/_site/operations/get-openapis"]
:install
{:juxt.site/subject-uri "https://auth.example.org/_site/subjects/system"
:juxt.site/operation-uri "https://auth.example.org/operations/put-resource"
:juxt.site/input
{:xt/id "{{$id}}"
:juxt.site/methods
{:get {:juxt.site/operation-uri "https://auth.example.org/operations/get-openapis"}}
{:get {:juxt.site/operation-uri "https://data.example.org/_site/operations/get-openapis"}}
:juxt.site/variant-of "https://data.example.org/_site/openapis"
:juxt.http/content-type "application/edn"
:juxt.pick/quality-of-source 0.5 ; downgrade in content-negotiation
Expand Down
4 changes: 2 additions & 2 deletions installers/data.example.org/_site/openapis.json.edn
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{:deps
["https://data.example.org/_site/openapis"
"https://auth.example.org/operations/get-openapis"]
"https://data.example.org/_site/operations/get-openapis"]
:install
{:juxt.site/subject-uri "https://auth.example.org/_site/subjects/system"
:juxt.site/operation-uri "https://auth.example.org/operations/put-resource"
:juxt.site/input
{:xt/id "{{$id}}"
:juxt.site/methods
{:get {:juxt.site/operation-uri "https://auth.example.org/operations/get-openapis"}}
{:get {:juxt.site/operation-uri "https://data.example.org/_site/operations/get-openapis"}}
:juxt.site/variant-of "https://data.example.org/_site/openapis"
:juxt.http/content-type "application/json"

Expand Down
Loading
Loading