Add oAuth

This commit is contained in:
Egor Kislitsyn 2020-04-02 17:33:23 +04:00
parent 23219e6fb3
commit 0aa24a150b
No known key found for this signature in database
GPG Key ID: 1B49CB15B71E7805
2 changed files with 19 additions and 3 deletions

View 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()

View 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 =>