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
7e5ff770
Commit
7e5ff770
authored
Nov 10, 2015
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(auth) add dropKey to api handler
parent
e369c686
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
0 deletions
+27
-0
API.php
src/opnsense/mvc/app/library/OPNsense/Auth/API.php
+27
-0
No files found.
src/opnsense/mvc/app/library/OPNsense/Auth/API.php
View file @
7e5ff770
...
...
@@ -91,6 +91,33 @@ class API implements IAuthConnector
return
null
;
}
/**
* remove user api key
* @param string $username username
* @param string $apikey api key
* @return bool key found
*/
public
function
dropKey
(
$username
,
$apikey
)
{
$configObj
=
Config
::
getInstance
()
->
object
();
foreach
(
$configObj
->
system
->
children
()
as
$key
=>
$value
)
{
if
(
$key
==
'user'
&&
(
string
)
$username
==
(
string
)
$value
->
name
)
{
if
(
isset
(
$value
->
apikeys
))
{
$indx
=
0
;
foreach
(
$value
->
apikeys
->
children
()
as
$apiNodeId
=>
$apiNode
)
{
if
(
$apiNodeId
==
'item'
&&
(
string
)
$apiNode
->
key
==
$apikey
)
{
unset
(
$value
->
apikeys
->
item
[
$indx
]);
Config
::
getInstance
()
->
save
();
return
true
;
}
$indx
++
;
}
}
}
}
return
false
;
}
/**
* authenticate user against local database (in config.xml)
* @param string $username username to authenticate
...
...
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