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
67415c33
Commit
67415c33
authored
Oct 19, 2015
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(Captiveportal, new) move zoneid from redirect url to generated zone javascript file
parent
d87ca5d2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
8 deletions
+16
-8
index.html
.../scripts/OPNsense/CaptivePortal/htdocs_default/index.html
+3
-1
overlay_template.py
...nsense/scripts/OPNsense/CaptivePortal/overlay_template.py
+8
-2
lighttpd-zone.conf
...rvice/templates/OPNsense/Captiveportal/lighttpd-zone.conf
+5
-5
No files found.
src/opnsense/scripts/OPNsense/CaptivePortal/htdocs_default/index.html
View file @
67415c33
...
@@ -16,6 +16,8 @@
...
@@ -16,6 +16,8 @@
<link
href=
"css/bootstrap.min.css"
rel=
"stylesheet"
>
<link
href=
"css/bootstrap.min.css"
rel=
"stylesheet"
>
<link
href=
"css/signin.css"
rel=
"stylesheet"
>
<link
href=
"css/signin.css"
rel=
"stylesheet"
>
<script
type=
"text/javascript"
src=
"js/zone.js"
></script>
<script
type=
"text/javascript"
src=
"js/jquery-1.11.2.min.js"
></script>
<script
type=
"text/javascript"
src=
"js/jquery-1.11.2.min.js"
></script>
<script>
<script>
function
getURLparams
()
function
getURLparams
()
...
@@ -42,7 +44,7 @@
...
@@ -42,7 +44,7 @@
// try to login
// try to login
$
.
ajax
({
$
.
ajax
({
type
:
"
POST
"
,
type
:
"
POST
"
,
url
:
"
/api/captiveportal/access/logon
"
,
url
:
"
/api/captiveportal/access/logon
/
"
+
zoneid
+
"
/
"
,
dataType
:
"
json
"
,
dataType
:
"
json
"
,
data
:{
user
:
$
(
"
#inputUsername
"
).
val
(),
password
:
$
(
"
#inputPassword
"
).
val
()
}
data
:{
user
:
$
(
"
#inputUsername
"
).
val
(),
password
:
$
(
"
#inputPassword
"
).
val
()
}
}).
done
(
function
(
data
)
{
}).
done
(
function
(
data
)
{
...
...
src/opnsense/scripts/OPNsense/CaptivePortal/overlay_template.py
View file @
67415c33
...
@@ -39,10 +39,11 @@ from lib import Config
...
@@ -39,10 +39,11 @@ from lib import Config
if
len
(
sys
.
argv
)
>
1
:
if
len
(
sys
.
argv
)
>
1
:
cnf
=
Config
()
cnf
=
Config
()
target_directory
=
'/var/captiveportal/zone
%
s/htdocs/'
%
sys
.
argv
[
1
]
zoneid
=
sys
.
argv
[
1
]
target_directory
=
'/var/captiveportal/zone
%
s/htdocs/'
%
zoneid
template_data
=
cnf
.
fetch_template_data
(
sys
.
argv
[
1
])
template_data
=
cnf
.
fetch_template_data
(
sys
.
argv
[
1
])
if
template_data
is
not
None
and
len
(
template_data
)
>
20
:
if
template_data
is
not
None
and
len
(
template_data
)
>
20
:
print
(
'overlay user template package for zone
%
s'
%
sys
.
argv
[
1
]
)
print
(
'overlay user template package for zone
%
s'
%
zoneid
)
zip_content
=
template_data
.
decode
(
'base64'
)
zip_content
=
template_data
.
decode
(
'base64'
)
input_data
=
StringIO
.
StringIO
(
zip_content
)
input_data
=
StringIO
.
StringIO
(
zip_content
)
with
zipfile
.
ZipFile
(
input_data
,
mode
=
'r'
,
compression
=
zipfile
.
ZIP_DEFLATED
)
as
zf_in
:
with
zipfile
.
ZipFile
(
input_data
,
mode
=
'r'
,
compression
=
zipfile
.
ZIP_DEFLATED
)
as
zf_in
:
...
@@ -54,5 +55,10 @@ if len(sys.argv) > 1:
...
@@ -54,5 +55,10 @@ if len(sys.argv) > 1:
os
.
makedirs
(
file_target_directory
)
os
.
makedirs
(
file_target_directory
)
with
open
(
target_filename
,
'wb'
)
as
f_out
:
with
open
(
target_filename
,
'wb'
)
as
f_out
:
f_out
.
write
(
zf_in
.
read
(
zf_info
.
filename
))
f_out
.
write
(
zf_in
.
read
(
zf_info
.
filename
))
# write zone settings
filename
=
'
%
sjs/zone.js'
%
target_directory
with
open
(
filename
,
'wb'
)
as
f_out
:
f_out
.
write
(
'var zoneid =
%
s'
%
zoneid
)
os
.
chmod
(
filename
,
0444
)
sys
.
exit
(
0
)
sys
.
exit
(
0
)
src/opnsense/service/templates/OPNsense/Captiveportal/lighttpd-zone.conf
View file @
67415c33
...
@@ -23,10 +23,10 @@
...
@@ -23,10 +23,10 @@
{
# generate zone redirect address #}
{
# generate zone redirect address #}
{%
if
cp_zone_item
.
certificate
|
default
(
""
) !=
""
%}
{%
if
cp_zone_item
.
certificate
|
default
(
""
) !=
""
%}
# ssl enabled, redirect to https
# ssl enabled, redirect to https
{%
do
cp_zone_item
.
update
({
'redirect_host'
:
'https://'
+
cp_zone_item
.
interface_hostaddr
+
':'
~ (
cp_zone_item
.
zoneid
|
int
+
8000
) ~
'/index.html
?zone='
~
cp_zone_item
.
zoneid
}) %}
{%
do
cp_zone_item
.
update
({
'redirect_host'
:
'https://'
+
cp_zone_item
.
interface_hostaddr
+
':'
~ (
cp_zone_item
.
zoneid
|
int
+
8000
) ~
'/index.html
'
}) %}
{%
else
%}
{%
else
%}
# ssl disabled, redirect to http
# ssl disabled, redirect to http
{%
do
cp_zone_item
.
update
({
'redirect_host'
:
'http://'
+
cp_zone_item
.
interface_hostaddr
+
':'
~ (
cp_zone_item
.
zoneid
|
int
+
8000
) ~
'/index.html
?zone='
~
cp_zone_item
.
zoneid
}) %}
{%
do
cp_zone_item
.
update
({
'redirect_host'
:
'http://'
+
cp_zone_item
.
interface_hostaddr
+
':'
~ (
cp_zone_item
.
zoneid
|
int
+
8000
) ~
'/index.html
'
}) %}
{%
endif
%}
{%
endif
%}
{%
do
cp_zone_item
.
update
({
'redirect_host_match'
:
cp_zone_item
.
interface_hostaddr
.
replace
(
'.'
,
'\.'
) ~
':'
~ (
cp_zone_item
.
zoneid
|
int
+
8000
) }) %}
{%
do
cp_zone_item
.
update
({
'redirect_host_match'
:
cp_zone_item
.
interface_hostaddr
.
replace
(
'.'
,
'\.'
) ~
':'
~ (
cp_zone_item
.
zoneid
|
int
+
8000
) }) %}
...
@@ -81,19 +81,19 @@ server.port = {{ cp_zone_item.zoneid|int + 8000 }}
...
@@ -81,19 +81,19 @@ server.port = {{ cp_zone_item.zoneid|int + 8000 }}
##
##
$
HTTP
[
"host"
] !~
"(.*{{cp_zone_item.redirect_host_match}}.*)"
{
$
HTTP
[
"host"
] !~
"(.*{{cp_zone_item.redirect_host_match}}.*)"
{
$
HTTP
[
"host"
] =~
"([^:/]+)"
{
$
HTTP
[
"host"
] =~
"([^:/]+)"
{
url
.
redirect
= (
"^(.*)$"
=>
"{{cp_zone_item.redirect_host}}
&
redirurl=%1$1"
)
url
.
redirect
= (
"^(.*)$"
=>
"{{cp_zone_item.redirect_host}}
?
redirurl=%1$1"
)
}
}
}
}
## redirect http traffic to http(s) main target
## redirect http traffic to http(s) main target
$
SERVER
[
"socket"
] ==
":{{ cp_zone_item.zoneid|int + 9000 }}"
{
$
SERVER
[
"socket"
] ==
":{{ cp_zone_item.zoneid|int + 9000 }}"
{
$
HTTP
[
"host"
] =~
"([^:/]+)"
{
$
HTTP
[
"host"
] =~
"([^:/]+)"
{
url
.
redirect
= (
"^(.*)$"
=>
"{{cp_zone_item.redirect_host}}
&
redirurl=%1$1"
)
url
.
redirect
= (
"^(.*)$"
=>
"{{cp_zone_item.redirect_host}}
?
redirurl=%1$1"
)
}
}
}
}
$
SERVER
[
"socket"
] ==
"[::]:{{ cp_zone_item.zoneid|int + 9000 }}"
{
$
SERVER
[
"socket"
] ==
"[::]:{{ cp_zone_item.zoneid|int + 9000 }}"
{
$
HTTP
[
"host"
] =~
"([^:/]+)"
{
$
HTTP
[
"host"
] =~
"([^:/]+)"
{
url
.
redirect
= (
"(.*)"
=>
"{{cp_zone_item.redirect_host}}
&
redirurl=%1$1"
)
url
.
redirect
= (
"(.*)"
=>
"{{cp_zone_item.redirect_host}}
?
redirurl=%1$1"
)
}
}
}
}
...
...
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