From 8984bd76367e70cdecc79344be30302616d14c46 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Fri, 17 Mar 2023 18:10:59 +0100 Subject: [PATCH] Introduce authorizations with Rajska Signed-off-by: Thomas Citharel --- config/test.exs | 2 +- js/package.json | 23 +- js/src/components/Event/EventMetadataList.vue | 17 +- .../Event/OrganizerPickerWrapper.story.vue | 2 +- .../components/OAuth/AuthorizeApplication.vue | 135 +- js/src/components/OAuth/scopes.ts | 283 +++ js/src/components/core/MaterialIcon.vue | 8 + js/src/composition/apollo/actor.ts | 5 +- js/src/composition/apollo/user.ts | 10 +- js/src/graphql/actor.ts | 8 +- js/src/graphql/application.ts | 21 +- js/src/graphql/config.ts | 1 + js/src/graphql/group.ts | 10 +- js/src/i18n/en_US.json | 98 +- js/src/i18n/fr_FR.json | 96 +- js/src/types/application.model.ts | 2 +- js/src/types/current-user.model.ts | 1 + js/src/utils/identity.ts | 5 +- .../views/Account/children/EditIdentity.vue | 25 +- js/src/views/Group/TimelineView.vue | 45 +- js/src/views/OAuth/AuthorizeView.vue | 50 +- js/src/views/Settings/AppsView.vue | 6 +- js/vite.config.js | 7 + js/yarn.lock | 1818 ++++++++++------- lib/graphql/authorization.ex | 86 + lib/graphql/authorization/app_scope.ex | 118 ++ lib/graphql/error.ex | 19 + lib/graphql/resolvers/application.ex | 62 +- lib/graphql/resolvers/media.ex | 4 +- lib/graphql/schema.ex | 25 +- lib/graphql/schema/activity.ex | 4 + lib/graphql/schema/actor.ex | 4 + lib/graphql/schema/actors/application.ex | 1 + lib/graphql/schema/actors/follower.ex | 4 + lib/graphql/schema/actors/group.ex | 61 +- lib/graphql/schema/actors/member.ex | 91 +- lib/graphql/schema/actors/person.ex | 78 +- lib/graphql/schema/address.ex | 8 +- lib/graphql/schema/admin.ex | 27 +- lib/graphql/schema/auth_application.ex | 52 +- lib/graphql/schema/config.ex | 45 + lib/graphql/schema/discussions/comment.ex | 24 + lib/graphql/schema/discussions/discussion.ex | 39 + lib/graphql/schema/event.ex | 45 +- lib/graphql/schema/events/feed_token.ex | 17 + lib/graphql/schema/events/participant.ex | 24 +- lib/graphql/schema/followed_group_activity.ex | 2 + lib/graphql/schema/media.ex | 20 + lib/graphql/schema/post.ex | 37 +- lib/graphql/schema/report.ex | 36 +- lib/graphql/schema/resource.ex | 38 + lib/graphql/schema/search.ex | 13 +- lib/graphql/schema/statistics.ex | 4 + lib/graphql/schema/tag.ex | 2 + lib/graphql/schema/todos/todo.ex | 6 +- lib/graphql/schema/todos/todo_list.ex | 4 + lib/graphql/schema/user.ex | 64 +- lib/graphql/schema/users/activity_setting.ex | 8 + lib/graphql/schema/users/push_subscription.ex | 14 + lib/mobilizon/applications.ex | 29 +- lib/mobilizon/applications/application.ex | 8 +- .../application_device_activation.ex | 2 +- .../applications/application_token.ex | 2 +- lib/service/auth/applications.ex | 223 +- lib/web/auth/context.ex | 2 +- lib/web/auth/error_handler.ex | 5 +- lib/web/auth/guardian.ex | 19 +- lib/web/controllers/application_controller.ex | 173 +- lib/web/router.ex | 6 +- mix.exs | 1 + mix.lock | 1 + .../20230208101626_create_applications.exs | 4 +- ...230215125801_create_application_tokens.exs | 2 + ...20230216151638_add_device_flow_support.exs | 10 - test/graphql/resolvers/activity_test.exs | 3 +- test/graphql/resolvers/admin_test.exs | 107 +- test/graphql/resolvers/application_test.exs | 533 +++++ test/graphql/resolvers/comment_test.exs | 13 +- test/graphql/resolvers/event_test.exs | 97 +- test/graphql/resolvers/feed_token_test.exs | 176 +- test/graphql/resolvers/follower_test.exs | 5 +- test/graphql/resolvers/group_test.exs | 48 +- test/graphql/resolvers/media_test.exs | 2 +- test/graphql/resolvers/member_test.exs | 6 +- test/graphql/resolvers/person_test.exs | 3 +- test/graphql/resolvers/report_test.exs | 8 +- test/graphql/resolvers/resource_test.exs | 8 +- test/graphql/resolvers/search_test.exs | 49 +- test/graphql/resolvers/tag_test.exs | 24 +- test/graphql/resolvers/user_test.exs | 78 +- test/mobilizon/applications_test.exs | 33 +- test/support/conn_case.ex | 10 +- test/support/factory.ex | 33 + .../support/fixtures/applications_fixtures.ex | 15 +- .../application_controller_test.exs | 563 +++++ 95 files changed, 4560 insertions(+), 1505 deletions(-) create mode 100644 js/src/components/OAuth/scopes.ts create mode 100644 lib/graphql/authorization.ex create mode 100644 lib/graphql/authorization/app_scope.ex delete mode 100644 priv/repo/migrations/20230216151638_add_device_flow_support.exs create mode 100644 test/graphql/resolvers/application_test.exs create mode 100644 test/web/controllers/application_controller_test.exs diff --git a/config/test.exs b/config/test.exs index 62901358..b5995e94 100644 --- a/config/test.exs +++ b/config/test.exs @@ -78,7 +78,7 @@ config :tesla, Mobilizon.Service.HTTP.HostMetaClient, config :mobilizon, Mobilizon.Service.Geospatial, service: Mobilizon.Service.Geospatial.Mock -config :mobilizon, Oban, queues: false, plugins: false +config :mobilizon, Oban, testing: :manual config :mobilizon, Mobilizon.Web.Auth.Guardian, secret_key: "some secret" diff --git a/js/package.json b/js/package.json index d73a875c..40b802ba 100644 --- a/js/package.json +++ b/js/package.json @@ -45,6 +45,7 @@ "@tiptap/extension-strike": "^2.0.0-beta.26", "@tiptap/extension-text": "^2.0.0-beta.15", "@tiptap/extension-underline": "^2.0.0-beta.7", + "@tiptap/pm": "^2.0.0-beta.220", "@tiptap/suggestion": "^2.0.0-beta.195", "@tiptap/vue-3": "^2.0.0-beta.96", "@vue-a11y/announcer": "^2.1.0", @@ -59,7 +60,7 @@ "autoprefixer": "^10", "blurhash": "^2.0.0", "date-fns": "^2.16.0", - "date-fns-tz": "^1.1.6", + "date-fns-tz": "^2.0.0", "floating-vue": "^2.0.0-beta.17", "graphql": "^15.8.0", "graphql-tag": "^2.10.3", @@ -74,16 +75,6 @@ "p-debounce": "^4.0.0", "phoenix": "^1.6", "postcss": "^8", - "prosemirror-commands": "^1.5.0", - "prosemirror-dropcursor": "^1.6.1", - "prosemirror-gapcursor": "^1.3.1", - "prosemirror-history": "^1.3.0", - "prosemirror-keymap": "^1.2.0", - "prosemirror-model": "^1.19.0", - "prosemirror-schema-list": "^1.2.2", - "prosemirror-state": "^1.4.2", - "prosemirror-transform": "^1.7.1", - "prosemirror-view": "^1.30.0", "register-service-worker": "^1.7.2", "sanitize-html": "^2.5.3", "tailwindcss": "^3", @@ -100,7 +91,7 @@ "zhyswan-vuedraggable": "^4.1.3" }, "devDependencies": { - "@histoire/plugin-vue": "^0.12.4", + "@histoire/plugin-vue": "^0.15.8", "@playwright/test": "^1.25.1", "@rushstack/eslint-patch": "^1.1.4", "@tailwindcss/forms": "^0.5.2", @@ -114,8 +105,8 @@ "@types/phoenix": "^1.5.2", "@types/sanitize-html": "^2.5.0", "@vitejs/plugin-vue": "^4.0.0", - "@vitest/coverage-c8": "^0.28.2", - "@vitest/ui": "^0.28.2", + "@vitest/coverage-c8": "^0.29.2", + "@vitest/ui": "^0.29.2", "@vue/eslint-config-prettier": "^7.0.0", "@vue/eslint-config-typescript": "^11.0.0", "@vue/test-utils": "^2.0.2", @@ -125,7 +116,7 @@ "eslint-plugin-prettier": "^4.0.0", "eslint-plugin-vue": "^9.3.0", "flush-promises": "^1.0.2", - "histoire": "^0.12.4", + "histoire": "^0.15.8", "jsdom": "^21.1.0", "mock-apollo-client": "^1.1.0", "prettier": "^2.2.1", @@ -135,7 +126,7 @@ "typescript": "~4.9.4", "vite": "^4.0.4", "vite-plugin-pwa": "^0.14.1", - "vitest": "^0.28.2", + "vitest": "^0.29.2", "vue-i18n-extract": "^2.0.4" } } diff --git a/js/src/components/Event/EventMetadataList.vue b/js/src/components/Event/EventMetadataList.vue index d3fb4abd..1b504151 100644 --- a/js/src/components/Event/EventMetadataList.vue +++ b/js/src/components/Event/EventMetadataList.vue @@ -65,18 +65,15 @@ -