Commit f8290c82 authored by Ad Schellevis's avatar Ad Schellevis

(captiveportal, new) add authenticated_via metadata to allow action

parent ebc96f66
......@@ -35,7 +35,7 @@ from lib.arp import ARP
from lib.ipfw import IPFW
# parse input parameters
parameters = {'username': '', 'ip_address': None, 'zoneid': None, 'output_type':'plain'}
parameters = {'username': '', 'ip_address': None, 'zoneid': None,'authenticated_via': None, 'output_type':'plain'}
current_param = None
for param in sys.argv[1:]:
if len(param) > 1 and param[0] == '/':
......@@ -56,6 +56,7 @@ if parameters['ip_address'] is not None and parameters['zoneid'] is not None:
mac_address = None
response = cpDB.add_client(zoneid=parameters['zoneid'],
authenticated_via=parameters['authenticated_via'],
username=parameters['username'],
ip_address=parameters['ip_address'],
mac_address=mac_address
......@@ -77,4 +78,3 @@ if parameters['output_type'] != 'json':
print '%20s %s' % (item, response[item])
else:
print(ujson.dumps(response))
......@@ -58,7 +58,7 @@ class DB(object):
cur.executescript(open(init_script_filename, 'rb').read())
cur.close()
def add_client(self, zoneid, username, ip_address, mac_address):
def add_client(self, zoneid, authenticated_via, username, ip_address, mac_address):
""" add a new client to the captive portal administration
:param zoneid: cp zone number
:param username: username, maybe empty
......@@ -68,6 +68,7 @@ class DB(object):
"""
response = dict()
response['zoneid'] = zoneid
response['authenticated_via'] = authenticated_via
response['userName'] = username
response['ipAddress'] = ip_address
response['macAddress'] = mac_address
......@@ -83,8 +84,8 @@ class DB(object):
""", response)
# add new session
cur.execute("""insert into cp_clients(zoneid, sessionid, username, ip_address, mac_address, created)
values (:zoneid, :sessionId, :userName, :ipAddress, :macAddress, :startTime)
cur.execute("""insert into cp_clients(zoneid, authenticated_via, sessionid, username, ip_address, mac_address, created)
values (:zoneid, :authenticated_via, :sessionId, :userName, :ipAddress, :macAddress, :startTime)
""", response)
self._connection.commit()
......@@ -129,6 +130,7 @@ class DB(object):
# rename fields for API
cur.execute(""" select cc.zoneid
, cc.sessionid sessionId
, cc.authenticated_via authenticated_via
, cc.username userName
, cc.created startTime
, cc.ip_address ipAddress
......
......@@ -6,7 +6,7 @@ message:list registered clients
[allow]
command:/usr/local/opnsense/scripts/OPNsense/CaptivePortal/allow.py
parameters:/zoneid %s /username %s /ip_address %s /output_type %s
parameters:/zoneid %s /username %s /ip_address %s /authenticated_via %s /output_type %s
type:script_output
message:allow client access to captive portal
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment