diff --git a/feeds/ucentral/uspot/files/usr/share/uspot/handler.uc b/feeds/ucentral/uspot/files/usr/share/uspot/handler.uc index 0fff13147..6536a86c7 100644 --- a/feeds/ucentral/uspot/files/usr/share/uspot/handler.uc +++ b/feeds/ucentral/uspot/files/usr/share/uspot/handler.uc @@ -19,6 +19,19 @@ function request_start(ctx) { include('radius.uc', ctx); return; case 'uam': + if (portal.config?.uam.mac_auth) { + let payload = portal.radius_init(ctx); + payload.username = ctx.format_mac; + payload.password = ctx.format_mac; + payload.service_type = 2; + let radius = portal.radius_call(ctx, payload); + if (radius['access-accept']) { + if (portal.config.uam.final_redirect_url == 'uam') + ctx.query_string.userurl = portal.uam_url(ctx, 'success'); + portal.allow_client(ctx, { radius: { reply: radius.reply, request: payload } } ); + return; + } + } ctx.redir_location = portal.uam_url(ctx, 'notyet'); include('redir.uc', ctx); return; diff --git a/feeds/ucentral/uspot/src/radius.c b/feeds/ucentral/uspot/src/radius.c index f63596b4e..0fac61ebf 100644 --- a/feeds/ucentral/uspot/src/radius.c +++ b/feeds/ucentral/uspot/src/radius.c @@ -33,6 +33,7 @@ enum { RADIUS_OUTPUT_PACKETS, RADIUS_LOGOFF_URL, RADIUS_CLASS, + RADIUS_SERVICE_TYPE, __RADIUS_MAX, }; @@ -61,6 +62,7 @@ static const struct blobmsg_policy radius_policy[__RADIUS_MAX] = { [RADIUS_OUTPUT_PACKETS] = { .name = "output_packets", .type = BLOBMSG_TYPE_INT32 }, [RADIUS_LOGOFF_URL] = { .name = "logoff_url", .type = BLOBMSG_TYPE_STRING }, [RADIUS_CLASS] = { .name = "class", .type = BLOBMSG_TYPE_STRING }, + [RADIUS_SERVICE_TYPE] = { .name = "service_type", .type = BLOBMSG_TYPE_INT32 }, }; static struct blob_buf b = {}; @@ -138,7 +140,7 @@ radius(void) rc_add_config(rh, "acctserver", blobmsg_get_string(tb[RADIUS_ACCT_SERVER]), "code", __LINE__); rc_add_config(rh, "servers", "/tmp/radius.servers", "code", __LINE__); rc_add_config(rh, "dictionary", "/etc/radcli/dictionary", "code", __LINE__); - rc_add_config(rh, "radius_timeout", "2", "code", __LINE__); + rc_add_config(rh, "radius_timeout", "5", "code", __LINE__); rc_add_config(rh, "radius_retries", "1", "code", __LINE__); rc_add_config(rh, "bindaddr", "*", "code", __LINE__); @@ -253,6 +255,12 @@ radius(void) return result(rh, 0, NULL); } + if (tb[RADIUS_SERVICE_TYPE]) { + val = blobmsg_get_u32(tb[RADIUS_SERVICE_TYPE]); + if (rc_avpair_add(rh, &send, PW_SERVICE_TYPE, &val, 4, 0) == NULL) + return result(rh, 0, NULL); + } + if (tb[RADIUS_CLASS]) if (rc_avpair_add(rh, &send, PW_CLASS, blobmsg_get_string(tb[RADIUS_CLASS]), -1, 0) == NULL) return result(rh, 0, NULL);