Software / code / prosody
Comparison
plugins/mod_auth_internal_hashed.lua @ 12916:5a06d07596f9
mod_auth_internal_hashed: Add oauthbearer handler to our SASL profile
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Wed, 01 Mar 2023 13:05:17 +0000 |
| parent | 12903:13950bf92802 |
| child | 12933:3ab0bbb1dc35 |
comparison
equal
deleted
inserted
replaced
| 12915:70f6a8dceb1d | 12916:5a06d07596f9 |
|---|---|
| 27 local get_auth_db = assert(scram_hashers[hash_name], "SCRAM-"..hash_name.." not supported by SASL library"); | 27 local get_auth_db = assert(scram_hashers[hash_name], "SCRAM-"..hash_name.." not supported by SASL library"); |
| 28 local scram_name = "scram_"..hash_name:gsub("%-","_"):lower(); | 28 local scram_name = "scram_"..hash_name:gsub("%-","_"):lower(); |
| 29 | 29 |
| 30 -- Default; can be set per-user | 30 -- Default; can be set per-user |
| 31 local default_iteration_count = module:get_option_number("default_iteration_count", 10000); | 31 local default_iteration_count = module:get_option_number("default_iteration_count", 10000); |
| 32 | |
| 33 local tokenauth = module:depends("tokenauth"); | |
| 32 | 34 |
| 33 -- define auth provider | 35 -- define auth provider |
| 34 local provider = {}; | 36 local provider = {}; |
| 35 | 37 |
| 36 function provider.test_password(username, password) | 38 function provider.test_password(username, password) |
| 176 local stored_key, server_key = credentials.stored_key, credentials.server_key; | 178 local stored_key, server_key = credentials.stored_key, credentials.server_key; |
| 177 local iteration_count, salt = credentials.iteration_count, credentials.salt; | 179 local iteration_count, salt = credentials.iteration_count, credentials.salt; |
| 178 stored_key = stored_key and from_hex(stored_key); | 180 stored_key = stored_key and from_hex(stored_key); |
| 179 server_key = server_key and from_hex(server_key); | 181 server_key = server_key and from_hex(server_key); |
| 180 return stored_key, server_key, iteration_count, salt, not credentials.disabled; | 182 return stored_key, server_key, iteration_count, salt, not credentials.disabled; |
| 181 end | 183 end; |
| 184 oauthbearer = tokenauth.sasl_handler(provider, "oauth2", module:shared("tokenauth/oauthbearer_config")); | |
| 182 }; | 185 }; |
| 183 return new_sasl(host, testpass_authentication_profile); | 186 return new_sasl(host, testpass_authentication_profile); |
| 184 end | 187 end |
| 185 | 188 |
| 186 module:provides("auth", provider); | 189 module:provides("auth", provider); |