various captive portal improvements

Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
John Crispin
2022-09-28 14:43:45 +02:00
parent 81a74ccd8c
commit 0fbe7d51ee
7 changed files with 92 additions and 1 deletions

View File

@@ -28,6 +28,7 @@ else {
set uspot.config.auth_mode={{ s(captive.auth_mode) }} set uspot.config.auth_mode={{ s(captive.auth_mode) }}
set uspot.config.web_root={{ b(captive.web_root) }} set uspot.config.web_root={{ b(captive.web_root) }}
set uspot.config.idle_timeout={{ captive.idle_timeout }}
{% if (captive.auth_mode in [ 'radius', 'uam']): %} {% if (captive.auth_mode in [ 'radius', 'uam']): %}
set uspot.radius.auth_server={{ s(captive.auth_server) }} set uspot.radius.auth_server={{ s(captive.auth_server) }}
@@ -36,6 +37,7 @@ set uspot.radius.auth_secret={{ s(captive.auth_secret) }}
set uspot.radius.acct_server={{ s(captive.acct_server) }} set uspot.radius.acct_server={{ s(captive.acct_server) }}
set uspot.radius.acct_port={{ s(captive.acct_port) }} set uspot.radius.acct_port={{ s(captive.acct_port) }}
set uspot.radius.acct_secret={{ s(captive.acct_secret) }} set uspot.radius.acct_secret={{ s(captive.acct_secret) }}
set uspot.radius.acct_interval={{ captive.acct_interval }}
{% endif %} {% endif %}
{% if (captive.auth_mode == 'uam'): %} {% if (captive.auth_mode == 'uam'): %}
@@ -44,6 +46,7 @@ set uspot.uam.uam_secret={{ s(captive.uam_secret) }}
set uspot.uam.uam_server={{ s(captive.uam_server) }} set uspot.uam.uam_server={{ s(captive.uam_server) }}
set uspot.uam.nasid={{ s(captive.nasid) }} set uspot.uam.nasid={{ s(captive.nasid) }}
set uspot.uam.nasmac={{ s(captive.nasmac || serial) }} set uspot.uam.nasmac={{ s(captive.nasmac || serial) }}
set uspot.uam.ssid={{ s(captive.ssid) }}
{% {%
let math = require('math'); let math = require('math');
@@ -144,4 +147,5 @@ add_list uhttpd.@uhttpd[-1].listen_http='0.0.0.0:{{ captive.uam_port }}'
add_list uhttpd.@uhttpd[-1].listen_http='[::]:{{ captive.uam_port }}' add_list uhttpd.@uhttpd[-1].listen_http='[::]:{{ captive.uam_port }}'
set uhttpd.@uhttpd[-1].home=/tmp/ucentral/www-uspot set uhttpd.@uhttpd[-1].home=/tmp/ucentral/www-uspot
add_list uhttpd.@uhttpd[-1].ucode_prefix='/logon=/usr/share/uspot/handler-uam.uc' add_list uhttpd.@uhttpd[-1].ucode_prefix='/logon=/usr/share/uspot/handler-uam.uc'
add_list uhttpd.@uhttpd[-1].ucode_prefix='/logoff=/usr/share/uspot/handler-uam.uc'
{% endif %} {% endif %}

View File

@@ -14,7 +14,7 @@ let config = {
config: { config: {
default_class: 0, default_class: 0,
default_dns_class: 1, default_dns_class: 1,
client_autoremove: 0, client_autoremove: false,
class: [ class: [
{ {
index: 0, index: 0,

View File

@@ -48,3 +48,8 @@ properties:
type: string type: string
examples: examples:
- secret - secret
acct-interval:
description:
The timeout used for interim messages.
type: integer
default: 600

View File

@@ -72,3 +72,12 @@ properties:
type: string type: string
examples: examples:
- secret - secret
acct-interval:
description:
The timeout used for interim messages.
type: integer
default: 600
ssid:
description:
The name of the SSID that shall be sent as part of the UAM redirect.
type: string

View File

@@ -17,3 +17,8 @@ allOf:
A base64 encoded TAR file with the custom web-root. A base64 encoded TAR file with the custom web-root.
type: string type: string
format: uc-base64 format: uc-base64
idle-timeout:
description:
How long may a client be idle before getting removed.
type: integer
default: 600

View File

@@ -7244,6 +7244,20 @@ function instantiateServiceCaptiveRadius(location, value, errors) {
obj.acct_secret = parseAcctSecret(location + "/acct-secret", value["acct-secret"], errors); obj.acct_secret = parseAcctSecret(location + "/acct-secret", value["acct-secret"], errors);
} }
function parseAcctInterval(location, value, errors) {
if (type(value) != "int")
push(errors, [ location, "must be of type integer" ]);
return value;
}
if (exists(value, "acct-interval")) {
obj.acct_interval = parseAcctInterval(location + "/acct-interval", value["acct-interval"], errors);
}
else {
obj.acct_interval = 600;
}
return obj; return obj;
} }
@@ -7517,6 +7531,31 @@ function instantiateServiceCaptiveUam(location, value, errors) {
obj.acct_secret = parseAcctSecret(location + "/acct-secret", value["acct-secret"], errors); obj.acct_secret = parseAcctSecret(location + "/acct-secret", value["acct-secret"], errors);
} }
function parseAcctInterval(location, value, errors) {
if (type(value) != "int")
push(errors, [ location, "must be of type integer" ]);
return value;
}
if (exists(value, "acct-interval")) {
obj.acct_interval = parseAcctInterval(location + "/acct-interval", value["acct-interval"], errors);
}
else {
obj.acct_interval = 600;
}
function parseSsid(location, value, errors) {
if (type(value) != "string")
push(errors, [ location, "must be of type string" ]);
return value;
}
if (exists(value, "ssid")) {
obj.ssid = parseSsid(location + "/ssid", value["ssid"], errors);
}
return obj; return obj;
} }
@@ -7666,6 +7705,20 @@ function instantiateServiceCaptive(location, value, errors) {
obj.web_root = parseWebRoot(location + "/web-root", value["web-root"], errors); obj.web_root = parseWebRoot(location + "/web-root", value["web-root"], errors);
} }
function parseIdleTimeout(location, value, errors) {
if (type(value) != "int")
push(errors, [ location, "must be of type integer" ]);
return value;
}
if (exists(value, "idle-timeout")) {
obj.idle_timeout = parseIdleTimeout(location + "/idle-timeout", value["idle-timeout"], errors);
}
else {
obj.idle_timeout = 600;
}
return obj; return obj;
} }

View File

@@ -2640,6 +2640,10 @@
"examples": [ "examples": [
"secret" "secret"
] ]
},
"acct-interval": {
"type": "integer",
"default": 600
} }
} }
}, },
@@ -2728,6 +2732,13 @@
"examples": [ "examples": [
"secret" "secret"
] ]
},
"acct-interval": {
"type": "integer",
"default": 600
},
"ssid": {
"type": "string"
} }
} }
}, },
@@ -2761,6 +2772,10 @@
"web-root": { "web-root": {
"type": "string", "type": "string",
"format": "uc-base64" "format": "uc-base64"
},
"idle-timeout": {
"type": "integer",
"default": 600
} }
} }
} }