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
5cc2b001
Commit
5cc2b001
authored
Sep 30, 2015
by
Ad Schellevis
Committed by
Franco Fichtner
Oct 01, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(captiveportal, new) add X-Forwarded-For to access controller
(cherry picked from commit
a7033f22
)
parent
41d30cb5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
10 deletions
+22
-10
AccessController.php
...ntrollers/OPNsense/CaptivePortal/Api/AccessController.php
+22
-10
No files found.
src/opnsense/mvc/app/controllers/OPNsense/CaptivePortal/Api/AccessController.php
View file @
5cc2b001
...
...
@@ -55,7 +55,7 @@ class AccessController extends ApiControllerBase
if
(
$allClients
!=
null
)
{
// search for client by ip address
foreach
(
$allClients
as
$connectedClient
)
{
if
(
$connectedClient
[
'ipAddress'
]
==
$this
->
request
->
getClientAddress
())
{
if
(
$connectedClient
[
'ipAddress'
]
==
$this
->
getClientIp
())
{
// client is authorized in this zone according to our administration
$connectedClient
[
'clientState'
]
=
'AUTHORIZED'
;
return
$connectedClient
;
...
...
@@ -64,7 +64,22 @@ class AccessController extends ApiControllerBase
}
// return Unauthorized
return
array
(
'clientState'
=>
"NOT_AUTHORIZED"
,
"ipAddress"
=>
$this
->
request
->
getClientAddress
());
return
array
(
'clientState'
=>
"NOT_AUTHORIZED"
,
"ipAddress"
=>
$this
->
getClientIp
());
}
/**
* determine clients ip address
*/
private
function
getClientIp
()
{
// determine orginal sender of this request
if
(
$this
->
request
->
getHeader
(
'X-Forwarded-For'
)
!=
""
)
{
// use X-Forwarded-For header to determine real client
return
$this
->
request
->
getHeader
(
'X-Forwarded-For'
);
}
else
{
// client accesses the Api directly
return
$this
->
request
->
getClientAddress
();
}
}
/**
...
...
@@ -87,6 +102,7 @@ class AccessController extends ApiControllerBase
*/
public
function
logonAction
(
$zoneid
=
0
)
{
$clientIp
=
$this
->
getClientIp
();
if
(
$this
->
request
->
isOptions
())
{
// return empty result on CORS preflight
return
array
();
...
...
@@ -131,7 +147,7 @@ class AccessController extends ApiControllerBase
"captiveportal allow"
,
array
((
string
)
$cpZone
->
zoneid
,
$userName
,
$
this
->
request
->
getClientAddress
()
,
$
clientIp
,
$authServerName
,
'json'
)
);
...
...
@@ -143,16 +159,12 @@ class AccessController extends ApiControllerBase
}
}
}
else
{
return
array
(
"clientState"
=>
'NOT_AUTHORIZED'
,
"ipAddress"
=>
$this
->
request
->
getClientAddress
()
);
return
array
(
"clientState"
=>
'NOT_AUTHORIZED'
,
"ipAddress"
=>
$clientIp
);
}
}
}
return
array
(
"clientState"
=>
'UNKNOWN'
,
"ipAddress"
=>
$this
->
request
->
getClientAddress
()
);
return
array
(
"clientState"
=>
'UNKNOWN'
,
"ipAddress"
=>
$clientIp
);
}
...
...
@@ -182,7 +194,7 @@ class AccessController extends ApiControllerBase
}
}
}
return
array
(
"clientState"
=>
"UNKNOWN"
,
"ipAddress"
=>
$this
->
request
->
getClientAddress
());
return
array
(
"clientState"
=>
"UNKNOWN"
,
"ipAddress"
=>
$this
->
getClientIp
());
}
/**
...
...
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