Software /
code /
prosody-modules
Changeset
5220:d03448560acf
mod_rest: Point URLs to mod_http_oauth2 in demo mode
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 07 Mar 2023 14:59:45 +0100 (22 months ago) |
parents | 5219:25e824f64fd3 |
children | 5221:22483cfce3ce |
files | mod_rest/apidemo.lib.lua mod_rest/res/openapi.yaml |
diffstat | 2 files changed, 27 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_rest/apidemo.lib.lua Tue Mar 07 13:19:19 2023 +0000 +++ b/mod_rest/apidemo.lib.lua Tue Mar 07 14:59:45 2023 +0100 @@ -27,11 +27,13 @@ do local f = module:load_resource("res/openapi.yaml"); + local openapi = f:read("*a"); + openapi = openapi:gsub("https://example%.com/oauth2", module:http_url("oauth2")); _M.schema = { headers = { content_type = "text/x-yaml"; }; - body = f:read("*a"); + body = openapi; } f:close(); end
--- a/mod_rest/res/openapi.yaml Tue Mar 07 13:19:19 2023 +0000 +++ b/mod_rest/res/openapi.yaml Tue Mar 07 14:59:45 2023 +0100 @@ -21,6 +21,7 @@ security: - basic: [] - token: [] + - oauth2: [] requestBody: $ref: '#/components/requestBodies/common' responses: @@ -37,6 +38,7 @@ security: - basic: [] - token: [] + - oauth2: [] parameters: - $ref: '#/components/parameters/kind' - $ref: '#/components/parameters/type' @@ -55,6 +57,7 @@ security: - basic: [] - token: [] + - oauth2: [] requestBody: $ref: '#/components/requestBodies/common' responses: @@ -69,6 +72,7 @@ security: - basic: [] - token: [] + - oauth2: [] parameters: - $ref: '#/components/parameters/to' responses: @@ -91,6 +95,7 @@ security: - basic: [] - token: [] + - oauth2: [] parameters: - $ref: '#/components/parameters/to' responses: @@ -112,6 +117,7 @@ security: - basic: [] - token: [] + - oauth2: [] parameters: - $ref: '#/components/parameters/to' responses: @@ -126,6 +132,7 @@ security: - basic: [] - token: [] + - oauth2: [] parameters: - $ref: '#/components/parameters/to' responses: @@ -140,6 +147,7 @@ security: - basic: [] - token: [] + - oauth2: [] parameters: - $ref: '#/components/parameters/to' - name: type @@ -160,6 +168,7 @@ security: - basic: [] - token: [] + - oauth2: [] parameters: - $ref: '#/components/parameters/to' - name: with @@ -211,6 +220,7 @@ security: - basic: [] - token: [] + - oauth2: [] parameters: - $ref: '#/components/parameters/to' responses: @@ -225,6 +235,7 @@ security: - basic: [] - token: [] + - oauth2: [] parameters: - $ref: '#/components/parameters/to' responses: @@ -239,6 +250,7 @@ security: - basic: [] - token: [] + - oauth2: [] parameters: - $ref: '#/components/parameters/to' responses: @@ -1411,6 +1423,18 @@ description: Use JID as username. scheme: Basic type: http + oauth2: + description: Needs mod_http_oauth2 + type: oauth2 + flows: + authorizationCode: + authorizationUrl: https://example.com/oauth2/authorize + tokenUrl: https://example.com/oauth2/token + scopes: + prosody:restricted: Restricted account + prosody:user: Regular user privileges + prosody:admin: Administrator privileges + prosody:operator: Server operator privileges requestBodies: common: