mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-10-30 01:52:51 +00:00
uspot: handler-uam: improve auth-client()
Simplify the query string parsing logic, allow empty password. Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
This commit is contained in:
committed by
John Crispin
parent
0a390bea0b
commit
78c7a3cbfa
@@ -13,21 +13,16 @@ function auth_client(ctx) {
|
|||||||
let payload = portal.radius_init(ctx);
|
let payload = portal.radius_init(ctx);
|
||||||
|
|
||||||
payload.logoff_url = sprintf('http://%s:%s/logoff', ctx.env.SERVER_ADDR, ctx.config.uam_port);
|
payload.logoff_url = sprintf('http://%s:%s/logoff', ctx.env.SERVER_ADDR, ctx.config.uam_port);
|
||||||
if (ctx.query_string.username && ctx.query_string.password && !ctx.config.uam_secret) {
|
if (ctx.query_string.username) { // username must be set
|
||||||
payload.username = ctx.query_string.username;
|
payload.username = ctx.query_string.username;
|
||||||
payload.password = ctx.query_string.password;
|
if (ctx.query_string.response) { // try challenge first
|
||||||
} else if (ctx.query_string.username && ctx.query_string.response) {
|
let challenge = uam.md5(ctx.config.challenge, ctx.format_mac);
|
||||||
let challenge = uam.md5(ctx.config.challenge, ctx.format_mac);
|
payload.chap_password = ctx.query_string.response;
|
||||||
|
payload.chap_challenge = ctx.config.secret ? uam.chap_challenge(challenge, ctx.config.uam_secret) : challenge;
|
||||||
payload.username = ctx.query_string.username;
|
} else if ("password" in ctx.query_string) { // allow empty password
|
||||||
payload.chap_password = ctx.query_string.response;
|
payload.password = !ctx.config_uam_secret ? ctx.query_string.password :
|
||||||
if (ctx.config.secret)
|
uam.password(uam.md5(ctx.config.challenge, ctx.format_mac), ctx.query_string.password, ctx.config.uam_secret);
|
||||||
payload.chap_challenge = uam.chap_challenge(challenge, ctx.config.uam_secret);
|
}
|
||||||
else
|
|
||||||
payload.chap_challenge = challenge;
|
|
||||||
} else if (ctx.query_string.username && ctx.query_string.password) {
|
|
||||||
payload.username = ctx.query_string.username;
|
|
||||||
payload.password = uam.password(uam.md5(ctx.config.challenge, ctx.format_mac), ctx.query_string.password, ctx.config.uam_secret);
|
|
||||||
} else {
|
} else {
|
||||||
include('error.uc', ctx);
|
include('error.uc', ctx);
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user