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
0a890241
Commit
0a890241
authored
Oct 14, 2015
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(captiveportal, new) add anonymous login when no auth servers are provided
parent
395d0d20
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
17 deletions
+32
-17
AccessController.php
...ntrollers/OPNsense/CaptivePortal/Api/AccessController.php
+32
-17
No files found.
src/opnsense/mvc/app/controllers/OPNsense/CaptivePortal/Api/AccessController.php
View file @
0a890241
...
...
@@ -63,8 +63,17 @@ class AccessController extends ApiControllerBase
}
}
// return Unauthorized
return
array
(
'clientState'
=>
"NOT_AUTHORIZED"
,
"ipAddress"
=>
$this
->
getClientIp
());
// return Unauthorized including authentication requirements
$result
=
array
(
'clientState'
=>
"NOT_AUTHORIZED"
,
"ipAddress"
=>
$this
->
getClientIp
());
$mdlCP
=
new
CaptivePortal
();
$cpZone
=
$mdlCP
->
getByZoneID
(
$zoneid
);
if
(
$cpZone
!=
null
&&
trim
((
string
)
$cpZone
->
authservers
)
==
""
)
{
// no authentication needed, logon without username/password
$result
[
'authType'
]
=
'none'
;
}
else
{
$result
[
'authType'
]
=
'normal'
;
}
return
$result
;
}
/**
...
...
@@ -109,32 +118,38 @@ class AccessController extends ApiControllerBase
if
(
$this
->
request
->
isOptions
())
{
// return empty result on CORS preflight
return
array
();
}
elseif
(
$this
->
request
->
isPost
()
&&
$this
->
request
->
hasPost
(
'user'
)
)
{
}
elseif
(
$this
->
request
->
isPost
())
{
// close session for long running action
$this
->
sessionClose
();
// get username from post
$userName
=
$this
->
request
->
getPost
(
"user"
,
"striptags"
);
$userName
=
$this
->
request
->
getPost
(
"user"
,
"striptags"
,
null
);
// search zone info, to retrieve list of authenticators
$mdlCP
=
new
CaptivePortal
();
$cpZone
=
$mdlCP
->
getByZoneID
(
$zoneid
);
if
(
$cpZone
!=
null
)
{
// authenticate user
$isAuthenticated
=
false
;
$authFactory
=
new
AuthenticationFactory
();
foreach
(
explode
(
','
,
(
string
)
$cpZone
->
authservers
)
as
$authServerName
)
{
$authServer
=
$authFactory
->
get
(
trim
(
$authServerName
));
// try this auth method
$isAuthenticated
=
$authServer
->
authenticate
(
$userName
,
$this
->
request
->
getPost
(
"password"
,
"string"
)
);
if
(
trim
((
string
)
$cpZone
->
authservers
)
!=
""
)
{
// authenticate user
$isAuthenticated
=
false
;
$authFactory
=
new
AuthenticationFactory
();
foreach
(
explode
(
','
,
(
string
)
$cpZone
->
authservers
)
as
$authServerName
)
{
$authServer
=
$authFactory
->
get
(
trim
(
$authServerName
));
// try this auth method
$isAuthenticated
=
$authServer
->
authenticate
(
$userName
,
$this
->
request
->
getPost
(
"password"
,
"string"
)
);
if
(
$isAuthenticated
)
{
// stop trying, when authenticated
break
;
if
(
$isAuthenticated
)
{
// stop trying, when authenticated
break
;
}
}
}
else
{
// no authentication needed, set username to "anonymous@ip"
$userName
=
"anonymous@"
.
$clientIp
;
$isAuthenticated
=
true
;
}
if
(
$isAuthenticated
)
{
...
...
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