Software /
code /
prosody-modules
Changeset
5188:7c531137a553
mod_http_oauth2: Implement OOB special redirect URI in code flow
Aka "copy and paste this into your client"
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 02 Mar 2023 23:59:09 +0100 |
parents | 5187:6a3c1febd7be |
children | 5189:4ee8eb1134a8 |
files | mod_http_oauth2/mod_http_oauth2.lua |
diffstat | 1 files changed, 14 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_http_oauth2/mod_http_oauth2.lua Thu Mar 02 23:57:29 2023 +0100 +++ b/mod_http_oauth2/mod_http_oauth2.lua Thu Mar 02 23:59:09 2023 +0100 @@ -119,7 +119,20 @@ return {status_code = 429}; end - local redirect = url.parse(params.redirect_uri or client.redirect_uri); + local redirect_uri = params.redirect_uri or client.redirect_uri; + if redirect_uri == "urn:ietf:wg:oauth:2.0:oob" then + -- TODO some nicer template page + local response = { status_code = 200; headers = { content_type = "text/plain" } } + response.body = module:context("*"):fire_event("http-message", { + response = response; + title = "Your authorization code"; + message = "Here's your authorization code, copy and paste it into your app:"; + extra = code; + }) or ("Here's your authorization code:\n%s\n"):format(code); + end + + local redirect = url.parse(redirect_uri); + local query = http.formdecode(redirect.query or ""); if type(query) ~= "table" then query = {}; end table.insert(query, { name = "code", value = code })