Software /
code /
prosody-modules
Changeset
5207:c72e3b0914e8
mod_http_oauth: Factor out issuer URL calculation to a helper function
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 06 Mar 2023 09:40:17 +0000 |
parents | 5206:31c62df82aa8 |
children | 5208:aaa64c647e12 |
files | mod_http_oauth2/mod_http_oauth2.lua |
diffstat | 1 files changed, 6 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_http_oauth2/mod_http_oauth2.lua Sun Mar 05 12:38:20 2023 +0100 +++ b/mod_http_oauth2/mod_http_oauth2.lua Mon Mar 06 09:40:17 2023 +0000 @@ -66,6 +66,10 @@ return code and code_expires_in(code) + 1 or 900; end) +local function get_issuer() + return (module:http_url(nil, "/"):gsub("/$", "")); +end + local function oauth_error(err_name, err_desc) return errors.new({ type = "modify"; @@ -159,7 +163,7 @@ local query = http.formdecode(redirect.query or ""); if type(query) ~= "table" then query = {}; end table.insert(query, { name = "code", value = code }); - table.insert(query, { name = "iss", value = module:http_url(nil, "/"):gsub("/$", "") }); + table.insert(query, { name = "iss", value = get_issuer() }); if params.state then table.insert(query, { name = "state", value = params.state }); end @@ -474,7 +478,7 @@ ["GET"] = { headers = { content_type = "application/json" }; body = json.encode { - issuer = module:http_url(nil, "/"):gsub("/$", ""); + issuer = get_issuer(); authorization_endpoint = handle_authorization_request and module:http_url() .. "/authorize" or nil; token_endpoint = handle_token_grant and module:http_url() .. "/token" or nil; jwks_uri = nil; -- TODO?