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
85664101
Commit
85664101
authored
Apr 22, 2016
by
Ad Schellevis
Committed by
Franco Fichtner
Apr 27, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(proxy) auth, don't quit when squid sends an empty string
(cherry picked from commit
9fd6504d
)
parent
2b392a67
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
35 deletions
+38
-35
squid.auth-user.php
src/etc/inc/squid.auth-user.php
+38
-35
No files found.
src/etc/inc/squid.auth-user.php
View file @
85664101
...
@@ -36,48 +36,51 @@ openlog("squid", LOG_ODELAY, LOG_AUTH);
...
@@ -36,48 +36,51 @@ openlog("squid", LOG_ODELAY, LOG_AUTH);
$authFactory
=
new
\OPNsense\Auth\AuthenticationFactory
();
$authFactory
=
new
\OPNsense\Auth\AuthenticationFactory
();
$f
=
fopen
(
"php://stdin"
,
"r"
);
$f
=
fopen
(
"php://stdin"
,
"r"
);
while
(
$line
=
fgets
(
$f
))
{
while
(
!
(
feof
(
$f
)))
{
$fields
=
explode
(
' '
,
trim
(
$line
));
$line
=
fgets
(
$f
);
$username
=
rawurldecode
(
$fields
[
0
]);
if
(
$line
)
{
$password
=
rawurldecode
(
$fields
[
1
]);
$fields
=
explode
(
' '
,
trim
(
$line
));
$username
=
rawurldecode
(
$fields
[
0
]);
$password
=
rawurldecode
(
$fields
[
1
]);
$isAuthenticated
=
false
;
$isAuthenticated
=
false
;
if
(
isset
(
$config
[
'OPNsense'
][
'proxy'
][
'forward'
][
'authentication'
][
'method'
]))
{
if
(
isset
(
$config
[
'OPNsense'
][
'proxy'
][
'forward'
][
'authentication'
][
'method'
]))
{
foreach
(
explode
(
','
,
$config
[
'OPNsense'
][
'proxy'
][
'forward'
][
'authentication'
][
'method'
])
as
$authServerName
)
{
foreach
(
explode
(
','
,
$config
[
'OPNsense'
][
'proxy'
][
'forward'
][
'authentication'
][
'method'
])
as
$authServerName
)
{
$authServer
=
$authFactory
->
get
(
trim
(
$authServerName
));
$authServer
=
$authFactory
->
get
(
trim
(
$authServerName
));
if
(
$authServer
==
null
)
{
if
(
$authServer
==
null
)
{
// authenticator not found, use local
// authenticator not found, use local
$authServer
=
$authFactory
->
get
(
'Local Database'
);
$authServer
=
$authFactory
->
get
(
'Local Database'
);
}
}
$isAuthenticated
=
$authServer
->
authenticate
(
$username
,
$password
);
$isAuthenticated
=
$authServer
->
authenticate
(
$username
,
$password
);
if
(
$isAuthenticated
)
{
if
(
$isAuthenticated
)
{
if
(
get_class
(
$authServer
)
==
"OPNsense\Auth\Local"
)
{
if
(
get_class
(
$authServer
)
==
"OPNsense\Auth\Local"
)
{
// todo: user priv check needs a reload of squid, maybe it's better to move the token check to
// todo: user priv check needs a reload of squid, maybe it's better to move the token check to
// the auth object.
// the auth object.
//
//
// when using local authentication, check if user has role user-proxy-auth
// when using local authentication, check if user has role user-proxy-auth
$user
=
getUserEntry
(
$username
);
$user
=
getUserEntry
(
$username
);
if
(
is_array
(
$user
)
&&
userHasPrivilege
(
$user
,
"user-proxy-auth"
))
{
if
(
is_array
(
$user
)
&&
userHasPrivilege
(
$user
,
"user-proxy-auth"
))
{
break
;
break
;
}
else
{
// log user auth failure
syslog
(
LOG_WARNING
,
"user '
{
$username
}
' cannot authenticate for squid because of missing user-proxy-auth role"
);
fwrite
(
STDOUT
,
"ERR
\n
"
);
$isAuthenticated
=
false
;
}
}
else
{
}
else
{
// log user auth failure
break
;
syslog
(
LOG_WARNING
,
"user '
{
$username
}
' cannot authenticate for squid because of missing user-proxy-auth role"
);
fwrite
(
STDOUT
,
"ERR
\n
"
);
$isAuthenticated
=
false
;
}
}
}
else
{
break
;
}
}
}
}
}
}
}
if
(
$isAuthenticated
)
{
if
(
$isAuthenticated
)
{
syslog
(
LOG_NOTICE
,
"user '
{
$username
}
' authenticated
\n
"
);
syslog
(
LOG_NOTICE
,
"user '
{
$username
}
' authenticated
\n
"
);
fwrite
(
STDOUT
,
"OK
\n
"
);
fwrite
(
STDOUT
,
"OK
\n
"
);
}
else
{
}
else
{
syslog
(
LOG_WARNING
,
"user '
{
$username
}
' could not authenticate.
\n
"
);
syslog
(
LOG_WARNING
,
"user '
{
$username
}
' could not authenticate.
\n
"
);
fwrite
(
STDOUT
,
"ERR
\n
"
);
fwrite
(
STDOUT
,
"ERR
\n
"
);
}
}
}
}
}
...
...
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