├── .orycli.yml ├── .npmignore ├── .github ├── CODEOWNER ├── config.yml ├── FUNDING.yml ├── workflows │ ├── format.yml │ ├── labels.yml │ ├── test-integration.yaml │ ├── closed_references.yml │ ├── licenses.yml │ ├── cve-scan.yaml │ └── conventional_commits.yml ├── auto_assign.yml ├── ISSUE_TEMPLATE │ └── config.yml └── pull_request_template.md ├── cmd ├── cloudx │ ├── client │ │ ├── fixtures │ │ │ └── iohelpers │ │ │ │ ├── a.yaml │ │ │ │ ├── b.yml │ │ │ │ └── c.json │ │ ├── print.go │ │ ├── http_client.go │ │ ├── iohelpers_test.go │ │ ├── flags.go │ │ ├── config_test.go │ │ ├── iohelpers.go │ │ ├── event_stream.go │ │ ├── organization.go │ │ ├── client.go │ │ └── workspace.go │ ├── e2e │ │ ├── .gitignore │ │ ├── cypress.json │ │ ├── app.js │ │ ├── package.json │ │ ├── root.go │ │ ├── cypress │ │ │ ├── support │ │ │ │ ├── index.js │ │ │ │ └── commands.js │ │ │ └── plugins │ │ │ │ └── index.js │ │ └── README.md │ ├── project │ │ ├── .snapshots │ │ │ ├── TestProjectIdentityConfig-prints_good_error_messages_for_failing_schemas-stdout.json │ │ │ ├── TestUpdateProject-target=project-prints_good_error_messages_for_failing_schemas-stdout.json │ │ │ ├── TestUpdateProject-target=identity-config-prints_good_error_messages_for_failing_schemas-stdout.json │ │ │ ├── TestUpdateProject-target=oauth2-config-prints_good_error_messages_for_failing_schemas-stdout.json │ │ │ ├── TestUpdateProject-target=permission-config-prints_good_error_messages_for_failing_schemas-stdout.json │ │ │ └── TestUpdateProject-target=permission-config-is_able_to_update_a_project.json │ │ ├── fixtures │ │ │ ├── update-hydra │ │ │ │ └── fail │ │ │ │ │ └── config.json │ │ │ ├── update-keto │ │ │ │ ├── fail │ │ │ │ │ └── config.json │ │ │ │ └── json │ │ │ │ │ └── config.json │ │ │ ├── patch │ │ │ │ ├── 2.json │ │ │ │ └── 1.json │ │ │ ├── update-kratos │ │ │ │ └── fail │ │ │ │ │ └── config.json │ │ │ └── update │ │ │ │ ├── json │ │ │ │ └── identity-schema.json │ │ │ │ └── fail │ │ │ │ └── config.json │ │ ├── main_test.go │ │ ├── list.go │ │ ├── use_test.go │ │ ├── use.go │ │ ├── get_identity_config.go │ │ ├── get_permission_config.go │ │ ├── get.go │ │ ├── get_oauth2_config.go │ │ ├── update_namespace_config_test.go │ │ ├── patch_oauth2_config_test.go │ │ ├── patch_identity_config_test.go │ │ ├── update_namespace_config.go │ │ ├── list_test.go │ │ ├── patch_permission_config_test.go │ │ ├── utils.go │ │ ├── update_identity_config.go │ │ ├── get_test.go │ │ ├── output.go │ │ ├── update_permission_config.go │ │ ├── update_oauth2_config.go │ │ ├── helper_test.go │ │ └── patch_permission_config.go │ ├── logout_test.go │ ├── main_test.go │ ├── relationtuples │ │ ├── permissions.go │ │ └── permissions_test.go │ ├── identity │ │ ├── list.go │ │ ├── import.go │ │ ├── get.go │ │ ├── delete.go │ │ ├── main_test.go │ │ ├── import_test.go │ │ ├── delete_test.go │ │ ├── get_test.go │ │ └── list_test.go │ ├── oauth2 │ │ ├── flows.go │ │ ├── token.go │ │ ├── client.go │ │ └── jwks.go │ ├── revoke.go │ ├── patch.go │ ├── use.go │ ├── introspect.go │ ├── parse.go │ ├── validate.go │ ├── is.go │ ├── perform.go │ ├── open.go │ ├── logout.go │ ├── import.go │ ├── workspace │ │ ├── list.go │ │ ├── get.go │ │ ├── output.go │ │ └── create.go │ ├── auth.go │ ├── eventstreams │ │ ├── flags.go │ │ ├── list.go │ │ ├── delete.go │ │ ├── output.go │ │ ├── update.go │ │ └── create.go │ ├── get.go │ ├── auth_test.go │ ├── update.go │ ├── delete.go │ ├── organizations │ │ ├── list_organizations.go │ │ ├── delete_organization.go │ │ ├── output.go │ │ ├── create_organization.go │ │ ├── organizations_test.go │ │ └── update_organization.go │ ├── create.go │ ├── list.go │ └── accountexperience │ │ ├── accountexperience_test.go │ │ └── accountexperience.go ├── dev │ ├── ci │ │ ├── deps │ │ │ ├── test │ │ │ │ ├── invalidFile.yaml │ │ │ │ ├── defaultURL.yaml │ │ │ │ ├── customOSURL.yaml │ │ │ │ ├── customArchURL.yaml │ │ │ │ └── full-working.yaml │ │ │ └── main.go │ │ ├── monorepo │ │ │ ├── test │ │ │ │ ├── invalidConfigFile │ │ │ │ │ └── monorepo.yml │ │ │ │ ├── working │ │ │ │ │ ├── console │ │ │ │ │ │ ├── src │ │ │ │ │ │ │ └── monorepo.yml │ │ │ │ │ │ └── helm │ │ │ │ │ │ │ └── monorepo.yml │ │ │ │ │ ├── stack │ │ │ │ │ │ └── monorepo.yml │ │ │ │ │ └── backoffice │ │ │ │ │ │ ├── src │ │ │ │ │ │ └── monorepo.yml │ │ │ │ │ │ ├── helm │ │ │ │ │ │ └── monorepo.yml │ │ │ │ │ │ └── docker │ │ │ │ │ │ └── monorepo.yml │ │ │ │ └── circular │ │ │ │ │ ├── componentA │ │ │ │ │ └── monorepo.yml │ │ │ │ │ └── componentB │ │ │ │ │ └── monorepo.yml │ │ │ ├── main.go │ │ │ └── depgraph_test.go │ │ ├── orbs │ │ │ ├── main.go │ │ │ └── bump.go │ │ ├── github │ │ │ ├── main.go │ │ │ └── env.go │ │ └── main.go │ ├── newsletter │ │ ├── stub │ │ │ └── .gitignore │ │ ├── main.go │ │ ├── render_test.go │ │ └── send.go │ ├── headers │ │ ├── comments │ │ │ ├── doc.go │ │ │ ├── file_type.go │ │ │ ├── file_type_test.go │ │ │ ├── files_test.go │ │ │ └── files.go │ │ └── main.go │ ├── markdown │ │ ├── main.go │ │ ├── render_test.go │ │ └── render.go │ ├── swagger │ │ ├── main.go │ │ └── sanitize_test.go │ ├── release │ │ ├── notify │ │ │ ├── main.go │ │ │ └── send.go │ │ ├── main.go │ │ └── compile.go │ ├── openapi │ │ └── main.go │ ├── schema │ │ ├── main.go │ │ ├── latest.fragment.schema.json │ │ ├── fixtures │ │ │ └── render_version_test │ │ │ │ └── .schema │ │ │ │ └── version.schema.json │ │ └── expected │ │ │ └── render_version_test │ │ │ └── .schema │ │ │ └── version.schema.json │ └── main.go ├── nodev.go ├── root_test.go ├── dev.go ├── clidoc │ └── main.go ├── version.go ├── pkg │ ├── github.go │ ├── cli.go │ ├── repos.go │ └── patch.go └── root.go ├── .reference-ignore ├── cypress.json ├── .grype.yaml ├── .vscode └── settings.json ├── cypress ├── fixtures │ └── example.json ├── support │ ├── index.js │ └── commands.js ├── plugins │ └── index.js └── integration │ └── proxy.spec.js ├── view └── view.go ├── .reports └── dep-licenses.csv ├── spec └── spec.go ├── .gitignore ├── .docker ├── Dockerfile-distroless-static ├── Dockerfile-alpine └── Dockerfile-build ├── main.go ├── .editorconfig ├── test ├── changelog.md └── note.md ├── .goreleaser.yml ├── .golangci.yml ├── npm └── index.js ├── package.json ├── README.md ├── SECURITY.md └── Makefile /.orycli.yml: -------------------------------------------------------------------------------- 1 | project: cli 2 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | * 2 | !npm/* 3 | !bin/* 4 | -------------------------------------------------------------------------------- /.github/CODEOWNER: -------------------------------------------------------------------------------- 1 | * @ory/maintainers 2 | -------------------------------------------------------------------------------- /cmd/cloudx/client/fixtures/iohelpers/a.yaml: -------------------------------------------------------------------------------- 1 | a: true -------------------------------------------------------------------------------- /cmd/cloudx/client/fixtures/iohelpers/b.yml: -------------------------------------------------------------------------------- 1 | b: true -------------------------------------------------------------------------------- /cmd/dev/ci/deps/test/invalidFile.yaml: -------------------------------------------------------------------------------- 1 | I am invalid. 2 | -------------------------------------------------------------------------------- /cmd/dev/newsletter/stub/.gitignore: -------------------------------------------------------------------------------- 1 | changelog.html.tmp 2 | -------------------------------------------------------------------------------- /.reference-ignore: -------------------------------------------------------------------------------- 1 | **/node_modules 2 | docs 3 | CHANGELOG.md 4 | -------------------------------------------------------------------------------- /cmd/dev/ci/monorepo/test/invalidConfigFile/monorepo.yml: -------------------------------------------------------------------------------- 1 | invalid -------------------------------------------------------------------------------- /cmd/cloudx/client/fixtures/iohelpers/c.json: -------------------------------------------------------------------------------- 1 | { 2 | "c": true 3 | } -------------------------------------------------------------------------------- /cypress.json: -------------------------------------------------------------------------------- 1 | { 2 | "baseUrl": "http://localhost:4000" 3 | } 4 | -------------------------------------------------------------------------------- /.grype.yaml: -------------------------------------------------------------------------------- 1 | #only-fixed: true 2 | ignore: 3 | - vulnerability: CVE-2023-42821 -------------------------------------------------------------------------------- /cmd/cloudx/e2e/.gitignore: -------------------------------------------------------------------------------- 1 | videos/ 2 | screenshots/ 3 | ory 4 | fixtures/example.json 5 | -------------------------------------------------------------------------------- /cmd/dev/ci/monorepo/test/working/console/src/monorepo.yml: -------------------------------------------------------------------------------- 1 | name: Console 2 | id: console -------------------------------------------------------------------------------- /cmd/dev/ci/monorepo/test/working/stack/monorepo.yml: -------------------------------------------------------------------------------- 1 | name: Terraform 2 | id: terraform -------------------------------------------------------------------------------- /cmd/dev/ci/monorepo/test/working/backoffice/src/monorepo.yml: -------------------------------------------------------------------------------- 1 | name: Backoffice 2 | id: backoffice -------------------------------------------------------------------------------- /cmd/dev/ci/monorepo/test/working/console/helm/monorepo.yml: -------------------------------------------------------------------------------- 1 | name: Console Helm Chart 2 | id: console-helm 3 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "gopls": { 3 | "formatting.local": "github.com/ory", 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /cmd/dev/ci/monorepo/test/working/backoffice/helm/monorepo.yml: -------------------------------------------------------------------------------- 1 | name: Backoffice Helm Chart 2 | id: backoffice-helm 3 | -------------------------------------------------------------------------------- /cmd/cloudx/project/.snapshots/TestProjectIdentityConfig-prints_good_error_messages_for_failing_schemas-stdout.json: -------------------------------------------------------------------------------- 1 | "" 2 | -------------------------------------------------------------------------------- /cmd/cloudx/project/fixtures/update-hydra/fail/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "ttl": { 3 | "access_token": 1234 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /cmd/cloudx/project/fixtures/update-keto/fail/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "namespaces": "foo", 3 | "limit": "nothing" 4 | } 5 | -------------------------------------------------------------------------------- /cmd/cloudx/client/print.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package client 5 | -------------------------------------------------------------------------------- /cmd/cloudx/project/.snapshots/TestUpdateProject-target=project-prints_good_error_messages_for_failing_schemas-stdout.json: -------------------------------------------------------------------------------- 1 | "" 2 | -------------------------------------------------------------------------------- /cmd/dev/ci/monorepo/test/circular/componentA/monorepo.yml: -------------------------------------------------------------------------------- 1 | name: Component A 2 | id: component-a 3 | deps: 4 | - component-b 5 | -------------------------------------------------------------------------------- /cmd/dev/ci/monorepo/test/circular/componentB/monorepo.yml: -------------------------------------------------------------------------------- 1 | name: Component B 2 | id: component-b 3 | deps: 4 | - component-a 5 | -------------------------------------------------------------------------------- /cmd/cloudx/project/.snapshots/TestUpdateProject-target=identity-config-prints_good_error_messages_for_failing_schemas-stdout.json: -------------------------------------------------------------------------------- 1 | "" 2 | -------------------------------------------------------------------------------- /cmd/cloudx/project/.snapshots/TestUpdateProject-target=oauth2-config-prints_good_error_messages_for_failing_schemas-stdout.json: -------------------------------------------------------------------------------- 1 | "" 2 | -------------------------------------------------------------------------------- /cmd/cloudx/project/.snapshots/TestUpdateProject-target=permission-config-prints_good_error_messages_for_failing_schemas-stdout.json: -------------------------------------------------------------------------------- 1 | "" 2 | -------------------------------------------------------------------------------- /cmd/cloudx/e2e/cypress.json: -------------------------------------------------------------------------------- 1 | { 2 | "baseUrl": "http://localhost:4000", 3 | "chromeWebSecurity": false, 4 | "projectId": "hvfo5u" 5 | } 6 | -------------------------------------------------------------------------------- /cmd/dev/ci/monorepo/test/working/backoffice/docker/monorepo.yml: -------------------------------------------------------------------------------- 1 | name: Backoffice Docker Container 2 | id: backoffice-docker 3 | deps: 4 | - backoffice 5 | - terraform 6 | -------------------------------------------------------------------------------- /cmd/dev/ci/deps/test/defaultURL.yaml: -------------------------------------------------------------------------------- 1 | version: v1.20.2 2 | url: https://storage.googleapis.com/kubernetes-release/release/{{.Version}}/bin/{{.Os}}/{{.Architecture}}/kubectl 3 | -------------------------------------------------------------------------------- /cypress/fixtures/example.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Using fixtures to represent data", 3 | "email": "hello@cypress.io", 4 | "body": "Fixtures are a great way to mock data for responses to routes" 5 | } 6 | -------------------------------------------------------------------------------- /view/view.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package view 5 | 6 | import _ "embed" 7 | 8 | //go:embed mail-body.html 9 | var MailBody []byte 10 | -------------------------------------------------------------------------------- /.reports/dep-licenses.csv: -------------------------------------------------------------------------------- 1 | "module name","licenses" 2 | "@ory/cli@0.0.85","Apache*" 3 | 4 | "github.com/ory/x","Apache-2.0" 5 | "github.com/stretchr/testify","MIT" 6 | "golang.org/x/text","BSD-3-Clause" 7 | 8 | -------------------------------------------------------------------------------- /cmd/cloudx/project/fixtures/patch/2.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "op": "add", 4 | "path": "/services/identity/config/selfservice/methods/webauthn/config/rp/display_name", 5 | "value": "some value" 6 | } 7 | ] -------------------------------------------------------------------------------- /spec/spec.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package spec 5 | 6 | import _ "embed" 7 | 8 | //go:embed version_meta.schema.json 9 | var VersionSchema []byte 10 | -------------------------------------------------------------------------------- /cmd/dev/headers/comments/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // Package comments provides functionality to add and remove comments to the top of files. 5 | package comments 6 | -------------------------------------------------------------------------------- /.github/config.yml: -------------------------------------------------------------------------------- 1 | # AUTO-GENERATED, DO NOT EDIT! 2 | # Please edit the original at https://github.com/ory/meta/blob/master/templates/repository/common/.github/config.yml 3 | 4 | todo: 5 | keyword: "@todo" 6 | label: todo 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .bin/ 2 | dist/ 3 | pkged.go 4 | *.crt 5 | *.key 6 | docs/ 7 | node_modules 8 | ory 9 | bin/ 10 | unpacked_bin/ 11 | .idea 12 | cypress/screenshots 13 | cypress/videos 14 | cli 15 | playwright-traces 16 | .DS_Store 17 | -------------------------------------------------------------------------------- /cmd/dev/ci/deps/test/customOSURL.yaml: -------------------------------------------------------------------------------- 1 | version: v1.20.2 2 | url: https://storage.googleapis.com/kubernetes-release/release/{{.Version}}/bin/{{.Os}}/{{.Architecture}}/kubectl 3 | mappings: 4 | os: 5 | darwin: mac 6 | linux: unix 7 | -------------------------------------------------------------------------------- /cmd/cloudx/logout_test.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package cloudx_test 5 | 6 | import ( 7 | "testing" 8 | ) 9 | 10 | func TestAuthLogout(t *testing.T) { 11 | t.Skip("TODO") 12 | } 13 | -------------------------------------------------------------------------------- /cmd/dev/ci/deps/test/customArchURL.yaml: -------------------------------------------------------------------------------- 1 | version: v1.20.2 2 | url: https://storage.googleapis.com/kubernetes-release/release/{{.Version}}/bin/{{.Os}}/{{.Architecture}}/kubectl 3 | mappings: 4 | architecture: 5 | amd64: x64 6 | arm64: aarch64 7 | -------------------------------------------------------------------------------- /cmd/nodev.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | //go:build nodev 5 | // +build nodev 6 | 7 | package cmd 8 | 9 | import ( 10 | "github.com/spf13/cobra" 11 | ) 12 | 13 | var devCommands []*cobra.Command 14 | -------------------------------------------------------------------------------- /.docker/Dockerfile-distroless-static: -------------------------------------------------------------------------------- 1 | FROM gcr.io/distroless/static-debian12:nonroot 2 | 3 | COPY ory /usr/bin/ory 4 | # Declare the standard ports used by hydra (4444 for public service endpoint, 4445 for admin service endpoint) 5 | EXPOSE 4444 4445 6 | 7 | ENTRYPOINT ["ory"] 8 | -------------------------------------------------------------------------------- /cmd/dev/ci/orbs/main.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package orbs 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | ) 9 | 10 | var Main = &cobra.Command{ 11 | Use: "orbs", 12 | Short: "Helpers for CircleCI", 13 | } 14 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # AUTO-GENERATED, DO NOT EDIT! 2 | # Please edit the original at https://github.com/ory/meta/blob/master/templates/repository/common/.github/FUNDING.yml 3 | 4 | # These are supported funding model platforms 5 | 6 | # github: 7 | patreon: _ory 8 | open_collective: ory 9 | -------------------------------------------------------------------------------- /cmd/dev/ci/github/main.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package github 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | ) 9 | 10 | var Main = &cobra.Command{ 11 | Use: "github", 12 | Short: "Helpers for GitHub", 13 | } 14 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package main 5 | 6 | import ( 7 | "github.com/ory/cli/cmd" 8 | "github.com/ory/x/profilex" 9 | ) 10 | 11 | func main() { 12 | defer profilex.Profile().Stop() 13 | cmd.Execute() 14 | } 15 | -------------------------------------------------------------------------------- /cmd/dev/headers/main.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package headers 5 | 6 | import "github.com/spf13/cobra" 7 | 8 | var Main = &cobra.Command{ 9 | Use: "headers", 10 | Short: "Adds language-specific headers to files", 11 | } 12 | -------------------------------------------------------------------------------- /cmd/cloudx/project/fixtures/update-keto/json/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "namespaces": [ 3 | { 4 | "name": "files", 5 | "id": 1 6 | }, 7 | { 8 | "name": "directories", 9 | "id": 2 10 | } 11 | ], 12 | "limit": { 13 | "max_read_depth": 7 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /cmd/root_test.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package cmd 5 | 6 | import ( 7 | "testing" 8 | 9 | "github.com/ory/x/cmdx" 10 | ) 11 | 12 | func TestUsageTemplating(t *testing.T) { 13 | cmdx.AssertUsageTemplates(t, NewRootCmd()) 14 | } 15 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | ; http://editorconfig.org/ 2 | 3 | root = true 4 | 5 | [*] 6 | insert_final_newline = true 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | indent_style = space 10 | indent_size = 2 11 | 12 | [{Makefile,go.mod,go.sum,*.go}] 13 | indent_style = tab 14 | indent_size = 4 15 | -------------------------------------------------------------------------------- /cmd/dev/ci/deps/test/full-working.yaml: -------------------------------------------------------------------------------- 1 | version: v1.20.2 2 | url: https://storage.googleapis.com/kubernetes-release/release/{{.Version}}/bin/{{.Os}}/{{.Architecture}}/kubectl 3 | mappings: 4 | architecture: 5 | amd64: x64 6 | arm64: aarch64 7 | os: 8 | darwin: mac 9 | linux: unix 10 | -------------------------------------------------------------------------------- /cmd/dev/markdown/main.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package markdown 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | ) 9 | 10 | var Main = &cobra.Command{ 11 | Use: "markdown", 12 | Short: "Utilities for working with markdown", 13 | } 14 | -------------------------------------------------------------------------------- /cmd/dev/swagger/main.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package swagger 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | ) 9 | 10 | var Main = &cobra.Command{ 11 | Use: "swagger", 12 | Short: "Helpers for Swagger 2.0 / OpenAPI spec", 13 | } 14 | -------------------------------------------------------------------------------- /cmd/dev.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | //go:build !nodev 5 | // +build !nodev 6 | 7 | package cmd 8 | 9 | import ( 10 | "github.com/spf13/cobra" 11 | 12 | "github.com/ory/cli/cmd/dev" 13 | ) 14 | 15 | var devCommands = []*cobra.Command{dev.Main} 16 | -------------------------------------------------------------------------------- /cmd/dev/release/notify/main.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package notify 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | ) 9 | 10 | var Main = &cobra.Command{ 11 | Use: "notify", 12 | Short: "Notify subscribers about new releases", 13 | } 14 | -------------------------------------------------------------------------------- /cmd/cloudx/main_test.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package cloudx_test 5 | 6 | import ( 7 | "testing" 8 | 9 | "github.com/ory/cli/cmd/cloudx/testhelpers" 10 | ) 11 | 12 | func TestMain(m *testing.M) { 13 | testhelpers.UseStaging() 14 | m.Run() 15 | } 16 | -------------------------------------------------------------------------------- /cmd/dev/newsletter/main.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package newsletter 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | ) 9 | 10 | var Main = &cobra.Command{ 11 | Use: "newsletter", 12 | Short: "Draft and send release newsletters using Mailchimp", 13 | } 14 | -------------------------------------------------------------------------------- /.docker/Dockerfile-alpine: -------------------------------------------------------------------------------- 1 | FROM alpine:3.22 2 | 3 | RUN apk add -U --no-cache ca-certificates libssl3 libcrypto3 bash 4 | 5 | RUN addgroup -S ory; \ 6 | adduser -S ory -G ory -D -h /home/ory -s /bin/nologin; \ 7 | chown -R ory:ory /home/ory 8 | 9 | COPY ory /usr/bin/ory 10 | 11 | USER ory 12 | 13 | ENTRYPOINT ["ory"] 14 | -------------------------------------------------------------------------------- /cmd/cloudx/project/.snapshots/TestUpdateProject-target=permission-config-is_able_to_update_a_project.json: -------------------------------------------------------------------------------- 1 | { 2 | "limit": { 3 | "max_read_depth": 7 4 | }, 5 | "namespaces": [ 6 | { 7 | "id": 1, 8 | "name": "files" 9 | }, 10 | { 11 | "id": 2, 12 | "name": "directories" 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /cmd/cloudx/project/fixtures/patch/1.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "op": "replace", 4 | "path": "/services/identity/config/selfservice/methods/webauthn/enabled", 5 | "value": true 6 | }, 7 | { 8 | "op": "add", 9 | "path": "/services/identity/config/selfservice/methods/webauthn/config/passwordless", 10 | "value": true 11 | } 12 | ] -------------------------------------------------------------------------------- /test/changelog.md: -------------------------------------------------------------------------------- 1 | **Bug Fixes:** 2 | 3 | - Remove changelog heading from template 4 | ([d1e330c](https://github.com/ory/release/commit/d1e330c29e7a252e8355a983d3561d162b4ef770)) 5 | 6 | **Features:** 7 | 8 | - Add send command and refactor names 9 | ([75e87cf](https://github.com/ory/release/commit/75e87cf6ac51917550fc035e3e61a83bb15f859d)) 10 | -------------------------------------------------------------------------------- /cmd/dev/openapi/main.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package openapi 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | ) 9 | 10 | var Main = &cobra.Command{ 11 | Use: "openapi", 12 | Short: "Helpers for OpenAPI 3.0", 13 | } 14 | 15 | func init() { 16 | Main.AddCommand( 17 | migrateCmd, 18 | ) 19 | } 20 | -------------------------------------------------------------------------------- /cmd/dev/schema/main.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package schema 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | ) 9 | 10 | var Main = &cobra.Command{ 11 | Use: "schema", 12 | Short: "JSON Schema related helpers", 13 | } 14 | 15 | func init() { 16 | Main.AddCommand( 17 | RenderVersion, 18 | ) 19 | } 20 | -------------------------------------------------------------------------------- /cmd/dev/markdown/render_test.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package markdown 5 | 6 | import ( 7 | "strings" 8 | "testing" 9 | 10 | "github.com/stretchr/testify/assert" 11 | ) 12 | 13 | func TestRenderMarkdown(t *testing.T) { 14 | assert.EqualValues(t, `foo
`, 15 | strings.TrimSpace(string(renderMarkdown([]byte(`**foo**`))))) 16 | } 17 | -------------------------------------------------------------------------------- /.github/workflows/format.yml: -------------------------------------------------------------------------------- 1 | name: Format 2 | 3 | on: 4 | pull_request: 5 | push: 6 | 7 | jobs: 8 | format: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v3 12 | - uses: actions/setup-go@v3 13 | with: 14 | go-version: "1.24" 15 | - run: make format 16 | - name: Indicate formatting issues 17 | run: git diff HEAD --exit-code --color 18 | -------------------------------------------------------------------------------- /cmd/cloudx/relationtuples/permissions.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package relationtuples 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | 9 | "github.com/ory/keto/cmd/check" 10 | ) 11 | 12 | func NewAllowedCmd() *cobra.Command { 13 | cmd := check.NewCheckCmd() 14 | wrapForOryCLI(cmd) 15 | cmd.Use = "allowed " 16 | 17 | return cmd 18 | } 19 | -------------------------------------------------------------------------------- /cmd/dev/release/main.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package release 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | 9 | "github.com/ory/cli/cmd/dev/release/notify" 10 | ) 11 | 12 | var Main = &cobra.Command{ 13 | Use: "release", 14 | Short: "Release infrastructure for ORY and related components", 15 | } 16 | 17 | func init() { 18 | Main.AddCommand( 19 | notify.Main, 20 | ) 21 | } 22 | -------------------------------------------------------------------------------- /test/note.md: -------------------------------------------------------------------------------- 1 | Several indices have been added to the SQL Migrations. There are no backwards 2 | incompatible changes in this release but we advise to do a test-run of the SQL 3 | Migrations before applying them, as they might lock some tables which may cause 4 | downtimes. 5 | 6 | > Make a backup of your database before applying this change. 7 | 8 | After applying these SQL Migrations, several queries and endpoints will be much 9 | faster than before. 10 | -------------------------------------------------------------------------------- /.goreleaser.yml: -------------------------------------------------------------------------------- 1 | includes: 2 | - from_url: 3 | url: https://raw.githubusercontent.com/ory/xgoreleaser/master/build.tmpl.yml 4 | 5 | variables: 6 | brew_name: cli 7 | 8 | brew_description: "Use Ory from your terminal!" 9 | 10 | buildinfo_hash: "github.com/ory/cli/buildinfo.GitHash" 11 | buildinfo_tag: "github.com/ory/cli/buildinfo.Version" 12 | buildinfo_date: "github.com/ory/cli/buildinfo.Time" 13 | 14 | project_name: ory 15 | version: 2 16 | -------------------------------------------------------------------------------- /cmd/cloudx/e2e/app.js: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | const express = require("express") 5 | const app = express() 6 | const port = 4001 7 | 8 | app.get("/", (req, res) => { 9 | res.send("app home") 10 | }) 11 | 12 | app.get("/anything", (req, res) => { 13 | res.send({ headers: req.headers }) 14 | }) 15 | 16 | app.listen(port, () => { 17 | console.log(`Example app listening on port ${port}`) 18 | }) 19 | -------------------------------------------------------------------------------- /cmd/clidoc/main.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package main 5 | 6 | import ( 7 | "fmt" 8 | "os" 9 | 10 | "github.com/ory/cli/cmd" 11 | "github.com/ory/x/clidoc" 12 | ) 13 | 14 | func main() { 15 | if err := clidoc.Generate(cmd.NewRootCmd(), os.Args[1:]); err != nil { 16 | _, _ = fmt.Fprintf(os.Stderr, "%+v", err) 17 | os.Exit(1) 18 | } 19 | fmt.Println("All files have been generated and updated.") 20 | } 21 | -------------------------------------------------------------------------------- /cmd/cloudx/client/http_client.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package client 5 | 6 | import ( 7 | "net/http" 8 | "time" 9 | 10 | "golang.org/x/oauth2" 11 | ) 12 | 13 | func newOAuth2TokenClient(token oauth2.TokenSource) *http.Client { 14 | return &http.Client{ 15 | Transport: &oauth2.Transport{ 16 | Base: http.DefaultTransport, 17 | Source: token, 18 | }, 19 | Timeout: time.Second * 30, 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /cmd/cloudx/identity/list.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package identity 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | 9 | "github.com/ory/cli/cmd/cloudx/client" 10 | "github.com/ory/kratos/cmd/identities" 11 | ) 12 | 13 | func NewListIdentityCmd() *cobra.Command { 14 | cmd := identities.NewListIdentitiesCmd() 15 | client.RegisterProjectFlag(cmd.Flags()) 16 | client.RegisterWorkspaceFlag(cmd.Flags()) 17 | return cmd 18 | } 19 | -------------------------------------------------------------------------------- /cmd/cloudx/oauth2/flows.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package oauth2 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | 9 | hydra "github.com/ory/hydra/v2/cmd" 10 | ) 11 | 12 | func NewPerformAuthorizationCode() *cobra.Command { 13 | return wrapHydraCmd(hydra.NewPerformAuthorizationCodeCmd) 14 | } 15 | 16 | func NewPerformClientCredentials() *cobra.Command { 17 | return wrapHydraCmd(hydra.NewPerformClientCredentialsCmd) 18 | } 19 | -------------------------------------------------------------------------------- /cmd/cloudx/identity/import.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package identity 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | 9 | "github.com/ory/cli/cmd/cloudx/client" 10 | "github.com/ory/kratos/cmd/identities" 11 | ) 12 | 13 | func NewImportIdentityCmd() *cobra.Command { 14 | cmd := identities.NewImportIdentitiesCmd() 15 | client.RegisterProjectFlag(cmd.Flags()) 16 | client.RegisterWorkspaceFlag(cmd.Flags()) 17 | return cmd 18 | } 19 | -------------------------------------------------------------------------------- /cmd/cloudx/e2e/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "prettier": "ory-prettier-styles", 4 | "config": { 5 | "prettierTarget": "{**/,}*{.js,.md,.ts}" 6 | }, 7 | "scripts": { 8 | "server": "node app.js", 9 | "test": "cypress run --record", 10 | "test:dev": "cypress open" 11 | }, 12 | "devDependencies": { 13 | "cypress": "^9.0.0", 14 | "jsonwebtoken": "^8.5.1", 15 | "jwks-rsa": "^2.0.5" 16 | }, 17 | "dependencies": { 18 | "express": "^4.17.3" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /cmd/cloudx/identity/get.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package identity 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | 9 | "github.com/ory/cli/cmd/cloudx/client" 10 | "github.com/ory/kratos/cmd/identities" 11 | "github.com/ory/x/cmdx" 12 | ) 13 | 14 | func NewGetIdentityCmd() *cobra.Command { 15 | cmd := identities.NewGetIdentityCmd() 16 | client.RegisterProjectFlag(cmd.Flags()) 17 | client.RegisterWorkspaceFlag(cmd.Flags()) 18 | cmdx.RegisterFormatFlags(cmd.Flags()) 19 | return cmd 20 | } 21 | -------------------------------------------------------------------------------- /.golangci.yml: -------------------------------------------------------------------------------- 1 | version: "2" 2 | linters: 3 | exclusions: 4 | generated: lax 5 | presets: 6 | - comments 7 | - common-false-positives 8 | - legacy 9 | - std-error-handling 10 | paths: 11 | - third_party$ 12 | - builtin$ 13 | - examples$ 14 | formatters: 15 | enable: 16 | - goimports 17 | settings: 18 | goimports: 19 | local-prefixes: 20 | - github.com/ory 21 | exclusions: 22 | generated: lax 23 | paths: 24 | - third_party$ 25 | - builtin$ 26 | - examples$ 27 | -------------------------------------------------------------------------------- /cmd/cloudx/oauth2/token.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package oauth2 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | 9 | hydra "github.com/ory/hydra/v2/cmd" 10 | ) 11 | 12 | func NewDeleteAccessTokens() *cobra.Command { 13 | return wrapHydraCmd(hydra.NewDeleteAccessTokensCmd) 14 | } 15 | 16 | func NewRevokeToken() *cobra.Command { 17 | return wrapHydraCmd(hydra.NewRevokeTokenCmd) 18 | } 19 | 20 | func NewIntrospectToken() *cobra.Command { 21 | return wrapHydraCmd(hydra.NewIntrospectTokenCmd) 22 | } 23 | -------------------------------------------------------------------------------- /cmd/cloudx/identity/delete.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package identity 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | 9 | "github.com/ory/cli/cmd/cloudx/client" 10 | "github.com/ory/kratos/cmd/identities" 11 | "github.com/ory/x/cmdx" 12 | ) 13 | 14 | func NewDeleteIdentityCmd() *cobra.Command { 15 | cmd := identities.NewDeleteIdentityCmd() 16 | client.RegisterProjectFlag(cmd.Flags()) 17 | client.RegisterWorkspaceFlag(cmd.Flags()) 18 | cmdx.RegisterFormatFlags(cmd.Flags()) 19 | return cmd 20 | } 21 | -------------------------------------------------------------------------------- /cmd/cloudx/revoke.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package cloudx 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | 9 | "github.com/ory/cli/cmd/cloudx/oauth2" 10 | "github.com/ory/x/cmdx" 11 | ) 12 | 13 | func NewRevokeCmd() *cobra.Command { 14 | cmd := &cobra.Command{ 15 | Use: "revoke", 16 | Short: "Revoke resources", 17 | } 18 | cmd.AddCommand(oauth2.NewRevokeToken()) 19 | 20 | cmdx.RegisterHTTPClientFlags(cmd.PersistentFlags()) 21 | cmdx.RegisterFormatFlags(cmd.PersistentFlags()) 22 | return cmd 23 | } 24 | -------------------------------------------------------------------------------- /.github/auto_assign.yml: -------------------------------------------------------------------------------- 1 | # AUTO-GENERATED, DO NOT EDIT! 2 | # Please edit the original at https://github.com/ory/meta/blob/master/templates/repository/common/.github/auto_assign.yml 3 | 4 | # Set to true to add reviewers to pull requests 5 | addReviewers: true 6 | 7 | # Set to true to add assignees to pull requests 8 | addAssignees: true 9 | 10 | # A list of reviewers to be added to pull requests (GitHub user name) 11 | assignees: 12 | - ory/maintainers 13 | 14 | # A number of reviewers added to the pull request 15 | # Set 0 to add all the reviewers (default: 0) 16 | numberOfReviewers: 0 17 | -------------------------------------------------------------------------------- /cmd/cloudx/identity/main_test.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package identity_test 5 | 6 | import ( 7 | "context" 8 | "testing" 9 | 10 | cloud "github.com/ory/client-go" 11 | 12 | "github.com/ory/cli/cmd/cloudx/testhelpers" 13 | "github.com/ory/x/cmdx" 14 | ) 15 | 16 | var ( 17 | ctx context.Context 18 | defaultProject *cloud.Project 19 | defaultCmd *cmdx.CommandExecuter 20 | ) 21 | 22 | func TestMain(m *testing.M) { 23 | ctx, _, _, _, defaultProject, defaultCmd = testhelpers.CreateDefaultAssetsBrowser() 24 | m.Run() 25 | } 26 | -------------------------------------------------------------------------------- /cmd/version.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package cmd 5 | 6 | import ( 7 | "fmt" 8 | 9 | "github.com/ory/cli/buildinfo" 10 | 11 | "github.com/spf13/cobra" 12 | ) 13 | 14 | var versionCmd = &cobra.Command{ 15 | Use: "version", 16 | Short: "Display this binary's version, build time, and git hash of this build", 17 | Run: func(cmd *cobra.Command, args []string) { 18 | fmt.Printf("Version: %s\n", buildinfo.Version) 19 | fmt.Printf("Git Hash: %s\n", buildinfo.GitHash) 20 | fmt.Printf("Build Time: %s\n", buildinfo.Time) 21 | }, 22 | } 23 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | # AUTO-GENERATED, DO NOT EDIT! 2 | # Please edit the original at https://github.com/ory/meta/blob/master/templates/repository/common/.github/ISSUE_TEMPLATE/config.yml 3 | 4 | blank_issues_enabled: false 5 | contact_links: 6 | - name: Ory CLI Forum 7 | url: https://github.com/orgs/ory/discussions 8 | about: 9 | Please ask and answer questions here, show your implementations and 10 | discuss ideas. 11 | - name: Ory Chat 12 | url: https://www.ory.com/chat 13 | about: 14 | Hang out with other Ory community members to ask and answer questions. 15 | -------------------------------------------------------------------------------- /cmd/cloudx/client/iohelpers_test.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package client 5 | 6 | import ( 7 | "encoding/json" 8 | "testing" 9 | 10 | "github.com/stretchr/testify/require" 11 | 12 | "github.com/ory/x/assertx" 13 | ) 14 | 15 | func TestReadConfigFiles(t *testing.T) { 16 | configs, err := ReadAndParseFiles([]string{ 17 | "fixtures/iohelpers/a.yaml", 18 | "fixtures/iohelpers/b.yml", 19 | "fixtures/iohelpers/c.json", 20 | }) 21 | require.NoError(t, err) 22 | assertx.EqualAsJSON(t, json.RawMessage(`[{"a":true},{"b":true},{"c":true}]`), configs) 23 | } 24 | -------------------------------------------------------------------------------- /cmd/dev/ci/main.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package ci 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | 9 | "github.com/ory/cli/cmd/dev/ci/deps" 10 | "github.com/ory/cli/cmd/dev/ci/github" 11 | "github.com/ory/cli/cmd/dev/ci/monorepo" 12 | "github.com/ory/cli/cmd/dev/ci/orbs" 13 | ) 14 | 15 | var Main = &cobra.Command{ 16 | Use: "ci", 17 | Short: "Continuous Integration helpers", 18 | } 19 | 20 | func init() { 21 | Main.AddCommand(orbs.Main) 22 | Main.AddCommand(github.Main) 23 | Main.AddCommand(monorepo.Main) 24 | Main.AddCommand(deps.Main) 25 | } 26 | -------------------------------------------------------------------------------- /cmd/dev/ci/deps/main.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package deps 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | ) 9 | 10 | var Main = &cobra.Command{ 11 | Use: "deps", 12 | Short: "Helpers for binary dependencies in Makefiles.", 13 | } 14 | 15 | func init() { 16 | Main.PersistentFlags().StringP("os", "o", "", "OS the binary should run on. Currently only 'linux' and 'darwin' are supported.") 17 | Main.PersistentFlags().StringP("architecture", "a", "", "Architecture the binary should run on. Currently only 'amd64' is supported.") 18 | Main.PersistentFlags().StringP("config", "c", "", "Path to config files.") 19 | } 20 | -------------------------------------------------------------------------------- /cmd/dev/schema/latest.fragment.schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "allOf": [ 3 | { 4 | "oneOf": [ 5 | { 6 | "properties": { 7 | "version": { 8 | "type": "string", 9 | "maxLength": 0 10 | } 11 | }, 12 | "required": [ 13 | "version" 14 | ] 15 | }, 16 | { 17 | "not": { 18 | "properties": { 19 | "version": {} 20 | }, 21 | "required": [ 22 | "version" 23 | ] 24 | } 25 | } 26 | ] 27 | }, 28 | { 29 | "$ref": "#/oneOf/0/allOf/1" 30 | } 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /cmd/cloudx/patch.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package cloudx 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | 9 | "github.com/ory/cli/cmd/cloudx/client" 10 | "github.com/ory/cli/cmd/cloudx/project" 11 | ) 12 | 13 | func NewPatchCmd() *cobra.Command { 14 | cmd := &cobra.Command{ 15 | Use: "patch", 16 | Short: "Patch resources", 17 | } 18 | client.RegisterConfigFlag(cmd.PersistentFlags()) 19 | cmd.AddCommand( 20 | project.NewProjectsPatchCmd(), 21 | project.NewPatchKratosConfigCmd(), 22 | project.NewPatchKetoConfigCmd(), 23 | project.NewPatchOAuth2ConfigCmd(), 24 | project.NewUpdateNamespaceConfigCmd(), 25 | ) 26 | return cmd 27 | } 28 | -------------------------------------------------------------------------------- /cmd/dev/release/notify/send.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package notify 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | 9 | "github.com/ory/cli/cmd/dev/newsletter" 10 | "github.com/ory/x/flagx" 11 | ) 12 | 13 | var send = &cobra.Command{ 14 | Use: "send [list-id]", 15 | Short: "Send the release notification Mailchimp campaign", 16 | Args: cobra.ExactArgs(1), 17 | RunE: func(cmd *cobra.Command, args []string) error { 18 | newsletter.SendCampaign(args[0], flagx.MustGetBool(cmd, "dry")) 19 | return nil 20 | }, 21 | } 22 | 23 | func init() { 24 | Main.AddCommand(send) 25 | send.Flags().Bool("dry", false, "Do not actually send the campaign") 26 | } 27 | -------------------------------------------------------------------------------- /cmd/cloudx/client/flags.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package client 5 | 6 | import ( 7 | "github.com/spf13/pflag" 8 | ) 9 | 10 | const ( 11 | FlagWorkspace = "workspace" 12 | FlagProject = "project" 13 | FlagYes = "yes" 14 | ) 15 | 16 | func RegisterWorkspaceFlag(f *pflag.FlagSet) { 17 | f.String(FlagWorkspace, "", "The workspace to use, either workspace ID or a (partial) name.") 18 | } 19 | 20 | func RegisterProjectFlag(f *pflag.FlagSet) { 21 | f.String(FlagProject, "", "The project to use, either project ID or a (partial) slug.") 22 | } 23 | 24 | func RegisterYesFlag(f *pflag.FlagSet) { 25 | f.BoolP(FlagYes, FlagYes[:1], false, "Confirm all dialogs with yes.") 26 | } 27 | -------------------------------------------------------------------------------- /cmd/cloudx/use.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2022 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package cloudx 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | 9 | "github.com/ory/cli/cmd/cloudx/client" 10 | "github.com/ory/cli/cmd/cloudx/project" 11 | "github.com/ory/x/cmdx" 12 | ) 13 | 14 | func NewUseCmd() *cobra.Command { 15 | cmd := &cobra.Command{ 16 | Use: "use", 17 | Short: "Use a resource", 18 | } 19 | 20 | cmd.AddCommand( 21 | project.NewUseProjectCmd(), 22 | ) 23 | 24 | client.RegisterConfigFlag(cmd.PersistentFlags()) 25 | client.RegisterYesFlag(cmd.PersistentFlags()) 26 | cmdx.RegisterNoiseFlags(cmd.PersistentFlags()) 27 | cmdx.RegisterJSONFormatFlags(cmd.PersistentFlags()) 28 | 29 | return cmd 30 | } 31 | -------------------------------------------------------------------------------- /cmd/cloudx/introspect.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package cloudx 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | 9 | "github.com/ory/cli/cmd/cloudx/client" 10 | 11 | "github.com/ory/cli/cmd/cloudx/oauth2" 12 | "github.com/ory/x/cmdx" 13 | ) 14 | 15 | func NewIntrospectCmd() *cobra.Command { 16 | cmd := &cobra.Command{ 17 | Use: "introspect", 18 | Short: "Introspect resources", 19 | } 20 | cmd.AddCommand(oauth2.NewIntrospectToken()) 21 | 22 | client.RegisterConfigFlag(cmd.PersistentFlags()) 23 | client.RegisterYesFlag(cmd.PersistentFlags()) 24 | cmdx.RegisterHTTPClientFlags(cmd.PersistentFlags()) 25 | cmdx.RegisterFormatFlags(cmd.PersistentFlags()) 26 | return cmd 27 | } 28 | -------------------------------------------------------------------------------- /cmd/cloudx/parse.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package cloudx 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | 9 | "github.com/ory/cli/cmd/cloudx/client" 10 | "github.com/ory/cli/cmd/cloudx/relationtuples" 11 | "github.com/ory/x/cmdx" 12 | ) 13 | 14 | func NewParseCmd() *cobra.Command { 15 | cmd := &cobra.Command{ 16 | Use: "parse", 17 | Short: "Parse Ory Network resources", 18 | } 19 | cmd.AddCommand(relationtuples.NewParseCmd()) 20 | 21 | client.RegisterConfigFlag(cmd.PersistentFlags()) 22 | client.RegisterYesFlag(cmd.PersistentFlags()) 23 | cmdx.RegisterNoiseFlags(cmd.PersistentFlags()) 24 | cmdx.RegisterJSONFormatFlags(cmd.PersistentFlags()) 25 | 26 | return cmd 27 | } 28 | -------------------------------------------------------------------------------- /cmd/cloudx/validate.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package cloudx 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | 9 | "github.com/ory/cli/cmd/cloudx/client" 10 | "github.com/ory/kratos/cmd/identities" 11 | "github.com/ory/x/cmdx" 12 | ) 13 | 14 | func NewValidateCmd() *cobra.Command { 15 | cmd := &cobra.Command{ 16 | Use: "validate", 17 | Short: "Validate resources", 18 | } 19 | 20 | cmd.AddCommand(identities.NewValidateIdentityCmd()) 21 | 22 | client.RegisterConfigFlag(cmd.PersistentFlags()) 23 | client.RegisterYesFlag(cmd.PersistentFlags()) 24 | cmdx.RegisterNoiseFlags(cmd.PersistentFlags()) 25 | cmdx.RegisterJSONFormatFlags(cmd.PersistentFlags()) 26 | return cmd 27 | } 28 | -------------------------------------------------------------------------------- /cmd/cloudx/is.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package cloudx 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | 9 | "github.com/ory/cli/cmd/cloudx/client" 10 | "github.com/ory/cli/cmd/cloudx/relationtuples" 11 | "github.com/ory/x/cmdx" 12 | ) 13 | 14 | func NewIsCmd() *cobra.Command { 15 | cmd := &cobra.Command{ 16 | Use: "is", 17 | Short: "Assert the state of Ory Network resources", 18 | } 19 | cmd.AddCommand(relationtuples.NewAllowedCmd()) 20 | 21 | client.RegisterConfigFlag(cmd.PersistentFlags()) 22 | client.RegisterYesFlag(cmd.PersistentFlags()) 23 | cmdx.RegisterNoiseFlags(cmd.PersistentFlags()) 24 | cmdx.RegisterJSONFormatFlags(cmd.PersistentFlags()) 25 | 26 | return cmd 27 | } 28 | -------------------------------------------------------------------------------- /cmd/cloudx/perform.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package cloudx 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | 9 | "github.com/ory/cli/cmd/cloudx/oauth2" 10 | 11 | "github.com/ory/cli/cmd/cloudx/client" 12 | "github.com/ory/x/cmdx" 13 | ) 14 | 15 | func NewPerformCmd() *cobra.Command { 16 | cmd := &cobra.Command{ 17 | Use: "perform", 18 | Short: "Perform a flow", 19 | } 20 | 21 | cmd.AddCommand( 22 | oauth2.NewPerformAuthorizationCode(), 23 | oauth2.NewPerformClientCredentials(), 24 | ) 25 | 26 | client.RegisterConfigFlag(cmd.PersistentFlags()) 27 | client.RegisterYesFlag(cmd.PersistentFlags()) 28 | cmdx.RegisterNoiseFlags(cmd.PersistentFlags()) 29 | 30 | return cmd 31 | } 32 | -------------------------------------------------------------------------------- /.github/workflows/labels.yml: -------------------------------------------------------------------------------- 1 | # AUTO-GENERATED, DO NOT EDIT! 2 | # Please edit the original at https://github.com/ory/meta/blob/master/templates/repository/common/.github/workflows/labels.yml 3 | 4 | name: Synchronize Issue Labels 5 | 6 | on: 7 | workflow_dispatch: 8 | push: 9 | branches: 10 | - master 11 | 12 | jobs: 13 | milestone: 14 | if: github.repository_owner == 'ory' 15 | name: Synchronize Issue Labels 16 | runs-on: ubuntu-latest 17 | steps: 18 | - name: Checkout 19 | uses: actions/checkout@v2 20 | - name: Synchronize Issue Labels 21 | uses: ory/label-sync-action@v0 22 | with: 23 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 24 | dry: false 25 | forced: true 26 | -------------------------------------------------------------------------------- /cmd/cloudx/open.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package cloudx 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | 9 | "github.com/ory/cli/cmd/cloudx/accountexperience" 10 | "github.com/ory/cli/cmd/cloudx/client" 11 | "github.com/ory/x/cmdx" 12 | ) 13 | 14 | func NewOpenCmd() *cobra.Command { 15 | cmd := &cobra.Command{ 16 | Use: "open", 17 | Short: "Open Ory Account Experience Pages", 18 | } 19 | cmd.AddCommand(accountexperience.NewAccountExperienceOpenCmd()) 20 | client.RegisterProjectFlag(cmd.PersistentFlags()) 21 | client.RegisterConfigFlag(cmd.PersistentFlags()) 22 | cmdx.RegisterNoiseFlags(cmd.PersistentFlags()) 23 | client.RegisterYesFlag(cmd.PersistentFlags()) 24 | 25 | return cmd 26 | } 27 | -------------------------------------------------------------------------------- /cmd/pkg/github.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package pkg 5 | 6 | import ( 7 | "os" 8 | "strings" 9 | 10 | "github.com/ory/x/stringsx" 11 | ) 12 | 13 | func GitHubSHA() string { 14 | gitHash := stringsx.Coalesce( 15 | os.Getenv("CIRCLE_SHA1"), 16 | os.Getenv("GITHUB_SHA"), 17 | strings.TrimSpace(CommandGetOutput("git", "rev-parse", "HEAD")), 18 | ) 19 | return gitHash 20 | } 21 | 22 | func GitHubTag() string { 23 | var ghTag string 24 | if os.Getenv("GITHUB_REF_TYPE") == "tag" { 25 | ghTag = os.Getenv("GITHUB_REF_NAME") 26 | } 27 | 28 | tag := stringsx.Coalesce( 29 | os.Getenv("CIRCLE_TAG"), 30 | ghTag, 31 | strings.TrimSpace(CommandGetOutput("git", "tag", "--points-at", "HEAD")), 32 | ) 33 | return tag 34 | } 35 | -------------------------------------------------------------------------------- /cmd/cloudx/project/main_test.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package project_test 5 | 6 | import ( 7 | "context" 8 | "fmt" 9 | "testing" 10 | 11 | cloud "github.com/ory/client-go" 12 | 13 | "github.com/ory/cli/cmd/cloudx/testhelpers" 14 | "github.com/ory/x/cmdx" 15 | ) 16 | 17 | var ( 18 | ctx context.Context 19 | defaultProject, extraProject *cloud.Project 20 | defaultConfig, defaultWorkspaceID string 21 | defaultCmd *cmdx.CommandExecuter 22 | ) 23 | 24 | func TestMain(m *testing.M) { 25 | ctx, defaultConfig, defaultWorkspaceID, extraProject, defaultProject, defaultCmd = testhelpers.CreateDefaultAssetsBrowser() 26 | fmt.Println("done setting up, running tests") 27 | m.Run() 28 | } 29 | -------------------------------------------------------------------------------- /cmd/cloudx/logout.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package cloudx 5 | 6 | import ( 7 | "fmt" 8 | 9 | "github.com/ory/cli/cmd/cloudx/client" 10 | 11 | "github.com/spf13/cobra" 12 | ) 13 | 14 | func NewLogoutCmd() *cobra.Command { 15 | cmd := &cobra.Command{ 16 | Use: "logout", 17 | Short: "Signs you out of your account on this computer.", 18 | RunE: func(cmd *cobra.Command, args []string) error { 19 | h, err := client.NewCobraCommandHelper(cmd) 20 | if err != nil { 21 | return err 22 | } 23 | if err := h.SignOut(cmd.Context()); err != nil { 24 | return err 25 | } 26 | fmt.Println("You signed out successfully.") 27 | return nil 28 | }, 29 | } 30 | client.RegisterConfigFlag(cmd.PersistentFlags()) 31 | return cmd 32 | } 33 | -------------------------------------------------------------------------------- /cmd/dev/swagger/sanitize_test.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package swagger 5 | 6 | import ( 7 | "os" 8 | "path/filepath" 9 | "testing" 10 | 11 | "github.com/gofrs/uuid" 12 | "github.com/stretchr/testify/assert" 13 | "github.com/stretchr/testify/require" 14 | ) 15 | 16 | func TestSanitize(t *testing.T) { 17 | fp := filepath.Join(os.TempDir(), uuid.Must(uuid.NewV4()).String()+".json") 18 | 19 | require.NoError(t, sanitize("stub/in.json", fp)) 20 | 21 | actual, err := os.ReadFile(fp) 22 | require.NoError(t, err) 23 | 24 | expected, err := os.ReadFile("stub/expected.json") 25 | require.NoError(t, err) 26 | 27 | require.NotEmpty(t, actual) 28 | require.NotEmpty(t, expected) 29 | 30 | assert.JSONEq(t, string(expected), string(actual), fp) 31 | } 32 | -------------------------------------------------------------------------------- /npm/index.js: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | var binwrap = require("binwrap") 5 | var path = require("path") 6 | 7 | var packageInfo = require(path.join(__dirname, "..", "package.json")) 8 | var version = packageInfo.version 9 | var root = "https://github.com/ory/cli/releases/download/v" + version 10 | 11 | module.exports = binwrap({ 12 | dirname: __dirname, 13 | binaries: ["ory"], 14 | urls: { 15 | "linux-x64": root + "/ory_" + version + "-linux_64bit.tar.gz", 16 | "linux-arm64": root + "/ory_" + version + "-linux_arm64.tar.gz", 17 | "win32-x64": root + "/ory_" + version + "-windows_64bit.zip", 18 | "darwin-x64": root + "/ory_" + version + "-macOS_64bit.tar.gz", 19 | "darwin-arm64": root + "/ory_" + version + "-macOS_arm64.tar.gz", 20 | }, 21 | }) 22 | -------------------------------------------------------------------------------- /cmd/cloudx/e2e/root.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package main 5 | 6 | import ( 7 | "context" 8 | "fmt" 9 | "os" 10 | 11 | "github.com/pkg/errors" 12 | "github.com/spf13/cobra" 13 | 14 | "github.com/ory/cli/cmd/cloudx/proxy" 15 | "github.com/ory/x/cmdx" 16 | ) 17 | 18 | func NewRootCmd() *cobra.Command { 19 | c := &cobra.Command{ 20 | Use: "ory", 21 | Short: "The ORY CLI", 22 | } 23 | 24 | c.AddCommand( 25 | proxy.NewProxyCommand(), 26 | proxy.NewTunnelCommand(), 27 | ) 28 | 29 | return c 30 | } 31 | 32 | func main() { 33 | rootCmd := NewRootCmd() 34 | if err := rootCmd.ExecuteContext(context.Background()); err != nil { 35 | if !errors.Is(err, cmdx.ErrNoPrintButFail) { 36 | _, _ = fmt.Fprintln(rootCmd.ErrOrStderr(), err) 37 | } 38 | os.Exit(1) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /cypress/support/index.js: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // *********************************************************** 5 | // This example support/index.js is processed and 6 | // loaded automatically before your test files. 7 | // 8 | // This is a great place to put global configuration and 9 | // behavior that modifies Cypress. 10 | // 11 | // You can change the location of this file or turn off 12 | // automatically serving support files with the 13 | // 'supportFile' configuration option. 14 | // 15 | // You can read more here: 16 | // https://on.cypress.io/configuration 17 | // *********************************************************** 18 | 19 | // Import commands.js using ES2015 syntax: 20 | import "./commands" 21 | 22 | // Alternatively you can use CommonJS syntax: 23 | // require('./commands') 24 | -------------------------------------------------------------------------------- /cmd/cloudx/e2e/cypress/support/index.js: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // *********************************************************** 5 | // This example support/index.js is processed and 6 | // loaded automatically before your test files. 7 | // 8 | // This is a great place to put global configuration and 9 | // behavior that modifies Cypress. 10 | // 11 | // You can change the location of this file or turn off 12 | // automatically serving support files with the 13 | // 'supportFile' configuration option. 14 | // 15 | // You can read more here: 16 | // https://on.cypress.io/configuration 17 | // *********************************************************** 18 | 19 | // Import commands.js using ES2015 syntax: 20 | import "./commands" 21 | 22 | // Alternatively you can use CommonJS syntax: 23 | // require('./commands') 24 | -------------------------------------------------------------------------------- /cmd/cloudx/import.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package cloudx 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | 9 | "github.com/ory/cli/cmd/cloudx/oauth2" 10 | 11 | "github.com/ory/cli/cmd/cloudx/client" 12 | "github.com/ory/cli/cmd/cloudx/identity" 13 | "github.com/ory/x/cmdx" 14 | ) 15 | 16 | func NewImportCmd() *cobra.Command { 17 | cmd := &cobra.Command{ 18 | Use: "import", 19 | Short: "Import resources", 20 | } 21 | 22 | cmd.AddCommand( 23 | identity.NewImportIdentityCmd(), 24 | oauth2.NewImportOAuth2Client(), 25 | oauth2.NewImportJWK(), 26 | ) 27 | 28 | client.RegisterConfigFlag(cmd.PersistentFlags()) 29 | client.RegisterYesFlag(cmd.PersistentFlags()) 30 | cmdx.RegisterNoiseFlags(cmd.PersistentFlags()) 31 | cmdx.RegisterJSONFormatFlags(cmd.PersistentFlags()) 32 | return cmd 33 | } 34 | -------------------------------------------------------------------------------- /cmd/cloudx/workspace/list.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package workspace 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | 9 | "github.com/ory/cli/cmd/cloudx/client" 10 | "github.com/ory/x/cmdx" 11 | ) 12 | 13 | func NewListCmd() *cobra.Command { 14 | return &cobra.Command{ 15 | Use: "workspaces", 16 | Aliases: []string{"workspace", "ws"}, 17 | Short: "List Ory Network workspaces", 18 | Args: cobra.NoArgs, 19 | RunE: func(cmd *cobra.Command, _ []string) error { 20 | h, err := client.NewCobraCommandHelper(cmd) 21 | if err != nil { 22 | return err 23 | } 24 | 25 | workspaces, err := h.ListWorkspaces(cmd.Context()) 26 | if err != nil { 27 | return err 28 | } 29 | 30 | cmdx.PrintTable(cmd, (outputWorkspaces)(workspaces)) 31 | return nil 32 | }, 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /cmd/cloudx/oauth2/client.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package oauth2 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | 9 | hydra "github.com/ory/hydra/v2/cmd" 10 | ) 11 | 12 | func NewCreateOAuth2Client() *cobra.Command { 13 | return wrapHydraCmd(hydra.NewCreateClientsCommand) 14 | } 15 | 16 | func NewDeleteOAuth2Client() *cobra.Command { 17 | return wrapHydraCmd(hydra.NewDeleteClientCmd) 18 | } 19 | 20 | func NewGetOAuth2Client() *cobra.Command { 21 | return wrapHydraCmd(hydra.NewGetClientsCmd) 22 | } 23 | 24 | func NewImportOAuth2Client() *cobra.Command { 25 | return wrapHydraCmd(hydra.NewImportClientCmd) 26 | } 27 | 28 | func NewListOAuth2Clients() *cobra.Command { 29 | return wrapHydraCmd(hydra.NewListClientsCmd) 30 | } 31 | 32 | func NewUpdateOAuth2Client() *cobra.Command { 33 | return wrapHydraCmd(hydra.NewUpdateClientCmd) 34 | } 35 | -------------------------------------------------------------------------------- /cmd/cloudx/project/list.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package project 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | 9 | "github.com/ory/cli/cmd/cloudx/client" 10 | "github.com/ory/x/cmdx" 11 | ) 12 | 13 | func NewListProjectsCmd() *cobra.Command { 14 | cmd := &cobra.Command{ 15 | Use: "projects", 16 | Short: "List your Ory Network projects.", 17 | RunE: func(cmd *cobra.Command, args []string) error { 18 | h, err := client.NewCobraCommandHelper(cmd) 19 | if err != nil { 20 | return err 21 | } 22 | 23 | projects, err := h.ListProjects(cmd.Context(), h.WorkspaceID()) 24 | if err != nil { 25 | return cmdx.PrintOpenAPIError(cmd, err) 26 | } 27 | 28 | cmdx.PrintTable(cmd, &outputProjectCollection{projects}) 29 | return nil 30 | }, 31 | } 32 | client.RegisterWorkspaceFlag(cmd.Flags()) 33 | 34 | return cmd 35 | } 36 | -------------------------------------------------------------------------------- /cmd/cloudx/workspace/get.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package workspace 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | 9 | "github.com/ory/cli/cmd/cloudx/client" 10 | "github.com/ory/x/cmdx" 11 | ) 12 | 13 | func NewGetCmd() *cobra.Command { 14 | cmd := &cobra.Command{ 15 | Use: "workspace ", 16 | Aliases: []string{"workspaces", "ws"}, 17 | Short: "Get an Ory Network workspaces", 18 | Args: cobra.ExactArgs(1), 19 | RunE: func(cmd *cobra.Command, args []string) error { 20 | h, err := client.NewCobraCommandHelper(cmd) 21 | if err != nil { 22 | return err 23 | } 24 | 25 | workspace, err := h.GetWorkspace(cmd.Context(), args[0]) 26 | if err != nil { 27 | return err 28 | } 29 | 30 | cmdx.PrintRow(cmd, (*outputWorkspace)(workspace)) 31 | return nil 32 | }, 33 | } 34 | cmdx.RegisterFormatFlags(cmd.Flags()) 35 | return cmd 36 | } 37 | -------------------------------------------------------------------------------- /.github/workflows/test-integration.yaml: -------------------------------------------------------------------------------- 1 | name: dogfood integration test 2 | on: 3 | workflow_dispatch: 4 | pull_request: 5 | push: 6 | branches: 7 | - main 8 | - master 9 | 10 | env: 11 | # project & workspace are managed in Ory Cloud tech integration workspace. 12 | ORY_PROJECT_ID: "3b188173-833c-4074-995c-9085a72c8112" 13 | ORY_WORKSPACE_ID: "f77d4982-46f1-42cd-8d02-8bccfa54f8f7" 14 | ORY_WORKSPACE_API_KEY: ${{ secrets.ORY_WORKSPACE_API_KEY }} 15 | 16 | jobs: 17 | gha: 18 | runs-on: ubuntu-latest 19 | container: 20 | image: oryd/ory:v1.1.0 21 | # temporary until we release new image 22 | options: --user root 23 | steps: 24 | - name: checkout 25 | uses: actions/checkout@v4 26 | # temporary until we release new image 27 | - name: add bash 28 | run: apk add bash 29 | - name: Check integration 30 | run: ory get project ${{ env.ORY_PROJECT_ID }} 31 | -------------------------------------------------------------------------------- /cmd/pkg/cli.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package pkg 5 | 6 | import ( 7 | "fmt" 8 | "os" 9 | "runtime/debug" 10 | ) 11 | 12 | func Check(err error, args ...interface{}) { 13 | if err == nil { 14 | return 15 | } 16 | 17 | if len(args) == 0 { 18 | Fatalf("An unexpected error occurred: %+v", err) 19 | } 20 | 21 | if len(args) == 1 { 22 | Fatalf("%s", args[0]) 23 | } 24 | 25 | Fatalf(fmt.Sprintf("%s", args[0]), args[1:]...) 26 | } 27 | 28 | func MustGetEnv(key string) (v string) { 29 | v = os.Getenv(key) 30 | if len(v) == 0 { 31 | Fatalf(`Environment variable "%s" must be set.`, key) 32 | } 33 | return 34 | } 35 | 36 | func Fatalf(message string, args ...interface{}) { 37 | _, _ = fmt.Fprintf(os.Stderr, message+"\n", args...) 38 | if os.Getenv("LOG_LEVEL") == "trace" { 39 | _, _ = fmt.Fprintf(os.Stderr, "Stack trace: %s\n", debug.Stack()) 40 | } 41 | os.Exit(1) 42 | } 43 | -------------------------------------------------------------------------------- /.docker/Dockerfile-build: -------------------------------------------------------------------------------- 1 | FROM golang:1.24-alpine3.22 AS builder 2 | 3 | RUN apk -U --no-cache add build-base git gcc bash 4 | 5 | WORKDIR /go/src/github.com/ory/cli 6 | 7 | ADD ./go.mod go.mod 8 | ADD ./go.sum go.sum 9 | 10 | ENV GO111MODULE=on 11 | ENV CGO_ENABLED=1 12 | 13 | RUN go mod download 14 | 15 | ADD . . 16 | 17 | RUN CGO_CFLAGS="-D_LARGEFILE64_SOURCE" go build -tags sqlite,json1 -o /usr/bin/ory 18 | 19 | FROM alpine:3.22 20 | 21 | RUN apk add -U --no-cache ca-certificates bash 22 | RUN apk upgrade --no-cache libssl3 libcrypto3 23 | 24 | RUN addgroup -S ory; \ 25 | adduser -S ory -G ory -D -h /home/ory -s /bin/nologin; \ 26 | chown -R ory:ory /home/ory 27 | 28 | COPY --from=builder /usr/bin/ory /usr/bin/ory 29 | 30 | # Exposing the ory home directory to simplify passing in Kratos configuration (e.g. if the file $HOME/.kratos.yaml 31 | # exists, it will be automatically used as the configuration file). 32 | VOLUME /home/ory 33 | 34 | USER ory 35 | 36 | ENTRYPOINT ["ory"] 37 | -------------------------------------------------------------------------------- /cmd/dev/main.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package dev 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | 9 | "github.com/ory/cli/cmd/dev/ci" 10 | "github.com/ory/cli/cmd/dev/headers" 11 | "github.com/ory/cli/cmd/dev/markdown" 12 | "github.com/ory/cli/cmd/dev/newsletter" 13 | "github.com/ory/cli/cmd/dev/openapi" 14 | "github.com/ory/cli/cmd/dev/release" 15 | "github.com/ory/cli/cmd/dev/schema" 16 | "github.com/ory/cli/cmd/dev/swagger" 17 | ) 18 | 19 | var Main = &cobra.Command{ 20 | Use: "dev", 21 | Short: "Developer tools for writing Ory software", 22 | Long: `Developer tools and convenience functions for writing Ory software. 23 | Please check the individual commands for more information!`, 24 | Hidden: true, 25 | } 26 | 27 | func init() { 28 | Main.AddCommand( 29 | newsletter.Main, 30 | markdown.Main, 31 | release.Main, 32 | swagger.Main, 33 | ci.Main, 34 | schema.Main, 35 | openapi.Main, 36 | headers.Main, 37 | ) 38 | } 39 | -------------------------------------------------------------------------------- /cmd/cloudx/project/fixtures/update-kratos/fail/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "courier": { 3 | "smtp": { 4 | "from_name": "Updated Project from JSON via Ory" 5 | }, 6 | "templates": { 7 | "recovery": { 8 | "invalid": { 9 | "email": {} 10 | }, 11 | "valid": { 12 | "email": {} 13 | } 14 | }, 15 | "verification": { 16 | "invalid": { 17 | "email": {} 18 | }, 19 | "valid": { 20 | "email": {} 21 | } 22 | } 23 | } 24 | }, 25 | "session": { 26 | "lifespan": "72h0m0s", 27 | "cookie": { 28 | "domain": "upbeat-mclean-xjvqxk4i7e.projects.oryapis", 29 | "name": "ory_session_upbeatmcleanxjvqxk4i7e", 30 | "path": "/", 31 | "same_site": "Lax" 32 | }, 33 | "whoami": { 34 | "required_aal": "aal1" 35 | } 36 | }, 37 | "identity": { 38 | "schemas": [] 39 | }, 40 | "selfservice": { 41 | "default_browser_return_url": "/" 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /cmd/cloudx/auth.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package cloudx 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | 9 | "github.com/ory/cli/cmd/cloudx/client" 10 | "github.com/ory/x/cmdx" 11 | ) 12 | 13 | func NewAuthCmd() *cobra.Command { 14 | cmd := &cobra.Command{ 15 | Use: "auth", 16 | Short: "Create a new Ory Network account or sign in to an existing account.", 17 | RunE: func(cmd *cobra.Command, args []string) error { 18 | h, err := client.NewCobraCommandHelper(cmd) 19 | if err != nil { 20 | return err 21 | } 22 | 23 | ac, err := h.GetAuthenticatedConfig(cmd.Context()) 24 | if err != nil { 25 | return err 26 | } 27 | 28 | cmdx.PrintRow(cmd, ac) 29 | return nil 30 | }, 31 | } 32 | client.RegisterConfigFlag(cmd.PersistentFlags()) 33 | client.RegisterYesFlag(cmd.PersistentFlags()) 34 | cmdx.RegisterNoiseFlags(cmd.PersistentFlags()) 35 | cmdx.RegisterFormatFlags(cmd.Flags()) 36 | cmd.AddCommand(NewLogoutCmd()) 37 | return cmd 38 | } 39 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@ory/cli", 3 | "version": "0.0.85", 4 | "main": "npm/index.js", 5 | "bin": { 6 | "ory": "bin/ory" 7 | }, 8 | "files": [ 9 | "npm/index.js", 10 | "bin" 11 | ], 12 | "scripts": { 13 | "install": "binwrap-install", 14 | "prepare": "binwrap-prepare", 15 | "test": "npm-run-all test:cypress test:binwrap", 16 | "test:cypress": "cypress run", 17 | "test:binwrap": "binwrap-test", 18 | "test:cypress:dev": "cypress open", 19 | "prepublishOnly": "npm run test:binwrap" 20 | }, 21 | "prettier": "ory-prettier-styles", 22 | "dependencies": { 23 | "binwrap": "^0.2.3" 24 | }, 25 | "devDependencies": { 26 | "cypress": "^8.7.0", 27 | "jsonwebtoken": "^9.0.2", 28 | "jwks-rsa": "^2.0.5", 29 | "license-checker": "^25.0.1", 30 | "npm-run-all": "^4.1.5", 31 | "ory-prettier-styles": "1.3.0", 32 | "prettier": "2.7.1", 33 | "prettier-plugin-packagejson": "^2.2.18" 34 | }, 35 | "overrides": { 36 | "form-data": "^2.5.4" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /.github/workflows/closed_references.yml: -------------------------------------------------------------------------------- 1 | # AUTO-GENERATED, DO NOT EDIT! 2 | # Please edit the original at https://github.com/ory/meta/blob/master/templates/repository/common/.github/workflows/closed_references.yml 3 | 4 | name: Closed Reference Notifier 5 | 6 | on: 7 | schedule: 8 | - cron: "0 0 * * *" 9 | workflow_dispatch: 10 | inputs: 11 | issueLimit: 12 | description: Max. number of issues to create 13 | required: true 14 | default: "5" 15 | 16 | jobs: 17 | find_closed_references: 18 | if: github.repository_owner == 'ory' 19 | runs-on: ubuntu-latest 20 | name: Find closed references 21 | steps: 22 | - uses: actions/checkout@v2 23 | - uses: actions/setup-node@v2-beta 24 | with: 25 | node-version: "14" 26 | - uses: ory/closed-reference-notifier@v1 27 | with: 28 | token: ${{ secrets.GITHUB_TOKEN }} 29 | issueLabels: upstream,good first issue,help wanted 30 | issueLimit: ${{ github.event.inputs.issueLimit || '5' }} 31 | -------------------------------------------------------------------------------- /cmd/cloudx/oauth2/jwks.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package oauth2 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | 9 | "github.com/ory/kratos/cmd/cliclient" 10 | 11 | "github.com/ory/cli/cmd/cloudx/client" 12 | hydra "github.com/ory/hydra/v2/cmd" 13 | "github.com/ory/x/cmdx" 14 | ) 15 | 16 | func wrapHydraCmd(newCmd func() *cobra.Command) *cobra.Command { 17 | c := newCmd() 18 | client.RegisterProjectFlag(c.Flags()) 19 | client.RegisterWorkspaceFlag(c.Flags()) 20 | cmdx.RegisterFormatFlags(c.Flags()) 21 | cliclient.RegisterClientFlags(c.Flags()) 22 | return c 23 | } 24 | 25 | func NewGetJWK() *cobra.Command { 26 | return wrapHydraCmd(hydra.NewGetJWKSCmd) 27 | } 28 | 29 | func NewImportJWK() *cobra.Command { 30 | return wrapHydraCmd(hydra.NewKeysImportCmd) 31 | } 32 | 33 | func NewCreateJWK() *cobra.Command { 34 | return wrapHydraCmd(hydra.NewCreateJWKSCmd) 35 | } 36 | 37 | func NewDeleteJWKs() *cobra.Command { 38 | return wrapHydraCmd(hydra.NewDeleteJWKSCommand) 39 | } 40 | -------------------------------------------------------------------------------- /cypress/support/commands.js: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // *********************************************** 5 | // This example commands.js shows you how to 6 | // create various custom commands and overwrite 7 | // existing commands. 8 | // 9 | // For more comprehensive examples of custom 10 | // commands please read more here: 11 | // https://on.cypress.io/custom-commands 12 | // *********************************************** 13 | // 14 | // 15 | // -- This is a parent command -- 16 | // Cypress.Commands.add('login', (email, password) => { ... }) 17 | // 18 | // 19 | // -- This is a child command -- 20 | // Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... }) 21 | // 22 | // 23 | // -- This is a dual command -- 24 | // Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... }) 25 | // 26 | // 27 | // -- This will overwrite an existing command -- 28 | // Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) 29 | -------------------------------------------------------------------------------- /cmd/cloudx/relationtuples/permissions_test.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package relationtuples_test 5 | 6 | import ( 7 | "context" 8 | "testing" 9 | 10 | "github.com/stretchr/testify/require" 11 | 12 | "github.com/ory/cli/cmd/cloudx/client" 13 | "github.com/ory/cli/cmd/cloudx/testhelpers" 14 | ) 15 | 16 | func TestIsAllowedNoUnauthenticated(t *testing.T) { 17 | t.Parallel() 18 | 19 | cmd := testhelpers.Cmd(testhelpers.WithEmitAuthFlowTriggeredErr(context.Background(), t)) 20 | 21 | // with quiet flag 22 | _, _, err := cmd.Exec(nil, 23 | "is", "allowed", "user", "relation", "namespace", "object", 24 | "--quiet", "--project", defaultProject.Id) 25 | require.ErrorIsf(t, err, client.ErrNoConfigQuiet, "got error: %v", err) 26 | 27 | // without quiet flag 28 | _, _, err = cmd.Exec(nil, 29 | "is", "allowed", "user", "relation", "namespace", "object", 30 | "--project", defaultProject.Id) 31 | require.ErrorIsf(t, err, testhelpers.ErrAuthFlowTriggered, "got error: %v", err) 32 | } 33 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ORY CLI 2 | 3 | [![CI test status](https://github.com/ory/cli/actions/workflows/test.yml/badge.svg)](https://github.com/ory/cli/actions/workflows/test.yml) 4 | [![CI end-to-end test status](https://github.com/ory/cli/actions/workflows/test-e2e.yml/badge.svg)](https://github.com/ory/cli/actions/workflows/test-e2e.yml) 5 | 6 | This is the ORY Command Line Interface (CLI). 7 | 8 | ## Unix (Linux / macOS) 9 | 10 | ```shell-session 11 | $ curl https://raw.githubusercontent.com/ory/meta/master/install.sh | sh -s ory 12 | $ ory help 13 | ``` 14 | 15 | ## macOS 16 | 17 | ```shell-session 18 | $ brew install ory/tap/cli 19 | $ ory help 20 | ``` 21 | 22 | ## Releases 23 | 24 | You can find all release binaries in at 25 | [releases](https://github.com/ory/cli/releases). 26 | 27 | ## Development Toolchain 28 | 29 | The ORY development toolchain helps you with tasks that need to be done 30 | regularly when developing ORY technology. 31 | 32 | For help on available commands (e.g. creating fizz migrations) check 33 | 34 | ``` 35 | $ ory help dev 36 | ``` 37 | -------------------------------------------------------------------------------- /cmd/cloudx/e2e/cypress/support/commands.js: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // *********************************************** 5 | // This example commands.js shows you how to 6 | // create various custom commands and overwrite 7 | // existing commands. 8 | // 9 | // For more comprehensive examples of custom 10 | // commands please read more here: 11 | // https://on.cypress.io/custom-commands 12 | // *********************************************** 13 | // 14 | // 15 | // -- This is a parent command -- 16 | // Cypress.Commands.add('login', (email, password) => { ... }) 17 | // 18 | // 19 | // -- This is a child command -- 20 | // Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... }) 21 | // 22 | // 23 | // -- This is a dual command -- 24 | // Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... }) 25 | // 26 | // 27 | // -- This will overwrite an existing command -- 28 | // Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) 29 | -------------------------------------------------------------------------------- /cmd/cloudx/eventstreams/flags.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package eventstreams 5 | 6 | import ( 7 | "fmt" 8 | 9 | "github.com/spf13/pflag" 10 | 11 | "github.com/ory/client-go" 12 | ) 13 | 14 | type streamConfig client.CreateEventStreamBody 15 | 16 | func (c *streamConfig) Validate() error { 17 | switch "" { 18 | case c.Type: 19 | return fmt.Errorf("flag --type must be set") 20 | case c.RoleArn: 21 | return fmt.Errorf("flag --aws-iam-role-arn must be set") 22 | case c.TopicArn: 23 | return fmt.Errorf("flag --aws-sns-topic-arn must be set") 24 | } 25 | return nil 26 | } 27 | 28 | func registerStreamConfigFlags(f *pflag.FlagSet, c *streamConfig) { 29 | f.StringVar(&c.Type, "type", "", `The type of the event stream destination. Only "sns" is supported at the moment.`) 30 | f.StringVar(&c.RoleArn, "aws-iam-role-arn", "", "The ARN of the AWS IAM role to assume when publishing messages to the SNS topic.") 31 | f.StringVar(&c.TopicArn, "aws-sns-topic-arn", "", "The ARN of the AWS SNS topic.") 32 | } 33 | -------------------------------------------------------------------------------- /cmd/cloudx/get.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package cloudx 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | 9 | "github.com/ory/x/cmdx" 10 | 11 | "github.com/ory/cli/cmd/cloudx/client" 12 | "github.com/ory/cli/cmd/cloudx/identity" 13 | "github.com/ory/cli/cmd/cloudx/oauth2" 14 | "github.com/ory/cli/cmd/cloudx/project" 15 | "github.com/ory/cli/cmd/cloudx/workspace" 16 | ) 17 | 18 | func NewGetCmd() *cobra.Command { 19 | cmd := &cobra.Command{ 20 | Use: "get", 21 | Short: "Get a resource", 22 | } 23 | 24 | cmd.AddCommand( 25 | project.NewGetProjectCmd(), 26 | project.NewGetKratosConfigCmd(), 27 | project.NewGetKetoConfigCmd(), 28 | project.NewGetOAuth2ConfigCmd(), 29 | workspace.NewGetCmd(), 30 | identity.NewGetIdentityCmd(), 31 | oauth2.NewGetOAuth2Client(), 32 | oauth2.NewGetJWK(), 33 | ) 34 | 35 | client.RegisterConfigFlag(cmd.PersistentFlags()) 36 | client.RegisterYesFlag(cmd.PersistentFlags()) 37 | cmdx.RegisterNoiseFlags(cmd.PersistentFlags()) 38 | 39 | return cmd 40 | } 41 | -------------------------------------------------------------------------------- /cmd/cloudx/auth_test.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package cloudx_test 5 | 6 | import ( 7 | "context" 8 | "testing" 9 | 10 | "github.com/stretchr/testify/assert" 11 | 12 | "github.com/ory/cli/cmd/cloudx/client" 13 | "github.com/ory/cli/cmd/cloudx/testhelpers" 14 | ) 15 | 16 | func TestAuthenticator(t *testing.T) { 17 | t.Parallel() 18 | 19 | t.Run("errors without config and --quiet flag", func(t *testing.T) { 20 | ctx := testhelpers.WithCleanConfigFile(context.Background(), t) 21 | _, _, err := testhelpers.Cmd(ctx).Exec(nil, "auth", "--quiet") 22 | assert.ErrorIs(t, err, client.ErrNoConfigQuiet) 23 | }) 24 | 25 | t.Run("triggers auth flow when not authenticated", func(t *testing.T) { 26 | ctx := testhelpers.WithEmitAuthFlowTriggeredErr(context.Background(), t) 27 | _, _, err := testhelpers.Cmd(ctx).Exec(nil, "auth") 28 | assert.ErrorIs(t, err, testhelpers.ErrAuthFlowTriggered) 29 | }) 30 | 31 | // the full e2e flow is tested on the internal helper function instead of the full CLI wrapper 32 | } 33 | -------------------------------------------------------------------------------- /cmd/dev/headers/comments/file_type.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package comments 5 | 6 | import "path/filepath" 7 | 8 | // a file format that we know about, represented as its file extension 9 | type FileType string 10 | 11 | // indicates whether the given list of FileTypes contains the given FileType 12 | func ContainsFileType(fileTypes []FileType, fileType FileType) bool { 13 | for _, ft := range fileTypes { 14 | if ft == fileType { 15 | return true 16 | } 17 | } 18 | return false 19 | } 20 | 21 | // provides the extension of the given filepath 22 | func GetFileType(filePath string) FileType { 23 | ext := filepath.Ext(filePath) 24 | if len(ext) > 0 { 25 | ext = ext[1:] 26 | } 27 | if ext == "yaml" { 28 | ext = "yml" 29 | } 30 | return FileType(ext) 31 | } 32 | 33 | // indicates whether it is possible to add comments to the file with the given name 34 | func SupportsFile(filePath string) bool { 35 | filetype := GetFileType(filePath) 36 | _, ok := commentFormats[filetype] 37 | return ok 38 | } 39 | -------------------------------------------------------------------------------- /cmd/cloudx/project/use_test.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2022 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package project_test 5 | 6 | import ( 7 | "strings" 8 | "testing" 9 | 10 | "github.com/stretchr/testify/assert" 11 | "github.com/stretchr/testify/require" 12 | 13 | "github.com/ory/cli/cmd/cloudx/testhelpers" 14 | ) 15 | 16 | func TestUseProject(t *testing.T) { 17 | t.Parallel() 18 | 19 | t.Run("is able to use project", func(t *testing.T) { 20 | t.Parallel() 21 | 22 | ctx, _ := testhelpers.WithDuplicatedConfigFile(ctx, t, defaultConfig) 23 | testhelpers.SetDefaultProject(ctx, t, defaultProject.Id) 24 | 25 | stdout, _, err := testhelpers.Cmd(ctx).Exec(nil, "use", "project", extraProject.Id, "--quiet") 26 | require.NoError(t, err) 27 | assert.Equal(t, extraProject.Id, strings.TrimSpace(stdout)) 28 | }) 29 | 30 | t.Run("is able to print default project", func(t *testing.T) { 31 | t.Parallel() 32 | 33 | stdout, _, err := defaultCmd.Exec(nil, "use", "project", "--quiet") 34 | require.NoError(t, err) 35 | assert.Equal(t, defaultProject.Id, strings.TrimSpace(stdout)) 36 | }) 37 | } 38 | -------------------------------------------------------------------------------- /cmd/cloudx/update.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package cloudx 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | 9 | "github.com/ory/cli/cmd/cloudx/client" 10 | "github.com/ory/cli/cmd/cloudx/eventstreams" 11 | "github.com/ory/cli/cmd/cloudx/oauth2" 12 | "github.com/ory/cli/cmd/cloudx/organizations" 13 | "github.com/ory/cli/cmd/cloudx/project" 14 | "github.com/ory/x/cmdx" 15 | ) 16 | 17 | func NewUpdateCmd() *cobra.Command { 18 | cmd := &cobra.Command{ 19 | Use: "update", 20 | Short: "Update resources", 21 | } 22 | cmd.AddCommand( 23 | project.NewProjectsUpdateCmd(), 24 | project.NewUpdateIdentityConfigCmd(), 25 | project.NewUpdateOAuth2ConfigCmd(), 26 | project.NewUpdatePermissionConfigCmd(), 27 | project.NewUpdateNamespaceConfigCmd(), 28 | oauth2.NewUpdateOAuth2Client(), 29 | organizations.NewUpdateOrganizationCmd(), 30 | eventstreams.NewUpdateEventStreamCmd(), 31 | ) 32 | 33 | client.RegisterConfigFlag(cmd.PersistentFlags()) 34 | client.RegisterYesFlag(cmd.PersistentFlags()) 35 | cmdx.RegisterNoiseFlags(cmd.PersistentFlags()) 36 | 37 | return cmd 38 | } 39 | -------------------------------------------------------------------------------- /cmd/cloudx/eventstreams/list.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package eventstreams 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | 9 | "github.com/ory/cli/cmd/cloudx/client" 10 | "github.com/ory/x/cmdx" 11 | ) 12 | 13 | func NewListEventStreamsCmd() *cobra.Command { 14 | cmd := &cobra.Command{ 15 | Use: "event-streams", 16 | Args: cobra.NoArgs, 17 | Short: "List your event streams", 18 | RunE: func(cmd *cobra.Command, args []string) error { 19 | h, err := client.NewCobraCommandHelper(cmd) 20 | if err != nil { 21 | return err 22 | } 23 | 24 | projectID, err := h.ProjectID() 25 | if err != nil { 26 | return cmdx.PrintOpenAPIError(cmd, err) 27 | } 28 | 29 | streams, err := h.ListEventStreams(cmd.Context(), projectID) 30 | if err != nil { 31 | return cmdx.PrintOpenAPIError(cmd, err) 32 | } 33 | 34 | cmdx.PrintTable(cmd, outputList(*streams)) 35 | return nil 36 | }, 37 | } 38 | 39 | client.RegisterProjectFlag(cmd.Flags()) 40 | client.RegisterWorkspaceFlag(cmd.Flags()) 41 | cmdx.RegisterFormatFlags(cmd.Flags()) 42 | return cmd 43 | } 44 | -------------------------------------------------------------------------------- /cmd/dev/ci/monorepo/main.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package monorepo 5 | 6 | import "github.com/spf13/cobra" 7 | 8 | var rootDirectory string 9 | var verbose bool 10 | var debug bool 11 | var pr string 12 | var revisionRange string 13 | var branch string 14 | 15 | // Main cobra command for monorepo support 16 | var Main = &cobra.Command{ 17 | Use: "monorepo", 18 | Short: "Helpers for CircleCI monorepo support", 19 | } 20 | 21 | func isPR() bool { 22 | return len(pr) > 0 23 | } 24 | 25 | func init() { 26 | Main.PersistentFlags().StringVarP(&rootDirectory, "root", "r", ".", "Root directory to be used to traverse and search for dependency configurations.") 27 | Main.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Verbose output") 28 | Main.PersistentFlags().BoolVarP(&debug, "debug", "d", false, "Debug output") 29 | Main.PersistentFlags().StringVar(&pr, "pr", "", "Pull Request") 30 | Main.PersistentFlags().StringVar(&branch, "branch", "", "Branch") 31 | Main.PersistentFlags().StringVar(&revisionRange, "revisionRange", "", "RevisionRange used to determine changes!") 32 | } 33 | -------------------------------------------------------------------------------- /cmd/dev/release/compile.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package release 5 | 6 | import ( 7 | "fmt" 8 | "os" 9 | "strconv" 10 | 11 | "github.com/spf13/cobra" 12 | 13 | "github.com/ory/cli/cmd/pkg" 14 | "github.com/ory/x/flagx" 15 | ) 16 | 17 | var compile = &cobra.Command{ 18 | Use: "compile", 19 | Args: cobra.ExactArgs(0), 20 | Short: "Compiles the current project using oryd/xgoreleaser a new release", 21 | Run: func(cmd *cobra.Command, args []string) { 22 | wd, err := os.Getwd() 23 | pkg.Check(err) 24 | 25 | pkg.Check(pkg.NewCommand("docker", "run", "--mount", 26 | fmt.Sprintf(`type=bind,source=%s,target=/project`, wd), 27 | "oryd/xgoreleaser:"+flagx.MustGetString(cmd, "tag"), 28 | "--timeout", "60m", 29 | "--skip-publish", "--snapshot", "--rm-dist", "--parallelism", 30 | strconv.Itoa(flagx.MustGetInt(cmd, "parallelism"))).Run()) 31 | }, 32 | } 33 | 34 | func init() { 35 | Main.AddCommand(compile) 36 | compile.Flags().StringP("tag", "t", "1.14.4-0.139.0", "Set the xgoreleaser version tag.") 37 | compile.Flags().IntP("parallelism", "p", 4, "Build parallelism.") 38 | } 39 | -------------------------------------------------------------------------------- /cmd/cloudx/delete.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package cloudx 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | 9 | "github.com/ory/cli/cmd/cloudx/eventstreams" 10 | "github.com/ory/cli/cmd/cloudx/oauth2" 11 | "github.com/ory/cli/cmd/cloudx/organizations" 12 | "github.com/ory/cli/cmd/cloudx/relationtuples" 13 | 14 | "github.com/ory/cli/cmd/cloudx/client" 15 | "github.com/ory/cli/cmd/cloudx/identity" 16 | "github.com/ory/x/cmdx" 17 | ) 18 | 19 | func NewDeleteCmd() *cobra.Command { 20 | cmd := &cobra.Command{ 21 | Use: "delete", 22 | Short: "Delete resources", 23 | } 24 | 25 | cmd.AddCommand( 26 | identity.NewDeleteIdentityCmd(), 27 | oauth2.NewDeleteOAuth2Client(), 28 | oauth2.NewDeleteJWKs(), 29 | oauth2.NewDeleteAccessTokens(), 30 | relationtuples.NewDeleteCmd(), 31 | organizations.NewDeleteOrganizationCmd(), 32 | eventstreams.NewDeleteEventStream(), 33 | ) 34 | 35 | client.RegisterConfigFlag(cmd.PersistentFlags()) 36 | client.RegisterYesFlag(cmd.PersistentFlags()) 37 | cmdx.RegisterNoiseFlags(cmd.PersistentFlags()) 38 | cmdx.RegisterJSONFormatFlags(cmd.PersistentFlags()) 39 | return cmd 40 | } 41 | -------------------------------------------------------------------------------- /cmd/cloudx/organizations/list_organizations.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package organizations 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | 9 | "github.com/ory/cli/cmd/cloudx/client" 10 | "github.com/ory/x/cmdx" 11 | ) 12 | 13 | func NewListOrganizationsCmd() *cobra.Command { 14 | cmd := &cobra.Command{ 15 | Use: "organizations", 16 | Args: cobra.NoArgs, 17 | Short: "List your Ory Network organizations", 18 | RunE: func(cmd *cobra.Command, args []string) error { 19 | h, err := client.NewCobraCommandHelper(cmd) 20 | if err != nil { 21 | return err 22 | } 23 | 24 | projectID, err := h.ProjectID() 25 | if err != nil { 26 | return cmdx.PrintOpenAPIError(cmd, err) 27 | } 28 | 29 | organizations, err := h.ListOrganizations(cmd.Context(), projectID) 30 | if err != nil { 31 | return cmdx.PrintOpenAPIError(cmd, err) 32 | } 33 | 34 | cmdx.PrintTable(cmd, &outputOrganizations{organizations}) 35 | return nil 36 | }, 37 | } 38 | 39 | client.RegisterProjectFlag(cmd.Flags()) 40 | client.RegisterWorkspaceFlag(cmd.Flags()) 41 | cmdx.RegisterFormatFlags(cmd.Flags()) 42 | return cmd 43 | } 44 | -------------------------------------------------------------------------------- /cmd/cloudx/project/fixtures/update/json/identity-schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "https://schemas.ory.sh/presets/kratos/identity.email.schema.json", 3 | "$schema": "http://json-schema.org/draft-07/schema#", 4 | "title": "Person", 5 | "type": "object", 6 | "properties": { 7 | "traits": { 8 | "type": "object", 9 | "properties": { 10 | "email": { 11 | "type": "string", 12 | "format": "email", 13 | "title": "E-Mail", 14 | "ory.sh/kratos": { 15 | "credentials": { 16 | "password": { 17 | "identifier": true 18 | }, 19 | "webauthn": { 20 | "identifier": true 21 | }, 22 | "totp": { 23 | "account_name": true 24 | } 25 | }, 26 | "recovery": { 27 | "via": "email" 28 | }, 29 | "verification": { 30 | "via": "email" 31 | } 32 | }, 33 | "maxLength": 320 34 | } 35 | }, 36 | "required": [ 37 | "email" 38 | ], 39 | "additionalProperties": false 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /cmd/cloudx/client/config_test.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package client_test 5 | 6 | import ( 7 | "bytes" 8 | "context" 9 | "os" 10 | "strings" 11 | "testing" 12 | 13 | "github.com/stretchr/testify/assert" 14 | "github.com/stretchr/testify/require" 15 | 16 | "github.com/ory/cli/cmd/cloudx/client" 17 | "github.com/ory/cli/cmd/cloudx/testhelpers" 18 | ) 19 | 20 | func TestLegacyConfigHandling(t *testing.T) { 21 | ctx := context.Background() 22 | legacyConfigFile := testhelpers.NewConfigFile(t) 23 | require.NoError(t, os.WriteFile(legacyConfigFile, []byte(`{"version": "v0alpha0"}`), 0600)) 24 | 25 | out := bytes.Buffer{} 26 | h, err := client.NewCommandHelper( 27 | ctx, 28 | client.WithConfigLocation(legacyConfigFile), 29 | client.WithOpenBrowserHook(func(string) error { 30 | return testhelpers.ErrAuthFlowTriggered 31 | }), 32 | client.WithVerboseErrWriter(&out), 33 | client.WithStdin(strings.NewReader("\n")), 34 | ) 35 | require.NoError(t, err) 36 | 37 | _, err = h.GetAuthenticatedConfig(ctx) 38 | assert.ErrorIs(t, err, testhelpers.ErrAuthFlowTriggered) 39 | assert.Contains(t, out.String(), "Thanks for upgrading!") 40 | } 41 | -------------------------------------------------------------------------------- /cmd/cloudx/eventstreams/delete.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package eventstreams 5 | 6 | import ( 7 | "fmt" 8 | 9 | "github.com/spf13/cobra" 10 | 11 | "github.com/ory/cli/cmd/cloudx/client" 12 | "github.com/ory/x/cmdx" 13 | ) 14 | 15 | func NewDeleteEventStream() *cobra.Command { 16 | cmd := &cobra.Command{ 17 | Use: "event-stream [--project=PROJECT_ID]", 18 | Args: cobra.ExactArgs(1), 19 | Short: "Delete the event stream with the given ID", 20 | RunE: func(cmd *cobra.Command, args []string) error { 21 | h, err := client.NewCobraCommandHelper(cmd) 22 | if err != nil { 23 | return err 24 | } 25 | 26 | projectID, err := h.ProjectID() 27 | if err != nil { 28 | return cmdx.PrintOpenAPIError(cmd, err) 29 | } 30 | streamID := args[0] 31 | 32 | err = h.DeleteEventStream(cmd.Context(), projectID, streamID) 33 | if err != nil { 34 | return cmdx.PrintOpenAPIError(cmd, err) 35 | } 36 | 37 | _, _ = fmt.Fprintln(h.VerboseErrWriter, "Event stream deleted successfully!") 38 | return nil 39 | }, 40 | } 41 | 42 | client.RegisterProjectFlag(cmd.Flags()) 43 | client.RegisterWorkspaceFlag(cmd.Flags()) 44 | return cmd 45 | } 46 | -------------------------------------------------------------------------------- /cmd/cloudx/create.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package cloudx 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | 9 | "github.com/ory/cli/cmd/cloudx/workspace" 10 | 11 | "github.com/ory/cli/cmd/cloudx/eventstreams" 12 | "github.com/ory/cli/cmd/cloudx/oauth2" 13 | "github.com/ory/cli/cmd/cloudx/organizations" 14 | "github.com/ory/cli/cmd/cloudx/relationtuples" 15 | 16 | "github.com/ory/cli/cmd/cloudx/client" 17 | "github.com/ory/cli/cmd/cloudx/project" 18 | "github.com/ory/x/cmdx" 19 | ) 20 | 21 | func NewCreateCmd() *cobra.Command { 22 | cmd := &cobra.Command{ 23 | Use: "create", 24 | Short: "Create Ory Network resources", 25 | } 26 | cmd.AddCommand( 27 | project.NewCreateProjectCmd(), 28 | oauth2.NewCreateOAuth2Client(), 29 | relationtuples.NewCreateCmd(), 30 | oauth2.NewCreateJWK(), 31 | organizations.NewCreateOrganizationCmd(), 32 | eventstreams.NewCreateEventStreamCmd(), 33 | workspace.NewCreateCmd(), 34 | ) 35 | 36 | client.RegisterConfigFlag(cmd.PersistentFlags()) 37 | client.RegisterYesFlag(cmd.PersistentFlags()) 38 | cmdx.RegisterNoiseFlags(cmd.PersistentFlags()) 39 | cmdx.RegisterJSONFormatFlags(cmd.PersistentFlags()) 40 | return cmd 41 | } 42 | -------------------------------------------------------------------------------- /cmd/cloudx/eventstreams/output.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package eventstreams 5 | 6 | import ( 7 | "encoding/json" 8 | 9 | client "github.com/ory/client-go" 10 | ) 11 | 12 | type ( 13 | outputList client.ListEventStreams 14 | output client.EventStream 15 | ) 16 | 17 | func (output) Header() []string { 18 | return []string{"ID", "TYPE", "IAM_ROLE_ARN", "SNS_TOPIC_ARN"} 19 | } 20 | 21 | func (o output) Columns() []string { 22 | return []string{ 23 | *o.Id, 24 | *o.Type, 25 | *o.RoleArn, 26 | *o.TopicArn, 27 | } 28 | } 29 | 30 | func (o output) Interface() interface{} { 31 | return o 32 | } 33 | 34 | func (outputList) Header() []string { 35 | return new(output).Header() 36 | } 37 | 38 | func (o outputList) Table() [][]string { 39 | rows := make([][]string, len(o.EventStreams)) 40 | for i, stream := range o.EventStreams { 41 | rows[i] = (output)(stream).Columns() 42 | } 43 | return rows 44 | } 45 | 46 | func (o outputList) Interface() interface{} { 47 | return o 48 | } 49 | 50 | func (o outputList) Len() int { 51 | return len(o.EventStreams) 52 | } 53 | 54 | func (o outputList) MarshalJSON() ([]byte, error) { 55 | return json.Marshal(o.EventStreams) 56 | } 57 | -------------------------------------------------------------------------------- /.github/workflows/licenses.yml: -------------------------------------------------------------------------------- 1 | # AUTO-GENERATED, DO NOT EDIT! 2 | # Please edit the original at https://github.com/ory/meta/blob/master/templates/repository/common/.github/workflows/licenses.yml 3 | 4 | name: Licenses 5 | 6 | on: 7 | pull_request: 8 | push: 9 | branches: 10 | - main 11 | - v3 12 | - master 13 | 14 | jobs: 15 | licenses: 16 | name: License compliance 17 | runs-on: ubuntu-latest 18 | steps: 19 | - name: Install script 20 | uses: ory/ci/licenses/setup@master 21 | with: 22 | token: ${{ secrets.ORY_BOT_PAT || secrets.GITHUB_TOKEN }} 23 | - name: Check licenses 24 | uses: ory/ci/licenses/check@master 25 | - name: Write, commit, push licenses 26 | uses: ory/ci/licenses/write@master 27 | if: 28 | ${{ github.ref == 'refs/heads/main' || github.ref == 29 | 'refs/heads/master' || github.ref == 'refs/heads/v3' }} 30 | with: 31 | author-email: 32 | ${{ secrets.ORY_BOT_PAT && 33 | '60093411+ory-bot@users.noreply.github.com' || 34 | format('{0}@users.noreply.github.com', github.actor) }} 35 | author-name: ${{ secrets.ORY_BOT_PAT && 'ory-bot' || github.actor }} 36 | -------------------------------------------------------------------------------- /cmd/cloudx/identity/import_test.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package identity_test 5 | 6 | import ( 7 | "context" 8 | "testing" 9 | 10 | "github.com/ory/cli/cmd/cloudx/testhelpers" 11 | 12 | "github.com/stretchr/testify/require" 13 | 14 | "github.com/ory/cli/cmd/cloudx/client" 15 | ) 16 | 17 | func TestImportIdentity(t *testing.T) { 18 | t.Parallel() 19 | 20 | t.Run("is not able to import identities if not authenticated and quiet flag", func(t *testing.T) { 21 | ctx := testhelpers.WithCleanConfigFile(context.Background(), t) 22 | _, _, err := testhelpers.Cmd(ctx).Exec(nil, "import", "identities", "--quiet", "--project", defaultProject.Id) 23 | require.ErrorIs(t, err, client.ErrNoConfigQuiet) 24 | }) 25 | 26 | t.Run("triggers auth flow when not authenticated", func(t *testing.T) { 27 | ctx := testhelpers.WithCleanConfigFile(context.Background(), t) 28 | _, _, err := testhelpers.Cmd(ctx).Exec(nil, "import", "identities", "--quiet", "--project", defaultProject.Id) 29 | require.ErrorIs(t, err, client.ErrNoConfigQuiet) 30 | }) 31 | 32 | t.Run("is able to import identities", func(t *testing.T) { 33 | testhelpers.ImportIdentity(ctx, t, defaultProject.Id, nil) 34 | }) 35 | } 36 | -------------------------------------------------------------------------------- /cmd/cloudx/organizations/delete_organization.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package organizations 5 | 6 | import ( 7 | "fmt" 8 | 9 | "github.com/spf13/cobra" 10 | 11 | "github.com/ory/cli/cmd/cloudx/client" 12 | "github.com/ory/x/cmdx" 13 | ) 14 | 15 | func NewDeleteOrganizationCmd() *cobra.Command { 16 | cmd := &cobra.Command{ 17 | Use: "organization [--project=PROJECT_ID]", 18 | Args: cobra.ExactArgs(1), 19 | Short: "Delete the organization with the given ID", 20 | RunE: func(cmd *cobra.Command, args []string) error { 21 | h, err := client.NewCobraCommandHelper(cmd) 22 | if err != nil { 23 | return err 24 | } 25 | 26 | projectID, err := h.ProjectID() 27 | if err != nil { 28 | return cmdx.PrintOpenAPIError(cmd, err) 29 | } 30 | orgID := args[0] 31 | 32 | err = h.DeleteOrganization(cmd.Context(), projectID, orgID) 33 | if err != nil { 34 | return cmdx.PrintOpenAPIError(cmd, err) 35 | } 36 | 37 | _, _ = fmt.Fprintln(h.VerboseErrWriter, "Organization deleted successfully!") 38 | return nil 39 | }, 40 | } 41 | 42 | client.RegisterProjectFlag(cmd.Flags()) 43 | client.RegisterWorkspaceFlag(cmd.Flags()) 44 | return cmd 45 | } 46 | -------------------------------------------------------------------------------- /cmd/cloudx/e2e/README.md: -------------------------------------------------------------------------------- 1 | # Ory Tunnel / Ory Proxy End-To-End Tests 2 | 3 | This suite end-to-end tests the Ory Proxy and Ory Tunnel. 4 | 5 | ## Social sign-in 6 | 7 | To perform social sign-in, we use a pre-configured Ory Network project with ID 8 | `c3564677-7641-4bc4-a49d-e1a19acdbaf9`. 9 | 10 | The project is configured to use a localhost login & consent app which we run in 11 | the background during the tests. The project has a social sign-in provider 12 | called "hydra" which uses the project's own OAuth2 service. That service has an 13 | OAuth2 client registered: 14 | 15 | ```shell 16 | go run . create oauth2-client \ 17 | --project $project_id \ 18 | --grant-type authorization_code,refresh_token \ 19 | --response-type code,id_token \ 20 | --format json \ 21 | --scope openid --scope offline \ 22 | --redirect-uri http://127.0.0.1:5555/callback \ 23 | --redirect-uri "https://admiring-tu-swczqlujc0.projects.oryapis.com/self-service/methods/oidc/callback/SnUimsDjTxePInF-" 24 | ``` 25 | 26 | The project config is available at [`./oauth2.config.yml`](./oauth2.config.yml) 27 | and you can update the project using (you will need access, please ask Aeneas or 28 | Patrik): 29 | 30 | ``` 31 | ory update oauth2-config $project_id --file file://oauth2.config.yml --format yaml 32 | ``` 33 | -------------------------------------------------------------------------------- /cmd/cloudx/list.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package cloudx 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | 9 | "github.com/ory/cli/cmd/cloudx/workspace" 10 | 11 | "github.com/ory/cli/cmd/cloudx/eventstreams" 12 | "github.com/ory/cli/cmd/cloudx/identity" 13 | "github.com/ory/cli/cmd/cloudx/oauth2" 14 | "github.com/ory/cli/cmd/cloudx/organizations" 15 | "github.com/ory/cli/cmd/cloudx/relationtuples" 16 | 17 | "github.com/ory/cli/cmd/cloudx/client" 18 | "github.com/ory/cli/cmd/cloudx/project" 19 | "github.com/ory/x/cmdx" 20 | ) 21 | 22 | func NewListCmd() *cobra.Command { 23 | cmd := &cobra.Command{ 24 | Use: "list", 25 | Aliases: []string{"ls"}, 26 | Short: "List resources", 27 | } 28 | 29 | cmd.AddCommand( 30 | project.NewListProjectsCmd(), 31 | organizations.NewListOrganizationsCmd(), 32 | identity.NewListIdentityCmd(), 33 | oauth2.NewListOAuth2Clients(), 34 | relationtuples.NewListCmd(), 35 | eventstreams.NewListEventStreamsCmd(), 36 | workspace.NewListCmd(), 37 | ) 38 | 39 | client.RegisterConfigFlag(cmd.PersistentFlags()) 40 | client.RegisterYesFlag(cmd.PersistentFlags()) 41 | cmdx.RegisterNoiseFlags(cmd.PersistentFlags()) 42 | cmdx.RegisterJSONFormatFlags(cmd.PersistentFlags()) 43 | return cmd 44 | } 45 | -------------------------------------------------------------------------------- /cmd/dev/ci/monorepo/depgraph_test.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package monorepo 5 | 6 | import ( 7 | "testing" 8 | 9 | "github.com/stretchr/testify/assert" 10 | ) 11 | 12 | func TestMonorepoInvalidFile(t *testing.T) { 13 | var graph ComponentGraph 14 | _, err := graph.getComponentGraph("test/invalidConfigFile") 15 | //todo check for specific error 16 | assert.Error(t, err) 17 | } 18 | 19 | func TestMonorepoCirclular(t *testing.T) { 20 | var graph ComponentGraph 21 | g, err := graph.getComponentGraph("test/circular") 22 | 23 | //successfully read configurations 24 | assert.Nil(t, err, "Successfully read configuration") 25 | _, err = g.resolveGraph() 26 | assert.NotNil(t, err, "Failed resolving graph because of circular dependency") 27 | } 28 | 29 | func TestMonorepoWorking(t *testing.T) { 30 | var graph ComponentGraph 31 | 32 | _, _ = graph.getComponentGraph("test/working") 33 | graph.displayGraph() 34 | 35 | resolved, err := graph.resolveGraph() 36 | assert.Nil(t, err) 37 | assert.Equal(t, 6, resolved.len()) 38 | /* 39 | 1. Invalid Root Directory 40 | 2. No Config Files 41 | 3. Invalid Config Files 42 | 4. Valid Graph 43 | a) Parse 44 | b) Resolved Graph 45 | 5. Trigger 46 | 5. Circular Dependencies 47 | 48 | */ 49 | } 50 | -------------------------------------------------------------------------------- /cmd/cloudx/organizations/output.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package organizations 5 | 6 | import ( 7 | "encoding/json" 8 | "strings" 9 | 10 | client "github.com/ory/client-go" 11 | ) 12 | 13 | type ( 14 | outputOrganizations struct { 15 | organizations *client.ListOrganizationsResponse 16 | } 17 | output client.Organization 18 | ) 19 | 20 | func (o output) Header() []string { 21 | return []string{"ID", "LABEL", "DOMAINS"} 22 | } 23 | 24 | func (o output) Columns() []string { 25 | return []string{ 26 | o.Id, 27 | o.Label, 28 | strings.Join(o.Domains, ", "), 29 | } 30 | } 31 | 32 | func (o output) Interface() interface{} { 33 | return o 34 | } 35 | 36 | func (o *outputOrganizations) Header() []string { 37 | return new(output).Header() 38 | } 39 | 40 | func (o *outputOrganizations) Table() [][]string { 41 | rows := make([][]string, o.Len()) 42 | for i, organization := range o.organizations.Organizations { 43 | rows[i] = (output)(organization).Columns() 44 | } 45 | return rows 46 | } 47 | 48 | func (o *outputOrganizations) Interface() interface{} { 49 | return o 50 | } 51 | 52 | func (o *outputOrganizations) Len() int { 53 | return len(o.organizations.Organizations) 54 | } 55 | 56 | func (o *outputOrganizations) MarshalJSON() ([]byte, error) { 57 | return json.Marshal(o.organizations.Organizations) 58 | } 59 | -------------------------------------------------------------------------------- /cmd/cloudx/project/fixtures/update/fail/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "services": { 3 | "identity": { 4 | "config": { 5 | "identity": { 6 | "schemas": [] 7 | }, 8 | "selfservice": { 9 | "default_browser_return_url": "/" 10 | }, 11 | "courier": { 12 | "smtp": { 13 | "from_name": "Updated Project from JSON via Ory" 14 | }, 15 | "templates": { 16 | "recovery": { 17 | "invalid": { 18 | "email": {} 19 | }, 20 | "valid": { 21 | "email": {} 22 | } 23 | }, 24 | "verification": { 25 | "invalid": { 26 | "email": {} 27 | }, 28 | "valid": { 29 | "email": {} 30 | } 31 | } 32 | } 33 | }, 34 | "session": { 35 | "lifespan": "72h0m0s", 36 | "cookie": { 37 | "domain": "upbeat-mclean-xjvqxk4i7e.projects.oryapis", 38 | "name": "ory_session_upbeatmcleanxjvqxk4i7e", 39 | "path": "/", 40 | "same_site": "Lax" 41 | }, 42 | "whoami": { 43 | "required_aal": "aal1" 44 | } 45 | } 46 | } 47 | } 48 | }, 49 | "name": "Updated Project from JSON" 50 | } 51 | -------------------------------------------------------------------------------- /cmd/cloudx/workspace/output.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package workspace 5 | 6 | import ( 7 | cloud "github.com/ory/client-go" 8 | "github.com/ory/x/cmdx" 9 | ) 10 | 11 | type ( 12 | outputWorkspace cloud.Workspace 13 | outputWorkspaces []cloud.Workspace 14 | ) 15 | 16 | var ( 17 | workspaceHeader = []string{"ID", "NAME", "SUBSCRIPTION PLAN"} 18 | _ cmdx.TableRow = (*outputWorkspace)(nil) 19 | _ cmdx.Table = (*outputWorkspaces)(nil) 20 | ) 21 | 22 | func (*outputWorkspace) Header() []string { 23 | return workspaceHeader 24 | } 25 | 26 | func (w *outputWorkspace) Columns() []string { 27 | subPlan := cmdx.None 28 | if w.SubscriptionPlan.Get() != nil { 29 | subPlan = *w.SubscriptionPlan.Get() 30 | } 31 | return []string{w.Id, w.Name, subPlan} 32 | } 33 | 34 | func (w *outputWorkspace) Interface() interface{} { 35 | return w 36 | } 37 | 38 | func (o outputWorkspaces) Header() []string { 39 | return workspaceHeader 40 | } 41 | 42 | func (o outputWorkspaces) Table() [][]string { 43 | res := make([][]string, len(o)) 44 | for k, v := range o { 45 | res[k] = (*outputWorkspace)(&v).Columns() 46 | } 47 | return res 48 | } 49 | 50 | func (o outputWorkspaces) Interface() interface{} { 51 | return o 52 | } 53 | 54 | func (o outputWorkspaces) Len() int { 55 | return len(o) 56 | } 57 | -------------------------------------------------------------------------------- /.github/workflows/cve-scan.yaml: -------------------------------------------------------------------------------- 1 | name: Docker Image Scan 2 | on: 3 | push: 4 | branches: 5 | - "master" 6 | tags: 7 | - "v*.*.*" 8 | pull_request: 9 | branches: 10 | - "master" 11 | 12 | jobs: 13 | docker: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: Checkout 17 | uses: actions/checkout@v2 18 | - name: Set up QEMU 19 | uses: docker/setup-qemu-action@v1 20 | - name: Set up Docker Buildx 21 | uses: docker/setup-buildx-action@v1 22 | - name: Build images 23 | shell: bash 24 | run: | 25 | make docker 26 | - name: Scan image 27 | id: scan 28 | uses: anchore/scan-action@v3 29 | with: 30 | image: oryd/ory:latest-sqlite 31 | fail-build: false 32 | severity-cutoff: critical 33 | add-cpes-if-none: true 34 | - name: Inspect action SARIF report 35 | run: cat ${{ steps.scan.outputs.sarif }} 36 | - name: Upload SARIF report 37 | uses: github/codeql-action/upload-sarif@v2 38 | with: 39 | sarif_file: ${{ steps.scan.outputs.sarif }} 40 | - name: Inspect scan result 41 | id: report 42 | uses: anchore/scan-action@v3 43 | with: 44 | image: oryd/ory:latest-sqlite 45 | output-format: table 46 | fail-build: true 47 | severity-cutoff: critical 48 | add-cpes-if-none: true 49 | -------------------------------------------------------------------------------- /cmd/dev/markdown/render.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package markdown 5 | 6 | import ( 7 | "fmt" 8 | "html/template" 9 | "os" 10 | "strings" 11 | 12 | "github.com/gomarkdown/markdown" 13 | "github.com/gomarkdown/markdown/html" 14 | "github.com/gomarkdown/markdown/parser" 15 | "github.com/spf13/cobra" 16 | 17 | "github.com/ory/cli/cmd/pkg" 18 | ) 19 | 20 | func init() { 21 | Main.AddCommand(render) 22 | } 23 | 24 | var render = &cobra.Command{ 25 | Use: "render ", 26 | Args: cobra.ExactArgs(1), 27 | Short: "Render a Markdown file", 28 | Run: func(cmd *cobra.Command, args []string) { 29 | changelogRaw, err := os.ReadFile(args[0]) 30 | pkg.Check(err) 31 | 32 | fmt.Println(renderMarkdown(changelogRaw)) 33 | }, 34 | } 35 | 36 | func renderMarkdown(source []byte) template.HTML { 37 | var markdownRenderer = html.NewRenderer(html.RendererOptions{Flags: html.CommonFlags | html.HrefTargetBlank}) 38 | var markdownParser = parser.NewWithExtensions( 39 | parser.NoIntraEmphasis | parser.Tables | parser.FencedCode | parser.NoEmptyLineBeforeBlock | 40 | parser.Autolink | parser.Strikethrough | parser.SpaceHeadings | parser.DefinitionLists) 41 | 42 | rendered := string(markdown.ToHTML(source, markdownParser, markdownRenderer)) 43 | rendered = strings.ReplaceAll(rendered, "

