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
d98b45a6
Commit
d98b45a6
authored
May 19, 2015
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(mvc) add some logging to the api
parent
63b476a1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
0 deletions
+16
-0
ApiControllerBase.php
...e/mvc/app/controllers/OPNsense/Base/ApiControllerBase.php
+16
-0
No files found.
src/opnsense/mvc/app/controllers/OPNsense/Base/ApiControllerBase.php
View file @
d98b45a6
...
...
@@ -30,6 +30,7 @@ namespace OPNsense\Base;
use
OPNsense\Core\ACL
;
use
Phalcon\Mvc\Controller
;
use
Phalcon\Logger\Adapter\Syslog
;
/**
* Class ApiControllerBase, inherit this class to implement API calls
...
...
@@ -54,6 +55,17 @@ class ApiControllerBase extends Controller
session_write_close
();
}
protected
function
getLogger
(
$ident
=
"api"
)
{
$logger
=
new
Syslog
(
$ident
,
array
(
'option'
=>
LOG_PID
,
'facility'
=>
LOG_LOCAL4
));
return
$logger
;
}
/**
* before routing event
* @param Dispatcher $dispatcher
...
...
@@ -65,12 +77,15 @@ class ApiControllerBase extends Controller
// use authentication of legacy OPNsense to validate user.
if
(
$this
->
session
->
has
(
"Username"
)
==
false
)
{
$this
->
getLogger
()
->
error
(
"no active session, user not found"
);
$this
->
response
->
redirect
(
"/"
,
true
);
}
// Authorization using legacy acl structure
$acl
=
new
ACL
();
if
(
!
$acl
->
isPageAccessible
(
$this
->
session
->
get
(
"Username"
),
$_SERVER
[
'REQUEST_URI'
]))
{
$this
->
getLogger
()
->
error
(
"uri "
.
$_SERVER
[
'REQUEST_URI'
]
.
" not accessible for user "
.
$this
->
session
->
get
(
"Username"
));
$this
->
response
->
redirect
(
"/"
,
true
);
}
...
...
@@ -85,6 +100,7 @@ class ApiControllerBase extends Controller
)
&&
!
$csrf_valid
)
{
// missing csrf, exit.
$this
->
getLogger
()
->
error
(
"no matching csrf found for request"
);
return
false
;
}
...
...
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