Add oAuth
authorEgor Kislitsyn <egor@kislitsyn.com>
Thu, 2 Apr 2020 13:33:23 +0000 (17:33 +0400)
committerEgor Kislitsyn <egor@kislitsyn.com>
Thu, 2 Apr 2020 13:33:23 +0000 (17:33 +0400)
lib/pleroma/web/api_spec.ex
lib/pleroma/web/api_spec/operations/app_operation.ex

index 22f76d4bfff013529d948e3c2f0c12943efcc38b..41e48a0850a5bcd48cdd77e0aba92fd64e68d146 100644 (file)
@@ -22,7 +22,21 @@ defmodule Pleroma.Web.ApiSpec do
         version: Application.spec(:pleroma, :vsn) |> to_string()
       },
       # populate the paths from a phoenix router
-      paths: OpenApiSpex.Paths.from_router(Router)
+      paths: OpenApiSpex.Paths.from_router(Router),
+      components: %OpenApiSpex.Components{
+        securitySchemes: %{
+          "oAuth" => %OpenApiSpex.SecurityScheme{
+            type: "oauth2",
+            flows: %OpenApiSpex.OAuthFlows{
+              password: %OpenApiSpex.OAuthFlow{
+                authorizationUrl: "/oauth/authorize",
+                tokenUrl: "/oauth/token",
+                scopes: %{"read" => "read"}
+              }
+            }
+          }
+        }
+      }
     }
     # discover request/response schemas from path specs
     |> OpenApiSpex.resolve_schema_modules()
index 2a4958acfc2677af6b1d249511cbe06bb36f9106..41d56693ac1be1485fcd08f15e010716a1fbbd37 100644 (file)
@@ -51,8 +51,10 @@ defmodule Pleroma.Web.ApiSpec.AppOperation do
       summary: "Verify your app works",
       description: "Confirm that the app's OAuth2 credentials work.",
       operationId: "AppController.verify_credentials",
-      parameters: [
-        Operation.parameter(:authorization, :header, :string, "Bearer <app token>", required: true)
+      security: [
+        %{
+          "oAuth" => ["read"]
+        }
       ],
       responses: %{
         200 =>