", "") 44 | rendered = strings.ReplaceAll(rendered, "

", "
") 45 | return template.HTML(rendered) 46 | } 47 | -------------------------------------------------------------------------------- /cmd/dev/headers/comments/file_type_test.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package comments_test 5 | 6 | import ( 7 | "fmt" 8 | "testing" 9 | 10 | "github.com/stretchr/testify/assert" 11 | 12 | "github.com/ory/cli/cmd/dev/headers/comments" 13 | ) 14 | 15 | func TestContainsFileType(t *testing.T) { 16 | t.Parallel() 17 | fileTypes := []comments.FileType{"ts", "md", "go"} 18 | assert.True(t, comments.ContainsFileType(fileTypes, "ts")) 19 | assert.True(t, comments.ContainsFileType(fileTypes, "go")) 20 | assert.False(t, comments.ContainsFileType(fileTypes, "rs")) 21 | } 22 | 23 | func TestGetFileType(t *testing.T) { 24 | t.Parallel() 25 | tests := map[string]comments.FileType{ 26 | "foo.yml": "yml", 27 | "foo.yaml": "yml", 28 | "foo.md": "md", 29 | "foo.xxx": "xxx", 30 | "foo": "", 31 | } 32 | for give, want := range tests { 33 | t.Run(fmt.Sprintf("%s -> %s", give, want), func(t *testing.T) { 34 | have := comments.GetFileType(give) 35 | assert.Equal(t, want, have) 36 | }) 37 | } 38 | } 39 | 40 | func TestSupports(t *testing.T) { 41 | t.Parallel() 42 | assert.True(t, comments.SupportsFile("foo.ts")) 43 | assert.True(t, comments.SupportsFile("foo.md")) 44 | assert.False(t, comments.SupportsFile("foo.xxx")) 45 | assert.False(t, comments.SupportsFile("nodemon")) 46 | assert.False(t, comments.SupportsFile("./nodemon")) 47 | assert.False(t, comments.SupportsFile(".bin/nodemon")) 48 | } 49 | -------------------------------------------------------------------------------- /cmd/cloudx/project/use.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2022 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package project 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | 9 | "github.com/ory/cli/cmd/cloudx/client" 10 | "github.com/ory/x/cmdx" 11 | ) 12 | 13 | func NewUseProjectCmd() *cobra.Command { 14 | cmd := &cobra.Command{ 15 | Use: "project [id]", 16 | Args: cobra.MaximumNArgs(1), 17 | Short: "Set the project as the default. When no id is provided, prints the currently used default project.", 18 | Example: `$ ory use project ecaaa3cb-0730-4ee8-a6df-9553cdfeef89 19 | 20 | ID ecaaa3cb-0730-4ee8-a6df-9553cdfeef89 21 | 22 | $ ory use project ecaaa3cb-0730-4ee8-a6df-9553cdfeef89 --format json 23 | 24 | { 25 | "id": "ecaaa3cb-0730-4ee8-a6df-9553cdfeef89 26 | }`, 27 | RunE: func(cmd *cobra.Command, args []string) error { 28 | opts := make([]client.CommandHelperOption, 0, 1) 29 | if len(args) == 1 { 30 | opts = append(opts, client.WithProjectOverride(args[0])) 31 | } 32 | h, err := client.NewCobraCommandHelper(cmd, opts...) 33 | if err != nil { 34 | return err 35 | } 36 | 37 | id, err := h.ProjectID() 38 | if err != nil { 39 | return cmdx.PrintOpenAPIError(cmd, err) 40 | } 41 | 42 | if err := h.SelectProject(id); err != nil { 43 | return cmdx.PrintOpenAPIError(cmd, err) 44 | } 45 | 46 | cmdx.PrintRow(cmd, &selectedProject{ID: id}) 47 | return nil 48 | }, 49 | } 50 | 51 | cmdx.RegisterFormatFlags(cmd.Flags()) 52 | return cmd 53 | } 54 | -------------------------------------------------------------------------------- /cmd/dev/schema/fixtures/render_version_test/.schema/version.schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "https://github.com/ory/cli/cmd/dev/schema/fixtures/render_version_test/.schema/version.schema.json", 3 | "$schema": "http://json-schema.org/draft-07/schema#", 4 | "title": "Test Fixture schema.", 5 | "type": "object", 6 | "oneOf": [ 7 | { 8 | "allOf": [ 9 | { 10 | "properties": { 11 | "version": { 12 | "const": "v0.0.0" 13 | } 14 | }, 15 | "required": [ 16 | "version" 17 | ] 18 | }, 19 | { 20 | "$ref": "https://raw.githubusercontent.com/ory/hydra/v0.0.0/.schema/config.schema.json" 21 | } 22 | ] 23 | }, 24 | { 25 | "allOf": [ 26 | { 27 | "oneOf": [ 28 | { 29 | "properties": { 30 | "version": { 31 | "type": "string", 32 | "maxLength": 0 33 | } 34 | }, 35 | "required": [ 36 | "version" 37 | ] 38 | }, 39 | { 40 | "not": { 41 | "properties": { 42 | "version": {} 43 | }, 44 | "required": [ 45 | "version" 46 | ] 47 | } 48 | } 49 | ] 50 | }, 51 | { 52 | "$ref": "#/oneOf/0/allOf/1" 53 | } 54 | ] 55 | } 56 | ] 57 | } 58 | -------------------------------------------------------------------------------- /cmd/cloudx/eventstreams/update.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package eventstreams 5 | 6 | import ( 7 | "fmt" 8 | 9 | "github.com/spf13/cobra" 10 | 11 | "github.com/ory/cli/cmd/cloudx/client" 12 | cloud "github.com/ory/client-go" 13 | 14 | "github.com/ory/x/cmdx" 15 | ) 16 | 17 | func NewUpdateEventStreamCmd() *cobra.Command { 18 | c := streamConfig{} 19 | 20 | cmd := &cobra.Command{ 21 | Use: "event-stream id [--project=PROJECT_ID] [--type=sns] [--aws-iam-role-arn=arn:aws:iam::123456789012:role/MyRole] [--aws-sns-topic-arn=arn:aws:sns:us-east-1:123456789012:MyTopic]", 22 | Args: cobra.ExactArgs(1), 23 | Short: "Update the event stream with the given ID", 24 | RunE: func(cmd *cobra.Command, args []string) error { 25 | ctx := cmd.Context() 26 | h, err := client.NewCobraCommandHelper(cmd) 27 | if err != nil { 28 | return err 29 | } 30 | 31 | projectID, err := h.ProjectID() 32 | if err != nil { 33 | return err 34 | } 35 | streamID := args[0] 36 | 37 | if err := c.Validate(); err != nil { 38 | return err 39 | } 40 | stream, err := h.UpdateEventStream(ctx, projectID, streamID, cloud.SetEventStreamBody(c)) 41 | if err != nil { 42 | return cmdx.PrintOpenAPIError(cmd, err) 43 | } 44 | 45 | _, _ = fmt.Fprintln(h.VerboseErrWriter, "Event stream updated successfully!") 46 | cmdx.PrintRow(cmd, output(*stream)) 47 | return nil 48 | }, 49 | } 50 | 51 | client.RegisterProjectFlag(cmd.Flags()) 52 | cmdx.RegisterFormatFlags(cmd.Flags()) 53 | 54 | return cmd 55 | } 56 | -------------------------------------------------------------------------------- /cmd/cloudx/project/get_identity_config.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package project 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | 9 | "github.com/ory/cli/cmd/cloudx/client" 10 | "github.com/ory/x/cmdx" 11 | ) 12 | 13 | func NewGetKratosConfigCmd() *cobra.Command { 14 | cmd := &cobra.Command{ 15 | Use: "identity-config", 16 | Aliases: []string{"ic", "kratos-config"}, 17 | Args: cobra.NoArgs, 18 | Short: "Get Ory Identities configuration.", 19 | Long: "Get the Ory Identities configuration for an Ory Network project.", 20 | Example: `$ ory get identity-config --project ecaaa3cb-0730-4ee8-a6df-9553cdfeef89 --format yaml > identity-config.yaml 21 | 22 | $ ory get identity-config --format json # uses currently selected project 23 | 24 | { 25 | "selfservice": { 26 | "methods": { 27 | "password": { "enabled": false } 28 | } 29 | // ... 30 | } 31 | }`, 32 | RunE: func(cmd *cobra.Command, _ []string) error { 33 | h, err := client.NewCobraCommandHelper(cmd) 34 | if err != nil { 35 | return err 36 | } 37 | 38 | pID, err := h.ProjectID() 39 | if err != nil { 40 | return err 41 | } 42 | project, err := h.GetProject(cmd.Context(), pID, nil) 43 | if err != nil { 44 | return cmdx.PrintOpenAPIError(cmd, err) 45 | } 46 | 47 | cmdx.PrintJSONAble(cmd, outputConfig(project.Services.Identity.Config)) 48 | return nil 49 | }, 50 | } 51 | 52 | cmdx.RegisterJSONFormatFlags(cmd.Flags()) 53 | client.RegisterProjectFlag(cmd.Flags()) 54 | client.RegisterWorkspaceFlag(cmd.Flags()) 55 | return cmd 56 | } 57 | -------------------------------------------------------------------------------- /cmd/cloudx/eventstreams/create.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package eventstreams 5 | 6 | import ( 7 | "fmt" 8 | 9 | "github.com/spf13/cobra" 10 | 11 | "github.com/ory/cli/cmd/cloudx/client" 12 | cloud "github.com/ory/client-go" 13 | "github.com/ory/x/cmdx" 14 | ) 15 | 16 | func NewCreateEventStreamCmd() *cobra.Command { 17 | c := streamConfig{} 18 | 19 | cmd := &cobra.Command{ 20 | Use: "event-stream [--project=PROJECT_ID] --type=sns --aws-iam-role-arn=arn:aws:iam::123456789012:role/MyRole --aws-sns-topic-arn=arn:aws:sns:us-east-1:123456789012:MyTopic", 21 | Short: "Create a new event stream", 22 | Args: cobra.NoArgs, 23 | RunE: func(cmd *cobra.Command, args []string) error { 24 | ctx := cmd.Context() 25 | 26 | h, err := client.NewCobraCommandHelper(cmd) 27 | if err != nil { 28 | return err 29 | } 30 | 31 | projectID, err := h.ProjectID() 32 | if err != nil { 33 | return err 34 | } 35 | 36 | if err := c.Validate(); err != nil { 37 | return err 38 | } 39 | stream, err := h.CreateEventStream(ctx, projectID, cloud.CreateEventStreamBody(c)) 40 | if err != nil { 41 | return cmdx.PrintOpenAPIError(cmd, err) 42 | } 43 | 44 | _, _ = fmt.Fprintln(h.VerboseErrWriter, "Event stream created successfully!") 45 | cmdx.PrintRow(cmd, output(*stream)) 46 | return nil 47 | }, 48 | } 49 | 50 | client.RegisterProjectFlag(cmd.Flags()) 51 | client.RegisterWorkspaceFlag(cmd.Flags()) 52 | cmdx.RegisterFormatFlags(cmd.Flags()) 53 | 54 | registerStreamConfigFlags(cmd.Flags(), &c) 55 | 56 | return cmd 57 | } 58 | -------------------------------------------------------------------------------- /cmd/cloudx/project/get_permission_config.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package project 5 | 6 | import ( 7 | "github.com/spf13/cobra" 8 | 9 | "github.com/ory/cli/cmd/cloudx/client" 10 | "github.com/ory/x/cmdx" 11 | ) 12 | 13 | func NewGetKetoConfigCmd() *cobra.Command { 14 | cmd := &cobra.Command{ 15 | Use: "permission-config", 16 | Aliases: []string{"pc", "keto-config"}, 17 | Args: cobra.NoArgs, 18 | Short: "Get Ory Permissions configuration.", 19 | Long: "Get the Ory Permissions configuration for an Ory Network project.", 20 | Example: `$ ory get permission-config --project ecaaa3cb-0730-4ee8-a6df-9553cdfeef89 --format yaml > permission-config.yaml 21 | 22 | $ ory get permission-config --format json # uses currently selected project 23 | 24 | { 25 | "namespaces": [ 26 | { 27 | "name": "files", 28 | "id": 1 29 | },1 30 | // ... 31 | ] 32 | }`, 33 | RunE: func(cmd *cobra.Command, _ []string) error { 34 | h, err := client.NewCobraCommandHelper(cmd) 35 | if err != nil { 36 | return err 37 | } 38 | 39 | pID, err := h.ProjectID() 40 | if err != nil { 41 | return err 42 | } 43 | project, err := h.GetProject(cmd.Context(), pID, nil) 44 | if err != nil { 45 | return cmdx.PrintOpenAPIError(cmd, err) 46 | } 47 | 48 | cmdx.PrintJSONAble(cmd, outputConfig(project.Services.Permission.Config)) 49 | return nil 50 | }, 51 | } 52 | 53 | cmdx.RegisterJSONFormatFlags(cmd.Flags()) 54 | client.RegisterProjectFlag(cmd.Flags()) 55 | client.RegisterWorkspaceFlag(cmd.Flags()) 56 | return cmd 57 | } 58 | -------------------------------------------------------------------------------- /cmd/cloudx/identity/delete_test.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package identity_test 5 | 6 | import ( 7 | "context" 8 | "testing" 9 | 10 | "github.com/stretchr/testify/assert" 11 | "github.com/stretchr/testify/require" 12 | "github.com/tidwall/gjson" 13 | 14 | "github.com/ory/cli/cmd/cloudx/client" 15 | "github.com/ory/cli/cmd/cloudx/testhelpers" 16 | ) 17 | 18 | func TestDeleteIdentity(t *testing.T) { 19 | t.Parallel() 20 | 21 | userID := testhelpers.ImportIdentity(ctx, t, defaultProject.Id, nil) 22 | 23 | t.Run("is not able to delete identities if not authenticated and quiet flag", func(t *testing.T) { 24 | ctx := testhelpers.WithCleanConfigFile(context.Background(), t) 25 | _, _, err := testhelpers.Cmd(ctx).Exec(nil, "delete", "identity", "--quiet", "--project", defaultProject.Id, userID) 26 | require.ErrorIs(t, err, client.ErrNoConfigQuiet) 27 | }) 28 | 29 | t.Run("triggers auth flow when not authenticated", func(t *testing.T) { 30 | ctx := testhelpers.WithEmitAuthFlowTriggeredErr(context.Background(), t) 31 | _, _, err := testhelpers.Cmd(ctx).Exec(nil, "delete", "identity", "--project", defaultProject.Id, userID) 32 | require.ErrorIs(t, err, testhelpers.ErrAuthFlowTriggered) 33 | }) 34 | 35 | t.Run("is able to delete identities", func(t *testing.T) { 36 | stdout, stderr, err := defaultCmd.Exec(nil, "delete", "identity", "--format", "json", "--project", defaultProject.Id, userID) 37 | require.NoError(t, err, stderr) 38 | out := gjson.Parse(stdout) 39 | assert.True(t, gjson.Valid(stdout)) 40 | assert.Equal(t, userID, out.String(), "stdout: %s", stdout) 41 | }) 42 | } 43 | -------------------------------------------------------------------------------- /cmd/cloudx/organizations/create_organization.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 Ory Corp 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | package organizations 5 | 6 | import ( 7 | "fmt" 8 | 9 | "github.com/spf13/cobra" 10 | 11 | "github.com/ory/cli/cmd/cloudx/client" 12 | cloud "github.com/ory/client-go" 13 | 14 | "github.com/ory/x/cmdx" 15 | ) 16 | 17 | func NewCreateOrganizationCmd() *cobra.Command { 18 | var domains []string 19 | 20 | cmd := &cobra.Command{ 21 | Use: "organization