Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
f8290c82
Commit
f8290c82
authored
Sep 29, 2015
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(captiveportal, new) add authenticated_via metadata to allow action
parent
ebc96f66
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
6 deletions
+8
-6
allow.py
src/opnsense/scripts/OPNsense/CaptivePortal/allow.py
+2
-2
db.py
src/opnsense/scripts/OPNsense/CaptivePortal/lib/db.py
+5
-3
actions_captiveportal.conf
...pnsense/service/conf/actions.d/actions_captiveportal.conf
+1
-1
No files found.
src/opnsense/scripts/OPNsense/CaptivePortal/allow.py
View file @
f8290c82
...
...
@@ -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
'
%20
s
%
s'
%
(
item
,
response
[
item
])
else
:
print
(
ujson
.
dumps
(
response
))
src/opnsense/scripts/OPNsense/CaptivePortal/lib/db.py
View file @
f8290c82
...
...
@@ -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
...
...
src/opnsense/service/conf/actions.d/actions_captiveportal.conf
View file @
f8290c82
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment